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 2021/10/07 14:48:49 UTC

[GitHub] [nifi] noblenumbat360 opened a new pull request #5447: NIFI-8272 Delete stale metrics from REST API Prometheus endpoint.

noblenumbat360 opened a new pull request #5447:
URL: https://github.com/apache/nifi/pull/5447


   <!--
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
         http://www.apache.org/licenses/LICENSE-2.0
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
   -->
   Thank you for submitting a contribution to Apache NiFi.
   
   ### Description of PR
   Please provide a short description of the PR here:
   
   Fixes bug reported in NIFI-8272 where the metrics from deleted or renamed processors/connections/funnels/etc continue to be shown on the REST API Prometheus metrics endpoint.
   
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [x] 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.
   
   - [x] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
   
   - [x] 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?
   - [x] Have you written or updated unit tests to verify your changes?
   - [x] Have you verified that the full build is successful on JDK 8?
   - [x] Have you verified that the full build is successful on JDK 11?
   - [n/a] 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)?
   - [n/a] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [n/a] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [n/a] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [n/a] 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] noblenumbat360 commented on a change in pull request #5447: NIFI-8272 Delete stale metrics from REST API Prometheus endpoint.

Posted by GitBox <gi...@apache.org>.
noblenumbat360 commented on a change in pull request #5447:
URL: https://github.com/apache/nifi/pull/5447#discussion_r740655325



##########
File path: nifi-nar-bundles/nifi-extension-utils/nifi-prometheus-utils/src/main/java/org/apache/nifi/prometheus/util/PrometheusMetricsUtil.java
##########
@@ -101,20 +98,6 @@ public static CollectorRegistry createNifiMetrics(NiFiMetricsRegistry nifiMetric
         final String componentId = StringUtils.isEmpty(status.getId()) ? DEFAULT_LABEL_STRING : status.getId();
         final String componentName = StringUtils.isEmpty(status.getName()) ? DEFAULT_LABEL_STRING : status.getName();
 
-        // Clear all collectors to deal with removed/renamed components -- for root PG only
-        if("RootProcessGroup".equals(componentType)) {

Review comment:
       Thanks for the response.
   Removing this code does not cause a regression in PrometheusReportingTask. The correct behavior is confirmed by the existing tests starting on line 142 in PrometheusReportingTaskIT.java as well as manually confirmed.
   The removed code is no longer needed because a new NiFiMetricsRegistry is created (line 142 in PrometheusReportingTask.java) before each call to createNifiMetrics.
   This change was introduced in NIFI-7379 Support multiple instances of Prometheus registries/metrics.
   
   In hindsight, I should have had the removed code as a separate ticket as it isn't required to be removed to fix the bug I reported in NIFI-8272. Although it is all related so I did the work together.
   




-- 
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] noblenumbat360 commented on a change in pull request #5447: NIFI-8272 Delete stale metrics from REST API Prometheus endpoint.

Posted by GitBox <gi...@apache.org>.
noblenumbat360 commented on a change in pull request #5447:
URL: https://github.com/apache/nifi/pull/5447#discussion_r740655325



##########
File path: nifi-nar-bundles/nifi-extension-utils/nifi-prometheus-utils/src/main/java/org/apache/nifi/prometheus/util/PrometheusMetricsUtil.java
##########
@@ -101,20 +98,6 @@ public static CollectorRegistry createNifiMetrics(NiFiMetricsRegistry nifiMetric
         final String componentId = StringUtils.isEmpty(status.getId()) ? DEFAULT_LABEL_STRING : status.getId();
         final String componentName = StringUtils.isEmpty(status.getName()) ? DEFAULT_LABEL_STRING : status.getName();
 
-        // Clear all collectors to deal with removed/renamed components -- for root PG only
-        if("RootProcessGroup".equals(componentType)) {

Review comment:
       Thanks for the response.
   Removing this code does not cause a regression in PrometheusReportingTask. The correct behavior is confirmed by the existing tests starting on line 142 in PrometheusReportingTaskIT.java as well as manually confirmed.
   The removed code is no longer needed because a new NiFiMetricsRegistry is created (line 142 in PrometheusReportingTask.java) before each call to createNifiMetrics.
   This change was introduced in NIFI-7379 Support multiple instances of Prometheus registries/metrics.
   
   In hindsight, I should have had the removed code as a separate ticket as it isn't required to be removed to fix the bug I reported in NIFI-8272. Although it is all related so I did the work together.
   




-- 
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] mattyb149 commented on a change in pull request #5447: NIFI-8272 Delete stale metrics from REST API Prometheus endpoint.

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on a change in pull request #5447:
URL: https://github.com/apache/nifi/pull/5447#discussion_r736779420



##########
File path: nifi-nar-bundles/nifi-extension-utils/nifi-prometheus-utils/src/main/java/org/apache/nifi/prometheus/util/PrometheusMetricsUtil.java
##########
@@ -101,20 +98,6 @@ public static CollectorRegistry createNifiMetrics(NiFiMetricsRegistry nifiMetric
         final String componentId = StringUtils.isEmpty(status.getId()) ? DEFAULT_LABEL_STRING : status.getId();
         final String componentName = StringUtils.isEmpty(status.getName()) ? DEFAULT_LABEL_STRING : status.getName();
 
-        // Clear all collectors to deal with removed/renamed components -- for root PG only
-        if("RootProcessGroup".equals(componentType)) {

Review comment:
       This code was explicitly added for the PrometheusReportingTask under [NIFI-6715](https://issues.apache.org/jira/browse/NIFI-6715) and [NIFI-7017](https://issues.apache.org/jira/browse/NIFI-7017). It's my understanding that this PR is meant to have the Prometheus REST endpoint act like PrometheusReportingTask with regards to clearing stale metrics. Does removing this code cause a regression in PromethusReportingTask?

##########
File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml
##########
@@ -432,5 +432,9 @@
             <groupId>org.slf4j</groupId>
             <artifactId>jcl-over-slf4j</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-mock</artifactId>

Review comment:
       This should have `test` scope so it doesn't get included with the nifi-web-api artifact




-- 
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] mattyb149 commented on pull request #5447: NIFI-8272 Delete stale metrics from REST API Prometheus endpoint.

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on pull request #5447:
URL: https://github.com/apache/nifi/pull/5447#issuecomment-963729464


   +1 LGTM, GHA passed and I tried on a live NiFi instance, verified the removed processor's metrics no longer showed up in the Prometheus scrape results. Thanks for the fix! Merging to main


-- 
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] noblenumbat360 commented on a change in pull request #5447: NIFI-8272 Delete stale metrics from REST API Prometheus endpoint.

Posted by GitBox <gi...@apache.org>.
noblenumbat360 commented on a change in pull request #5447:
URL: https://github.com/apache/nifi/pull/5447#discussion_r740655325



##########
File path: nifi-nar-bundles/nifi-extension-utils/nifi-prometheus-utils/src/main/java/org/apache/nifi/prometheus/util/PrometheusMetricsUtil.java
##########
@@ -101,20 +98,6 @@ public static CollectorRegistry createNifiMetrics(NiFiMetricsRegistry nifiMetric
         final String componentId = StringUtils.isEmpty(status.getId()) ? DEFAULT_LABEL_STRING : status.getId();
         final String componentName = StringUtils.isEmpty(status.getName()) ? DEFAULT_LABEL_STRING : status.getName();
 
-        // Clear all collectors to deal with removed/renamed components -- for root PG only
-        if("RootProcessGroup".equals(componentType)) {

Review comment:
       Thanks for the response.
   Removing this code does not cause a regression in PrometheusReportingTask. The correct behavior is confirmed by the existing tests starting on line 142 in PrometheusReportingTaskIT.java as well as manually confirmed.
   The removed code is no longer needed because a new NiFiMetricsRegistry is created (line 142 in PrometheusReportingTask.java) before each call to createNifiMetrics.
   This change was introduced in NIFI-7379 Support multiple instances of Prometheus registries/metrics.
   
   In hindsight, I should have had the removed code as a separate ticket as it isn't required to be removed to fix the bug I reported in NIFI-8272. Although it is all related so I did the work together.
   




-- 
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] mattyb149 closed pull request #5447: NIFI-8272 Delete stale metrics from REST API Prometheus endpoint.

Posted by GitBox <gi...@apache.org>.
mattyb149 closed pull request #5447:
URL: https://github.com/apache/nifi/pull/5447


   


-- 
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