Skip to content

Commit 3bfb906

Browse files
authored
Add metric for samples dropped by relabeling (#3158)
2 parents 932370b + 49fba87 commit 3bfb906

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

reporter/parca_reporter.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ type ParcaReporter struct {
137137
stacktraceWriteRequestBytes prometheus.Counter
138138
debuginfoUploadRequestBytes prometheus.Counter
139139
emptySamples prometheus.Counter
140+
skippedByRelabeling prometheus.Counter
140141

141142
// Pre-created sample counters by type (avoid WithLabelValues allocations)
142143
cpuSamples prometheus.Counter
@@ -220,6 +221,7 @@ func (r *ParcaReporter) ReportTraceEvent(trace *libpf.Trace,
220221
labelRetrievalResult := r.labelsForTID(meta.TID, meta.PID, meta.Comm, meta.CPU, meta.EnvVars)
221222

222223
if !labelRetrievalResult.keep {
224+
r.skippedByRelabeling.Inc()
223225
log.Debugf("Skipping trace event for PID %d, as it was filtered out by relabeling", meta.PID)
224226
return nil
225227
}
@@ -672,6 +674,10 @@ func New(
672674
Name: "parca_reporter_empty_samples",
673675
Help: "The number of empty samples reported to the Parca reporter",
674676
})
677+
skippedByRelabeling := prometheus.NewCounter(prometheus.CounterOpts{
678+
Name: "parca_reporter_skipped_by_relabeling",
679+
Help: "The number of samples skipped due to relabeling rules",
680+
})
675681

676682
samplesByType := prometheus.NewCounterVec(prometheus.CounterOpts{
677683
Name: "parca_reporter_samples_total",
@@ -683,6 +689,7 @@ func New(
683689
reg.MustRegister(stacktraceWriteRequestBytes)
684690
reg.MustRegister(debuginfoUploadRequestBytes)
685691
reg.MustRegister(emptySamples)
692+
reg.MustRegister(skippedByRelabeling)
686693
reg.MustRegister(samplesByType)
687694

688695
r := &ParcaReporter{
@@ -711,6 +718,7 @@ func New(
711718
sampleWrites: sampleWrites,
712719
sampleWriteRequestBytes: sampleWriteRequestBytes,
713720
emptySamples: emptySamples,
721+
skippedByRelabeling: skippedByRelabeling,
714722
stacktraceWriteRequestBytes: stacktraceWriteRequestBytes,
715723
debuginfoUploadRequestBytes: debuginfoUploadRequestBytes,
716724
cpuSamples: samplesByType.WithLabelValues("cpu"),

0 commit comments

Comments
 (0)