You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/01/19 14:20:49 UTC

[GitHub] [nifi] exceptionfactory commented on a change in pull request #5673: NIFI-9587 Add json output for Prometheus metrics

exceptionfactory commented on a change in pull request #5673:
URL: https://github.com/apache/nifi/pull/5673#discussion_r787790407



##########
File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
##########
@@ -428,7 +429,11 @@ public Response getFlowMetrics(
             @ApiParam(
                     value = "Regular Expression Pattern to be applied against the sample label value field"
             )
-            @QueryParam("sampleLabelValue") final String sampleLabelValue
+            @QueryParam("sampleLabelValue") final String sampleLabelValue,
+            @ApiParam(
+                    value = "Name of the first field of JSON object. Applicable for JSON producer only."
+            )
+            @QueryParam("firstFieldName") final String firstFieldName

Review comment:
       What do you think about naming this parameter `rootFieldName` or `parentFieldName`?  That might help clarify the fact that not only is the field first, but it wraps all other values.

##########
File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/TestFlowResource.java
##########
@@ -174,4 +291,79 @@ private String getResponseOutput(final Response response) throws IOException {
         final CollectorRegistry otherJvmCollectorRegistry = PrometheusMetricsUtil.createJvmMetrics(jvmMetricsRegistry, JmxJvmMetrics.getInstance(), OTHER_LABEL_VALUE);
         return Arrays.asList(jvmCollectorRegistry, otherJvmCollectorRegistry);
     }
+
+    private Map<String, List<Collector.MetricFamilySamples.Sample>> convertJsonResponseToMap(final Response response) throws IOException {
+        final String json = getResponseOutput(response);
+        final Type type = new TypeToken<Map<String, List<Collector.MetricFamilySamples.Sample>>>() {}.getType();
+        return new Gson().fromJson(json, type);

Review comment:
       Can GSON be replaced with the Jackson ObjectMapper?  Although GSON is already available, it would be helpful to use Jackson here since it is already used in the JSON output writer.




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org