Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-106

Processor Counters should be included in the Status Reports

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.0
    • Component/s: Core Framework
    • Labels:
      None

      Description

      This would allow a Processor's Status HIstory to show counters that were maintained over time periods instead of having only a single count since system start.

        Issue Links

          Activity

          Hide
          joewitt Joseph Witt added a comment -

          We should document a strong use case here. I am suspect of whether counters are still a strong play beyond purely transient/developer-centric use cases especially given provenance the intent to add support for generating complex reports on such data. Given that I think counters as-is are done well. But if we have use cases to consider then of course...

          Show
          joewitt Joseph Witt added a comment - We should document a strong use case here. I am suspect of whether counters are still a strong play beyond purely transient/developer-centric use cases especially given provenance the intent to add support for generating complex reports on such data. Given that I think counters as-is are done well. But if we have use cases to consider then of course...
          Hide
          markap14 Mark Payne added a comment -

          Joseph Witt The benefit here I think is that we can basically expose custom metrics for processors, using the API that already exists. This is especially compelling now that we have added all of the Record-oriented processors, as this gives those processors a very simple and convenient way of exposing performance information about how many events/records/etc have been processed. The data rates that we currently supply are based on the number of FlowFiles and number of bytes, but that doesn't really translate well when comparing NiFi with other platforms that are record/event based.

          Show
          markap14 Mark Payne added a comment - Joseph Witt The benefit here I think is that we can basically expose custom metrics for processors, using the API that already exists. This is especially compelling now that we have added all of the Record-oriented processors, as this gives those processors a very simple and convenient way of exposing performance information about how many events/records/etc have been processed. The data rates that we currently supply are based on the number of FlowFiles and number of bytes, but that doesn't really translate well when comparing NiFi with other platforms that are record/event based.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user markap14 opened a pull request:

          https://github.com/apache/nifi/pull/1872

          NIFI-106: Expose processors' counters in Stats History

          Thank you for submitting a contribution to Apache NiFi.

          In order to streamline the review of the contribution we ask you
          to ensure the following steps have been taken:

              1. 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 master)?
          • [ ] Is your initial contribution a single, squashed commit?
              1. 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?
          • [ ] 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?
              1. For documentation related changes:
          • [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
              1. Note:
                Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/markap14/nifi NIFI-106

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/nifi/pull/1872.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #1872



          Show
          githubbot ASF GitHub Bot added a comment - GitHub user markap14 opened a pull request: https://github.com/apache/nifi/pull/1872 NIFI-106 : Expose processors' counters in Stats History Thank you for submitting a contribution to Apache NiFi. 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 master)? [ ] Is your initial contribution a single, squashed commit? 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? [ ] 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 travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/markap14/nifi NIFI-106 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/1872.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1872
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mcgilman commented on the issue:

          https://github.com/apache/nifi/pull/1872

          @markap14 - Counters are currently protected in access policies using a global resource. This is due to the fact that there are instance based Counters and a corresponding type based Counter. The type base Counters aggregate the values from all instances of that type reporting that Counter. Because type based Counters lose the association to the underlying instance, we are currently requiring a global permission.

          Access to stats and status history is available to any user with permissions to the UI (protected in access policies with the /flow resource). Because of this, I think we need to filter only allowable Counters into the status history. We will need to decide what is allowable in this context.

          Show
          githubbot ASF GitHub Bot added a comment - Github user mcgilman commented on the issue: https://github.com/apache/nifi/pull/1872 @markap14 - Counters are currently protected in access policies using a global resource. This is due to the fact that there are instance based Counters and a corresponding type based Counter. The type base Counters aggregate the values from all instances of that type reporting that Counter. Because type based Counters lose the association to the underlying instance, we are currently requiring a global permission. Access to stats and status history is available to any user with permissions to the UI (protected in access policies with the /flow resource). Because of this, I think we need to filter only allowable Counters into the status history. We will need to decide what is allowable in this context.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on the issue:

          https://github.com/apache/nifi/pull/1872

          @mcgilman great point! When I looked through the code, I saw the section of code that was handling permissions around the Status History but didn't look close enough. I had assumed that if the user doesn't have read permissions on the processor, that the stats would be made unavailable. However, looking again, I see that what we do is allow access to the stats but just blank out the name of the Processor.

          What probably makes sense, then, is to filter out any stats that come from counters unless the user does have read permissions to the Processor. I.e., if User A has no read permissions to a processor, its stats would return just the way they are now, with just the pre-defined Bytes In, Bytes Out, FlowFiles In, FlowFiles out, etc. But if the user does have read permissions, then they will also see all stats for counters emitted by that processor (but not type-specific counters, just instance-specific counters). Thoughts?

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on the issue: https://github.com/apache/nifi/pull/1872 @mcgilman great point! When I looked through the code, I saw the section of code that was handling permissions around the Status History but didn't look close enough. I had assumed that if the user doesn't have read permissions on the processor, that the stats would be made unavailable. However, looking again, I see that what we do is allow access to the stats but just blank out the name of the Processor. What probably makes sense, then, is to filter out any stats that come from counters unless the user does have read permissions to the Processor. I.e., if User A has no read permissions to a processor, its stats would return just the way they are now, with just the pre-defined Bytes In, Bytes Out, FlowFiles In, FlowFiles out, etc. But if the user does have read permissions, then they will also see all stats for counters emitted by that processor (but not type-specific counters, just instance-specific counters). Thoughts?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user gresockj commented on the issue:

          https://github.com/apache/nifi/pull/1872

          If you think it's appropriate to include in this ticket, you could also update the SiteToSiteStatusReportingTask to include the counters in the serialized JSON.

          Show
          githubbot ASF GitHub Bot added a comment - Github user gresockj commented on the issue: https://github.com/apache/nifi/pull/1872 If you think it's appropriate to include in this ticket, you could also update the SiteToSiteStatusReportingTask to include the counters in the serialized JSON.
          Hide
          joewitt Joseph Witt added a comment -

          Mark Payne can we bump this back off 1.3.0. I think gilman highlighted a very good point that needs discussion.
          Joseph Gresock perhaps file a JIRA to do that as well and connect it to this JIRA?

          Show
          joewitt Joseph Witt added a comment - Mark Payne can we bump this back off 1.3.0. I think gilman highlighted a very good point that needs discussion. Joseph Gresock perhaps file a JIRA to do that as well and connect it to this JIRA?
          Hide
          pvillard Pierre Villard added a comment -

          Joseph Gresock, is NIFI-3293 what you are looking for? Probably not exactly but...

          Show
          pvillard Pierre Villard added a comment - Joseph Gresock , is NIFI-3293 what you are looking for? Probably not exactly but...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on the issue:

          https://github.com/apache/nifi/pull/1872

          @mcgilman I pushed a new commit that addresses your concern, such that counters are included in the stats only if the user is authorized to read the processor that the counters belong to. Of note, all nodes in the cluster must also agree that counters should be shown (in case they differ in their policies).

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on the issue: https://github.com/apache/nifi/pull/1872 @mcgilman I pushed a new commit that addresses your concern, such that counters are included in the stats only if the user is authorized to read the processor that the counters belong to. Of note, all nodes in the cluster must also agree that counters should be shown (in case they differ in their policies).
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mcgilman commented on the issue:

          https://github.com/apache/nifi/pull/1872

          @markap14 this sounds like a good approach. Will review...

          Show
          githubbot ASF GitHub Bot added a comment - Github user mcgilman commented on the issue: https://github.com/apache/nifi/pull/1872 @markap14 this sounds like a good approach. Will review...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mcgilman commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/1872#discussion_r127741006

          — Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java —
          @@ -2867,6 +2867,7 @@ private ProcessorStatus getProcessorStatus(final RepositoryStatusReport report,
          status.setFlowFilesSent(entry.getFlowFilesSent());
          status.setBytesSent(entry.getBytesSent());
          status.setFlowFilesRemoved(entry.getFlowFilesRemoved());
          + status.setCounters(entry.getCounters());
          — End diff –

          This should be done conditionally based on `isProcessorAuthorized`. When captured for status history purposes that `Predicate` will always result in `true`.

          Show
          githubbot ASF GitHub Bot added a comment - Github user mcgilman commented on a diff in the pull request: https://github.com/apache/nifi/pull/1872#discussion_r127741006 — Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java — @@ -2867,6 +2867,7 @@ private ProcessorStatus getProcessorStatus(final RepositoryStatusReport report, status.setFlowFilesSent(entry.getFlowFilesSent()); status.setBytesSent(entry.getBytesSent()); status.setFlowFilesRemoved(entry.getFlowFilesRemoved()); + status.setCounters(entry.getCounters()); — End diff – This should be done conditionally based on `isProcessorAuthorized`. When captured for status history purposes that `Predicate` will always result in `true`.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mcgilman commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/1872#discussion_r127742238

          — Diff: nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java —
          @@ -234,6 +245,7 @@ public ProcessorStatus clone() {
          clonedObj.flowFilesRemoved = flowFilesRemoved;
          clonedObj.runStatus = runStatus;
          clonedObj.type = type;
          + clonedObj.counters = new HashMap<>(counters);
          — End diff –

          May need to protect against NPE when `counters` is null.

          Show
          githubbot ASF GitHub Bot added a comment - Github user mcgilman commented on a diff in the pull request: https://github.com/apache/nifi/pull/1872#discussion_r127742238 — Diff: nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java — @@ -234,6 +245,7 @@ public ProcessorStatus clone() { clonedObj.flowFilesRemoved = flowFilesRemoved; clonedObj.runStatus = runStatus; clonedObj.type = type; + clonedObj.counters = new HashMap<>(counters); — End diff – May need to protect against NPE when `counters` is null.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mcgilman commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/1872#discussion_r127739416

          — Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/StatusHistoryEndpointMerger.java —
          @@ -109,13 +119,49 @@ public NodeResponse merge(URI uri, String method, Set<NodeResponse> successfulRe
          noReadPermissionsComponentDetails = nodeStatus.getComponentDetails();
          }

          + if (!nodeStatus.isIncludeCounters()) {
          — End diff –

          I'm not sure we need to add a new field to the `nodeStatus` as the read permission is already present in the corresponding `nodeResponseEntity`.

          Show
          githubbot ASF GitHub Bot added a comment - Github user mcgilman commented on a diff in the pull request: https://github.com/apache/nifi/pull/1872#discussion_r127739416 — Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/StatusHistoryEndpointMerger.java — @@ -109,13 +119,49 @@ public NodeResponse merge(URI uri, String method, Set<NodeResponse> successfulRe noReadPermissionsComponentDetails = nodeStatus.getComponentDetails(); } + if (!nodeStatus.isIncludeCounters()) { — End diff – I'm not sure we need to add a new field to the `nodeStatus` as the read permission is already present in the corresponding `nodeResponseEntity`.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mcgilman commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/1872#discussion_r127741268

          — Diff: nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java —
          @@ -41,4 +41,9 @@

          • @return List of snapshots for a given component
            */
            List<StatusSnapshot> getStatusSnapshots();
            +
            + /**
            + * @return <code>true</code> if counter values are included in the Status History
            + */
            + boolean isIncludeCounters();
              • End diff –

          If we're able to remove the flag from the `StatusHistoryDTO`, we may also be able to remove this one.

          Show
          githubbot ASF GitHub Bot added a comment - Github user mcgilman commented on a diff in the pull request: https://github.com/apache/nifi/pull/1872#discussion_r127741268 — Diff: nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java — @@ -41,4 +41,9 @@ @return List of snapshots for a given component */ List<StatusSnapshot> getStatusSnapshots(); + + /** + * @return <code>true</code> if counter values are included in the Status History + */ + boolean isIncludeCounters(); End diff – If we're able to remove the flag from the `StatusHistoryDTO`, we may also be able to remove this one.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/1872#discussion_r128610464

          — Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/StatusHistoryEndpointMerger.java —
          @@ -109,13 +119,49 @@ public NodeResponse merge(URI uri, String method, Set<NodeResponse> successfulRe
          noReadPermissionsComponentDetails = nodeStatus.getComponentDetails();
          }

          + if (!nodeStatus.isIncludeCounters()) {
          — End diff –

          Good call. I didn't realize that was part of the entity.

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/1872#discussion_r128610464 — Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/StatusHistoryEndpointMerger.java — @@ -109,13 +119,49 @@ public NodeResponse merge(URI uri, String method, Set<NodeResponse> successfulRe noReadPermissionsComponentDetails = nodeStatus.getComponentDetails(); } + if (!nodeStatus.isIncludeCounters()) { — End diff – Good call. I didn't realize that was part of the entity.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/1872#discussion_r128610528

          — Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java —
          @@ -2867,6 +2867,7 @@ private ProcessorStatus getProcessorStatus(final RepositoryStatusReport report,
          status.setFlowFilesSent(entry.getFlowFilesSent());
          status.setBytesSent(entry.getBytesSent());
          status.setFlowFilesRemoved(entry.getFlowFilesRemoved());
          + status.setCounters(entry.getCounters());
          — End diff –

          Agreed.

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/1872#discussion_r128610528 — Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java — @@ -2867,6 +2867,7 @@ private ProcessorStatus getProcessorStatus(final RepositoryStatusReport report, status.setFlowFilesSent(entry.getFlowFilesSent()); status.setBytesSent(entry.getBytesSent()); status.setFlowFilesRemoved(entry.getFlowFilesRemoved()); + status.setCounters(entry.getCounters()); — End diff – Agreed.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/1872#discussion_r128610547

          — Diff: nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java —
          @@ -41,4 +41,9 @@

          • @return List of snapshots for a given component
            */
            List<StatusSnapshot> getStatusSnapshots();
            +
            + /**
            + * @return <code>true</code> if counter values are included in the Status History
            + */
            + boolean isIncludeCounters();
              • End diff –

          Noted.

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/1872#discussion_r128610547 — Diff: nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java — @@ -41,4 +41,9 @@ @return List of snapshots for a given component */ List<StatusSnapshot> getStatusSnapshots(); + + /** + * @return <code>true</code> if counter values are included in the Status History + */ + boolean isIncludeCounters(); End diff – Noted.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on a diff in the pull request:

          https://github.com/apache/nifi/pull/1872#discussion_r128610594

          — Diff: nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java —
          @@ -234,6 +245,7 @@ public ProcessorStatus clone() {
          clonedObj.flowFilesRemoved = flowFilesRemoved;
          clonedObj.runStatus = runStatus;
          clonedObj.type = type;
          + clonedObj.counters = new HashMap<>(counters);
          — End diff –

          Good catch. Will add a new commit shortly.

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/1872#discussion_r128610594 — Diff: nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java — @@ -234,6 +245,7 @@ public ProcessorStatus clone() { clonedObj.flowFilesRemoved = flowFilesRemoved; clonedObj.runStatus = runStatus; clonedObj.type = type; + clonedObj.counters = new HashMap<>(counters); — End diff – Good catch. Will add a new commit shortly.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user markap14 commented on the issue:

          https://github.com/apache/nifi/pull/1872

          @mcgilman ok i pushed a new commit. I also ran into another bug that occurred when a counter is present in some of the 'aggregate snapshot' fields but not all. Can you give it a review when you have a chance? THanks!

          Show
          githubbot ASF GitHub Bot added a comment - Github user markap14 commented on the issue: https://github.com/apache/nifi/pull/1872 @mcgilman ok i pushed a new commit. I also ran into another bug that occurred when a counter is present in some of the 'aggregate snapshot' fields but not all. Can you give it a review when you have a chance? THanks!
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 695e8aa98f1d9cce5a9b3025193ac57f9acd598e in nifi's branch refs/heads/master from Mark Payne
          [ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=695e8aa ]

          NIFI-106:

          • Expose processors' counters in Stats History
          • Only include counters in Processors' Status History if user has read access to corresponding Processor
          • Addressed review feedback. Found and addressed bug where a counter is not present in all of the aggregate snaphot values for status history, resulting in the UI not rendering the chart properly
          • This closes #1872
          Show
          jira-bot ASF subversion and git services added a comment - Commit 695e8aa98f1d9cce5a9b3025193ac57f9acd598e in nifi's branch refs/heads/master from Mark Payne [ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=695e8aa ] NIFI-106 : Expose processors' counters in Stats History Only include counters in Processors' Status History if user has read access to corresponding Processor Addressed review feedback. Found and addressed bug where a counter is not present in all of the aggregate snaphot values for status history, resulting in the UI not rendering the chart properly This closes #1872
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user mcgilman commented on the issue:

          https://github.com/apache/nifi/pull/1872

          Thanks @markap14! This has been merged to master.

          Show
          githubbot ASF GitHub Bot added a comment - Github user mcgilman commented on the issue: https://github.com/apache/nifi/pull/1872 Thanks @markap14! This has been merged to master.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/nifi/pull/1872

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/nifi/pull/1872

            People

            • Assignee:
              markap14 Mark Payne
              Reporter:
              mcgilman Matt Gilman
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development