Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export counters as counters #178

Closed
jkohen opened this issue Jul 24, 2018 · 6 comments · Fixed by #256
Closed

Export counters as counters #178

jkohen opened this issue Jul 24, 2018 · 6 comments · Fixed by #256
Labels

Comments

@jkohen
Copy link

jkohen commented Jul 24, 2018

I work on the Stackdriver integration with Prometheus and a user filed an issue because this redis exporter exports counters as gauges, and Stackdriver doesn't allow rate computations over gauge. I know this isn't a major problem for Prometheus (it can mostly cause glitches on process restart), but would you consider fixing the setMetrics method to set the right metric type? Any workaround on our side will be hard to maintain. Thanks!

@oliver006
Copy link
Owner

Thanks for raising the issue.
From looking at the Prometheus Golang library docs here (and #31 ) it looks like using a ConstMetric is way to go.
Alas, I currently don't have bandwidth to implement that change and it's not a priority for me as I don't use Stackdriver but I'd be happy to review & merge a PR if you (or anyone else ) submits one.

@oliver006
Copy link
Owner

Actually, it might be a lot more easy change than I initially thought.

Replacing this part:

e.metrics[name] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: e.namespace,
Name: name,
Help: name + "metric", // needs to be set for prometheus >= 2.3.1
}, []string{"addr", "alias"})
e.metricsMtx.Unlock()
}
var labels prometheus.Labels = map[string]string{"addr": scr.Addr, "alias": scr.Alias}
if len(scr.DB) > 0 {
labels["db"] = scr.DB
}
e.metrics[name].With(labels).Set(float64(scr.Value))

with something that uses NewCounterFunc might do the trick.

@lukmdo
Copy link

lukmdo commented Aug 13, 2018

@jkohen IMO Gauges are more appropriate for common case (redis values can go up and down)
which value would you like to calculate rate on ?

only ones that get pass making are included

func includeMetric(s string) bool {
if strings.HasPrefix(s, "db") || strings.HasPrefix(s, "cmdstat_") || strings.HasPrefix(s, "cluster_") {
return true
}
_, ok := metricMap[s]
return ok
}

@oliver006 perhaps
a) ones from metricMap that are*_total could use ConstMetric of type CounterValue ?
b) or better by adding types to metricMap

@oliver006
Copy link
Owner

a) could be a quick hack to make it work but I was thinking about going with option b) and store what type metric to use with each entry in the map.

@jkohen
Copy link
Author

jkohen commented May 22, 2019

Thank you, Oliver!

@mtanda FYI, this has been closed. In reference to Stackdriver/stackdriver-prometheus#14 you filed.

@mtanda
Copy link

mtanda commented May 22, 2019

@jkohen That's fantastic!
Thank you for notifying me.

Dear Oliver,
Thank you for your work. I appreciate so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants