private Map<MetricDefinition, List<DataPoint>> getMetric(Set<MetricDefinition> metricDefinitionSet, Statement statement) throws SystemException {
    Map<MetricDefinition, List<DataPoint>> results = new HashMap<MetricDefinition, List<DataPoint>>();
    try {
      StringBuilder query = new StringBuilder();
      Set<String> recordTypeContexts = new HashSet<String>();
      Set<String> recordTypeNamess = new HashSet<String>();
      Set<String> tagPairsPatterns = new HashSet<String>();
      Set<String> nodeNames = new HashSet<String>();
      Set<String> serviceNames = new HashSet<String>();
      Set<String> metricNames = new HashSet<String>();
      long startTime = 0, endTime = 0;
      for (MetricDefinition metricDefinition : metricDefinitionSet) {
        if (metricDefinition.getRecordTypeContext() == null || metricDefinition.getRecordTypeName() == null || metricDefinition.getNodeName() == null) {
          continue;
        }

        recordTypeContexts.add(metricDefinition.getRecordTypeContext());
        recordTypeNamess.add(metricDefinition.getRecordTypeName());
        tagPairsPatterns.add(metricDefinition.getTagPairsPattern());
        nodeNames.add(metricDefinition.getNodeName());
        serviceNames.add(metricDefinition.getServiceName());
        metricNames.add(metricDefinition.getMetricName());
        startTime = metricDefinition.getStartTime();
        endTime = metricDefinition.getEndTime();
      }

      for (String tagPairsPattern : tagPairsPatterns) {
        if (query.length() != 0) {
          query.append("\nUNION\n");
        }
        query.append(String.format(GET_METRICS_STATEMENT,
          "'" + StringUtils.join(recordTypeContexts, "','") + "'",
          "'" + StringUtils.join(recordTypeNamess, "','") + "'",
          "'%" + tagPairsPattern + "%'",
          "'" + StringUtils.join(nodeNames, "','") + "'",
          "'" + StringUtils.join(serviceNames, "','") + "'",
          startTime,
          endTime,
          "'" + StringUtils.join(metricNames, "','") + "'"
        ));
      }

      ResultSet rs = null;
      if (query.length() != 0) {
        rs = statement.executeQuery(query.toString());
      }

      if (rs != null) {
        //(RecordTimeStamp bigint, MetricValue NVARCHAR(512))
        while (rs.next()) {
          MetricDefinition metricDefinition = new MetricDefinition(rs.getString("RecordTypeContext"), rs.getString("RecordTypeName"), rs.getString("TagPairs"), rs.getString("MetricName"), rs.getString("ServiceName"), rs.getString("NodeName"));
          ParsePosition parsePosition = new ParsePosition(0);
          NumberFormat numberFormat = NumberFormat.getInstance();
          Number parsedNumber = numberFormat.parse(rs.getNString("MetricValue"), parsePosition);
          if (results.containsKey(metricDefinition)) {
            results.get(metricDefinition).add(new DataPoint(rs.getLong("RecordTimeStamp"), parsedNumber));
          } else {
            List<DataPoint> dataPoints = new ArrayList<DataPoint>();
            dataPoints.add(new DataPoint(rs.getLong("RecordTimeStamp"), parsedNumber));
            results.put(metricDefinition, dataPoints);
          }
        }
      }
    } catch (SQLException e) {
      throw new SystemException("Error during getMetric call : caught exception - ", e);
    }
    return results;
  }
SQL based property/metrics provider required for ambari-scom.
contrib/ambari-scom/ambari-scom-server/src/main/java/org/apache/ambari/scom/SQLPropertyProvider.java