diff --git a/docs/operational-metrics.md b/docs/operational-metrics.md index 2320f80c3..5a4cb1a57 100644 --- a/docs/operational-metrics.md +++ b/docs/operational-metrics.md @@ -47,6 +47,14 @@ Each table below provides documentation for an exported flowlogs-pipeline operat | **Labels** | error, metric, key | +### encode_prom_metrics_reported +| **Name** | encode_prom_metrics_reported | +|:---|:---| +| **Description** | Total number of prometheus metrics reported by this stage | +| **Type** | gauge | +| **Labels** | stage | + + ### ingest_batch_size_bytes | **Name** | ingest_batch_size_bytes | |:---|:---| diff --git a/pkg/pipeline/encode/encode_prom.go b/pkg/pipeline/encode/encode_prom.go index 2a9e8c163..5f7cb1b20 100644 --- a/pkg/pipeline/encode/encode_prom.go +++ b/pkg/pipeline/encode/encode_prom.go @@ -56,7 +56,7 @@ type EncodeProm struct { aggHistos []histoInfo expiryTime time.Duration mCache *putils.TimedCache - mChacheLen prometheus.Gauge + mChacheLenMetric prometheus.Gauge exitChan <-chan struct{} metricsProcessed prometheus.Counter metricsDropped prometheus.Counter @@ -82,6 +82,12 @@ var ( operational.TypeCounter, "error", "metric", "key", ) + mChacheLen = operational.DefineMetric( + "encode_prom_metrics_reported", + "Total number of prometheus metrics reported by this stage", + operational.TypeGauge, + "stage", + ) ) // Encode encodes a metric before being stored @@ -335,12 +341,6 @@ func NewEncodeProm(opMetrics *operational.Metrics, params config.StageParam) (En log.Debugf("histos = %v", histos) log.Debugf("aggHistos = %v", aggHistos) - mChacheLen := operational.DefineMetric( - "encode_prom_metrics_reported", - "Total number of prometheus metrics reported by this stage", - operational.TypeGauge, - "stage", - ) mChacheLenMetric := opMetrics.NewGauge(&mChacheLen, params.Name) w := &EncodeProm{ @@ -350,7 +350,7 @@ func NewEncodeProm(opMetrics *operational.Metrics, params config.StageParam) (En aggHistos: aggHistos, expiryTime: expiryTime, mCache: putils.NewTimedCache(cfg.MaxMetrics, mChacheLenMetric), - mChacheLen: mChacheLenMetric, + mChacheLenMetric: mChacheLenMetric, exitChan: putils.ExitChannel(), metricsProcessed: opMetrics.NewCounter(&metricsProcessed, params.Name), metricsDropped: opMetrics.NewCounter(&metricsDropped, params.Name),