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

Consider supporting Counter type #14

Open
dominikschulz opened this issue Jul 13, 2017 · 8 comments
Open

Consider supporting Counter type #14

dominikschulz opened this issue Jul 13, 2017 · 8 comments
Assignees

Comments

@dominikschulz
Copy link
Contributor

We should consider supporting Counter type metrics. In general I'd like to keep the SQL Exporter as simple as possible, but it may make sense to support Counters.

@dominikschulz dominikschulz changed the title Considuer supporting Counter type Consider supporting Counter type Jul 16, 2017
@saifulmuhajir
Copy link

I would love to have this feature.

Thank you for this awesome project.

@pasali
Copy link

pasali commented Aug 15, 2018

+1 for this feature, we currently have scenario that needs counter type metrics.

@zwopir
Copy link
Collaborator

zwopir commented Aug 15, 2018

Hi @pasali,

could you elaborate on your scenario, so I can think about it? As Dominik said, we'd like to keep the exporter as simple as possible, but this shouldn't prevent us from implementing important features.

@pasali
Copy link

pasali commented Aug 15, 2018

Hi, @zwopir

Let say i have table called 'failed_sms' and i want to fire alerts when count of failed SMSes in last 5 minutes greater than 1.

@zwopir
Copy link
Collaborator

zwopir commented Aug 15, 2018

I understand. But that's not a prometheus counter. Have a look at https://prometheus.io/docs/concepts/metric_types/#counter. In your use case there are two mismatches to consider the metric a prometheus counter:

  • the metric isn't cumulativ
  • the metric can go up and down

@pasali
Copy link

pasali commented Aug 15, 2018

I can not use type gauge either. Because if query returns zero rows, metric value stays the same.I see you don't change the metric value when query returns zero rows because this can create ambiguity(my opinion). So i think if i can store my metrics as counter and look for the increase then i i can fire alerts. Or do you have any suggestions ?

@zwopir
Copy link
Collaborator

zwopir commented Aug 15, 2018

I may have misunderstood or made false assumptions about your use case. If you export a SELECT count(*) FROM ... WHERE <...timerange limit...> as a prometheus counter, my above statement is true. If we where to implement a counter that adds the result of a query to the counter, that counter would be a valid prometheus counter. But that would imply that we limit the timerange to the time since the last scrape and here the trouble begins....!
So I would suggest to use delta() as promQL function or (if possible) instrument the code to count the number of failures

@pasali
Copy link

pasali commented Aug 17, 2018

@zwopir thanks for the suggestion, but i think best way to handle this is usage type gauge and always return rows to make metric value 0.

@dominikschulz dominikschulz removed their assignment Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants