Navigation Menu

Skip to content

Commit

Permalink
MB-54078 add TYPE information for prometheus metrics
Browse files Browse the repository at this point in the history
DP agent will scrape the indexer prometheus REST endpoint and
send the metrics to CP direclty(instead of using the ns-server
prometheus REST endpoint).

As per the OpenMetric specs, all metrics need to have TYPE information:
https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md

e.g.
"# TYPE index_memory_quota gauge"
index_memory_quota 268435456

This information is being added only to _prometheusMetrics endpoint in this commit.

Change-Id: If6d306fe29b2b3df6ce0ade78615fe4a2b03e6ae
  • Loading branch information
deepkaran committed Oct 12, 2022
1 parent 1cc8963 commit 21f636b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions secondary/indexer/stats_manager.go
Expand Up @@ -3039,13 +3039,23 @@ func (s *statsManager) handleMetrics(w http.ResponseWriter, r *http.Request) {
}

out := make([]byte, 0, 256)
out = append(out, []byte(fmt.Sprintf("# TYPE %vmemory_quota gauge\n", METRICS_PREFIX))...)
out = append(out, []byte(fmt.Sprintf("%vmemory_quota %v\n", METRICS_PREFIX, is.memoryQuota.Value()))...)

out = append(out, []byte(fmt.Sprintf("# TYPE %vmemory_used_total gauge\n", METRICS_PREFIX))...)
out = append(out, []byte(fmt.Sprintf("%vmemory_used_total %v\n", METRICS_PREFIX, is.memoryUsed.Value()))...)

if common.IsServerlessDeployment() {
out = append(out, []byte(fmt.Sprintf("# TYPE %vmemory_used_actual gauge\n", METRICS_PREFIX))...)
out = append(out, []byte(fmt.Sprintf("%vmemory_used_actual %v\n", METRICS_PREFIX, is.memoryUsedActual.Value()))...)

out = append(out, []byte(fmt.Sprintf("# TYPE %vunits_quota gauge\n", METRICS_PREFIX))...)
out = append(out, []byte(fmt.Sprintf("%vunits_quota %v\n", METRICS_PREFIX, is.unitsQuota.Value()))...)

out = append(out, []byte(fmt.Sprintf("# TYPE %vunits_used_actual gauge\n", METRICS_PREFIX))...)
out = append(out, []byte(fmt.Sprintf("%vunits_used_actual %v\n", METRICS_PREFIX, is.unitsUsedActual.Value()))...)

out = append(out, []byte(fmt.Sprintf("# TYPE %vnum_tenants gauge\n", METRICS_PREFIX))...)
out = append(out, []byte(fmt.Sprintf("%vnum_tenants %v\n", METRICS_PREFIX, is.numTenants.Value()))...)
}

Expand Down

0 comments on commit 21f636b

Please sign in to comment.