Skip to content

Commit

Permalink
Merge pull request #128 from grafana/add-ingester-sample-values-metric
Browse files Browse the repository at this point in the history
Add ingested sample values total metric.
  • Loading branch information
cyriltovena authored Jul 28, 2022
2 parents bb64ba7 + aab4cf3 commit 08155fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/firedb/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ func (h *Head) Ingest(ctx context.Context, p *profilev1.Profile, id uuid.UUID, e
}
h.index.Add(profile, profilesLabels)

h.metrics.sampleValuesIngested.WithLabelValues(metricName).Add(float64(len(p.Sample) * len(profilesLabels)))

return nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/firedb/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type headMetrics struct {

sizeBytes *prometheus.GaugeVec
rowsWritten *prometheus.CounterVec

sampleValuesIngested *prometheus.CounterVec
}

func newHeadMetrics(reg prometheus.Registerer) *headMetrics {
Expand All @@ -39,6 +41,12 @@ func newHeadMetrics(reg prometheus.Registerer) *headMetrics {
Name: "fire_head_profiles_created_total",
Help: "Total number of profiles created in the head",
}),
sampleValuesIngested: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "fire_head_ingested_sample_values_total",
Help: "Number of sample values ingested into the head per profile type.",
},
[]string{"type"}),
}

m.series = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Expand All @@ -64,11 +72,13 @@ func newHeadMetrics(reg prometheus.Registerer) *headMetrics {
m.profiles,
m.profilesCreated,
m.rowsWritten,
m.sampleValuesIngested,
m,
)
}
return m
}

func (m *headMetrics) setHead(head *Head) *headMetrics {
m.head = head
return m
Expand Down

0 comments on commit 08155fc

Please sign in to comment.