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 07:36:56 UTC
[GitHub] [nifi] timeabarna opened a new pull request #5673: NIFI-9587 Add json output for Prometheus metrics
timeabarna opened a new pull request #5673:
URL: https://github.com/apache/nifi/pull/5673
https://issues.apache.org/jira/browse/NIFI-9587
#### Description of PR
Enables exposing Prometheus metrics in json
Enables basic filtering for Sample names and Sample values
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
- [ ] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
### For code changes:
- [ ] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] Have you verified that the full build is successful on JDK 8?
- [ ] Have you verified that the full build is successful on JDK 11?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
- [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
- [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
--
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
[GitHub] [nifi] exceptionfactory commented on a change in pull request #5673: NIFI-9587 Add json output for Prometheus metrics
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [nifi] timeabarna commented on a change in pull request #5673: NIFI-9587 Add json output for Prometheus metrics
Posted by GitBox <gi...@apache.org>.
timeabarna commented on a change in pull request #5673:
URL: https://github.com/apache/nifi/pull/5673#discussion_r788399775
##########
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:
Renamed it to rootFieldName.
--
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
[GitHub] [nifi] timeabarna commented on pull request #5673: NIFI-9587 Add json output for Prometheus metrics
Posted by GitBox <gi...@apache.org>.
timeabarna commented on pull request #5673:
URL: https://github.com/apache/nifi/pull/5673#issuecomment-1017359679
Thanks @exceptionfactory for the review.
--
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
[GitHub] [nifi] timeabarna commented on pull request #5673: NIFI-9587 Add json output for Prometheus metrics
Posted by GitBox <gi...@apache.org>.
timeabarna commented on pull request #5673:
URL: https://github.com/apache/nifi/pull/5673#issuecomment-1016165928
Hello @exceptionfactory , as this PR is building on your PR 5571 would you mind reviewing it? Thanks in advance.
--
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
[GitHub] [nifi] timeabarna commented on a change in pull request #5673: NIFI-9587 Add json output for Prometheus metrics
Posted by GitBox <gi...@apache.org>.
timeabarna commented on a change in pull request #5673:
URL: https://github.com/apache/nifi/pull/5673#discussion_r788610509
##########
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:
As Prometheus Sample has no default constructor and 2 argument constructors so ObjectMapper was not able to deserialise. I needed to create a custom deserialiser for Sample.
--
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
[GitHub] [nifi] exceptionfactory closed pull request #5673: NIFI-9587 Add json output for Prometheus metrics
Posted by GitBox <gi...@apache.org>.
exceptionfactory closed pull request #5673:
URL: https://github.com/apache/nifi/pull/5673
--
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