luchunliang commented on a change in pull request #2165:
URL: https://github.com/apache/incubator-inlong/pull/2165#discussion_r786391225
##########
File path:
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/metrics/prometheus/PrometheusMetricListener.java
##########
@@ -105,7 +140,114 @@ public void snapshot(String domain, List<MetricItemValue>
itemValues) {
metricValue.addAndGet(fieldValue);
}
}
+ // id dimension
+ String dimensionKey = itemValue.getKey();
+ MetricItemValue dimensionMetricValue =
this.dimensionMetricValueMap.get(dimensionKey);
+ if (dimensionKey == null) {
+ dimensionMetricValue = new MetricItemValue(dimensionKey, new
ConcurrentHashMap<String, String>(),
+ new ConcurrentHashMap<String, MetricValue>());
+ this.dimensionMetricValueMap.putIfAbsent(dimensionKey,
dimensionMetricValue);
+ dimensionMetricValue =
this.dimensionMetricValueMap.get(dimensionKey);
+
dimensionMetricValue.getDimensions().putAll(itemValue.getDimensions());
+ // add prometheus label name
+ for (Entry<String, String> entry :
itemValue.getDimensions().entrySet()) {
+ if (!this.dimensionKeys.contains(entry.getKey())) {
+ this.dimensionKeys.add(entry.getKey());
+ }
+ }
+ }
+ // count
+ for (Entry<String, MetricValue> entry :
itemValue.getMetrics().entrySet()) {
+ String fieldName = entry.getValue().name;
+ MetricValue metricValue =
dimensionMetricValue.getMetrics().get(fieldName);
+ if (metricValue == null) {
+ metricValue = MetricValue.of(fieldName,
entry.getValue().value);
+ dimensionMetricValue.getMetrics().put(metricValue.name,
metricValue);
+ continue;
+ }
+ metricValue.value += entry.getValue().value;
+ }
+ }
+ }
+
+ /**
+ * collect
+ *
+ * @return
+ */
+ @Override
+ public List<MetricFamilySamples> collect() {
+
+ // total
+ CounterMetricFamily totalCounter = new CounterMetricFamily(metricName
+ ".total", "help",
+ Arrays.asList("dimension"));
+ totalCounter.addMetric(Arrays.asList(M_READ_SUCCESS_COUNT),
metricItem.readSuccessCount.get());
+ totalCounter.addMetric(Arrays.asList(M_READ_SUCCESS_SIZE),
metricItem.readSuccessSize.get());
+ totalCounter.addMetric(Arrays.asList(M_READ_FAIL_COUNT),
metricItem.readFailCount.get());
+ totalCounter.addMetric(Arrays.asList(M_READ_FAIL_SIZE),
metricItem.readFailSize.get());
+ //
+ totalCounter.addMetric(Arrays.asList(M_SEND_COUNT),
metricItem.sendCount.get());
+ totalCounter.addMetric(Arrays.asList(M_SEND_SIZE),
metricItem.sendSize.get());
+ //
+ totalCounter.addMetric(Arrays.asList(M_SEND_SUCCESS_COUNT),
metricItem.sendSuccessCount.get());
+ totalCounter.addMetric(Arrays.asList(M_SEND_SUCCESS_SIZE),
metricItem.sendSuccessSize.get());
+ totalCounter.addMetric(Arrays.asList(M_SEND_FAIL_COUNT),
metricItem.sendFailCount.get());
+ totalCounter.addMetric(Arrays.asList(M_SEND_FAIL_SIZE),
metricItem.sendFailSize.get());
+ //
+ totalCounter.addMetric(Arrays.asList(M_SINK_DURATION),
metricItem.sinkDuration.get());
+ totalCounter.addMetric(Arrays.asList(M_NODE_DURATION),
metricItem.nodeDuration.get());
+ totalCounter.addMetric(Arrays.asList(M_WHOLE_DURATION),
metricItem.wholeDuration.get());
+ List<MetricFamilySamples> mfs = new ArrayList<>();
+ mfs.add(totalCounter);
+
+ // id dimension
+ CounterMetricFamily idCounter = new CounterMetricFamily(metricName +
".id", "help", this.dimensionKeys);
Review comment:
CounterMetricFamily idCounter = new
CounterMetricFamily(metricName + "&group=id",
"The metrics of inlong dataflow.", this.dimensionKeys);
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]