statsd / statsd

Daemon for easy but powerful stats aggregation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set counter metric to a specific value

dctc42 opened this issue · comments

My team came across an edge case where we need to set a counter metric to a specific value to compensate for changes made offline/operationally in a database.

I tried combining counter and gauge operations with the same metric name but this generates two time series in our metrics backend (we use Wavefront).

Is there a way to set a counter type metric to a specific value?

Hi @dctc42, there's nothing to set a counter to a particular level at the moment. However you can increment by any desired amount (see https://github.com/statsd/statsd/blob/master/docs/metric_types.md#counting).

If you want to set a counter to a specific value then there would probably need to be something added to the statsd protocol to support it. Do gauges definetely not fit your use case? It sounds like you're more worried about an ending value, than incrementing by set amounts.

Thanks for your reply, @BlueHatbRit . I think we'll need to use gauges. I think the issue we're facing is consistency. App developers want to track operations that mostly match to rows in DB tables. The problem is there too many ways the DB can change outside the application.

@dctc42 that's an interesting use case! I'm not sure what database you're using, but you could consider using a database trigger to call out to a script/service that can handle the tracking for you. Then in that scenario, the database (as the authoratative source) will be able to trigger the incrementing event for you.

@BlueHatbRit This is a legacy app with a lot of performance issues. The DB (MSSQL)is basically an app server so I would be concerned about adding triggers in this type of environment.

Maybe change data capture functionality could help with this

😞 that's a shame, best of luck with the implementation. If this feature is something we can find a way to justify existing in the statsd protocol then I'm sure we'd be up for considering it, but we've not had the need to implement it so far so it doesn't currently exist.

Thanks!