[ 
https://issues.apache.org/jira/browse/NIFI-16608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Adela Jaworowska-Nowak updated NIFI-16608:
------------------------------------------
    Description: 
h3. Background

{\{UpdateCounter}} records values through \{{ProcessSession.adjustCounter()}}. 
Those values are stored in \{{CounterRepository}} and are queryable via \{{GET 
/nifi-api/counters}} (reset via \{{PUT /nifi-api/counters}} and \{{PUT 
/nifi-api/counters/{id}}}).

{\{UpdateGauge}} records values through \{{ProcessSession.recordGauge()}}. 
Those values are forwarded only to \{{ComponentMetricReporter}}. If no reporter 
is configured, \{{DefaultComponentMetricReporter}} drops the gauge. There is no 
framework store and no REST API to read the last recorded value.

Counters and gauges are therefore inconsistent for local inspection, debugging, 
and automated tests.

h3. Proposal

Persist the latest gauge value in a \{{GaugeRepository}} when 
\{{recordGauge()}} is applied, using the same commit-timing rules as counters 
(\{{NOW}} vs \{{SESSION_COMMITTED}}). Continue to call 
\{{ComponentMetricReporter.recordGauge()}} so OpenTelemetry (or any other 
reporter) remains the export path. The store is for local query, not a 
replacement for reporting.

h3. Identity

* Counters remain keyed by context + name. Metric attributes/labels are 
reporter-only.
* Gauges are keyed by *name + attributes/labels*, plus the same two contexts as 
counters:
** \{{"{componentName} (\{componentId})"}}
** \{{"All {componentType}'s"}}
* Distinct label sets (for example per-table last-ingestion time) must not 
overwrite each other.

h3. REST and authorization

Analogous to counters:

* \{{GET /nifi-api/gauges}}
* \{{PUT /nifi-api/gauges}} (reset all values to 0)
* \{{PUT /nifi-api/gauges/{id}}} (reset one gauge to 0)
* Authorization resource \{{/gauges}} (\{{ResourceType.Gauges}})
* Toolkit \{{GaugesClient}}

No Angular listing page is required. The policy type should appear so 
\{{/gauges}} can be granted like \{{/counters}}.

h3. Cluster

Do *not* sum gauges. When merging node snapshots, the value with the latest 
\{{recorded}} timestamp wins.

h3. Out of scope

* Changing processor \{{recordGauge}} APIs
* Requiring a \{{ComponentMetricReporter}} implementation in order to read 
gauges from a running node
* A UI page equivalent to Counters

  was:
UpdateCounter records values through ProcessSession.adjustCounter(). Those 
values are stored in the framework CounterRepository and are queryable via GET 
/nifi-api/counters (and reset via PUT /nifi-api/counters/\{id}).

UpdateGauge records values through ProcessSession.recordGauge(). Those values 
are forwarded only to ComponentMetricReporter. If no reporter is configured, 
DefaultComponentMetricReporter is used and the gauge is dropped. There is no 
framework store and no REST API to read the last recorded gauge value.

This makes counters and gauges inconsistent for local inspection, debugging, 
and automated tests. Custom gauges (for example last-ingestion time or latency 
recorded by UpdateGauge) cannot be asserted through the NiFi API the way 
counters can.

Proposal:
- Persist the latest value for each named gauge when recordGauge() is 
committed, using the same commit-timing rules as counters (NOW vs 
SESSION_COMMITTED).
- Keep gauge identity as name plus optional metric attributes/labels, matching 
how counters are keyed.
- Expose gauges over REST analogously to counters, for example:
  - GET /nifi-api/gauges
  - optional GET or reset by id if that matches the counters client
- Continue to call ComponentMetricReporter.recordGauge() so OpenTelemetry (or 
any other reporter) remains the export path. The store is for local query, not 
a replacement for reporting.

This should not change processor behavior or require a ComponentMetricReporter 
implementation in order to read gauge values from the running node.


> Add Gauge store and REST API analogous to Counters
> --------------------------------------------------
>
>                 Key: NIFI-16608
>                 URL: https://issues.apache.org/jira/browse/NIFI-16608
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: Adela Jaworowska-Nowak
>            Assignee: Adela Jaworowska-Nowak
>            Priority: Major
>
> h3. Background
> {\{UpdateCounter}} records values through 
> \{{ProcessSession.adjustCounter()}}. Those values are stored in 
> \{{CounterRepository}} and are queryable via \{{GET /nifi-api/counters}} 
> (reset via \{{PUT /nifi-api/counters}} and \{{PUT /nifi-api/counters/{id}}}).
> {\{UpdateGauge}} records values through \{{ProcessSession.recordGauge()}}. 
> Those values are forwarded only to \{{ComponentMetricReporter}}. If no 
> reporter is configured, \{{DefaultComponentMetricReporter}} drops the gauge. 
> There is no framework store and no REST API to read the last recorded value.
> Counters and gauges are therefore inconsistent for local inspection, 
> debugging, and automated tests.
> h3. Proposal
> Persist the latest gauge value in a \{{GaugeRepository}} when 
> \{{recordGauge()}} is applied, using the same commit-timing rules as counters 
> (\{{NOW}} vs \{{SESSION_COMMITTED}}). Continue to call 
> \{{ComponentMetricReporter.recordGauge()}} so OpenTelemetry (or any other 
> reporter) remains the export path. The store is for local query, not a 
> replacement for reporting.
> h3. Identity
> * Counters remain keyed by context + name. Metric attributes/labels are 
> reporter-only.
> * Gauges are keyed by *name + attributes/labels*, plus the same two contexts 
> as counters:
> ** \{{"{componentName} (\{componentId})"}}
> ** \{{"All {componentType}'s"}}
> * Distinct label sets (for example per-table last-ingestion time) must not 
> overwrite each other.
> h3. REST and authorization
> Analogous to counters:
> * \{{GET /nifi-api/gauges}}
> * \{{PUT /nifi-api/gauges}} (reset all values to 0)
> * \{{PUT /nifi-api/gauges/{id}}} (reset one gauge to 0)
> * Authorization resource \{{/gauges}} (\{{ResourceType.Gauges}})
> * Toolkit \{{GaugesClient}}
> No Angular listing page is required. The policy type should appear so 
> \{{/gauges}} can be granted like \{{/counters}}.
> h3. Cluster
> Do *not* sum gauges. When merging node snapshots, the value with the latest 
> \{{recorded}} timestamp wins.
> h3. Out of scope
> * Changing processor \{{recordGauge}} APIs
> * Requiring a \{{ComponentMetricReporter}} implementation in order to read 
> gauges from a running node
> * A UI page equivalent to Counters



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to