We currently use the Prometheus golang client to present metrics to a Prometheus endpoint.
I've recently had an ask from our customers to report these metrics with user-specified labels so they can filter the stats better.
I'm having some serious issues getting this to work. I've seen 2 cases.
Is there a workaround for this?
Delete won't work because labels will forever be not matchy for the bigger label map.
Is there a recommended workflow for this?
My code to set a metric is as follows
func (p *PrometheusSink) setMetricValue(subsystem string, name string, val float64, labels map[string]string) {
p.mu.Lock()
defer p.mu.Unlock()
key := p.normalizeKey(name)
g, ok := p.gauges[key]
if !ok {
lbl_keys := make([]string, 0, len(labels))
for k := range labels {
lbl_keys = append(lbl_keys, k)
}
g = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "app",
Subsystem: p.normalizeKey(subsystem),
Name: key,
Help: key,
}, lbl_keys)
p.Registry.Register(g)
p.gauges[key] = g
}
gauge, err := g.GetMetricWith(labels)
if err == nil {
gauge.Set(val)
p.updateGauageTs(g, gauge, labels)
}
}--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/c05ff878-20f2-414a-824d-67e586626b27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.