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

up metric to show that database connection was successful #366

Closed
fsiler opened this issue Oct 20, 2023 · 5 comments
Closed

up metric to show that database connection was successful #366

fsiler opened this issue Oct 20, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@fsiler
Copy link

fsiler commented Oct 20, 2023

Is your feature request related to a problem? Please describe.
Right now, the /metrics endpoint returns all available data if the connection to the database is successful. However, it would be really useful to have an up or scrape_successsful or db_connection_successful metric which shows that:

  1. A database connection has been configured, and
  2. by its value indicates whether or not a connection was successful (1) or unsuccessful (0).

I've also had occasion to notice when, for example with connecting with an unprivileged account, that an incomplete set of metrics was returned. I would therefore also propose reflecting a metric (perhaps sql_all_metrics_succeeded) on /metrics which would, for example, have the value 1 when all requested queries are exposed and 0 otherwise, so that a user might have a cue to look in the logs for details.

Describe the solution you'd like
Metrics:

  • sql_exporter_connection_successful
    • 1 on success
    • 0 on failure
    • labeled with name or index of configuration, something so you can tell where it's configured
  • sql_exporter_queries_successful
    • 1 on everything worked
    • 0 on something failed
    • labeled with name or index of configuration, something so you can tell where it's configured
  • (optional, "would be nice") sql_exporter_queries_bucket
    • label configured: number of configured queries
    • label successful: number of successfully run queries
    • label failed: number of failed queries
    • labeled with name or index of configuration, something so you can tell where it's configured

Describe alternatives you've considered
Right now I'm having to write ugly absent() queries and do other detective work to figure out the former condition, and I haven't the faintest idea how to systematically work the second issue.

Additional context
n/a

@fsiler fsiler added the enhancement New feature or request label Oct 20, 2023
@burningalchemist
Copy link
Owner

burningalchemist commented Oct 21, 2023

Hi @fsiler, this feature is already available for named targets. If you use a single connection mode (with target configuration block), you need to add name field, then you'll get up and scrape_duration metrics.

Besides that, in the upcoming release (it's already merged to master), there's the metric scrape_errors_total which shows unsuccessful scrape count for respective queries.

As for anything related to buckets/histograms, this topic is currently on hold, as it requires accumulating and processing data in memory, which is not really lightweight. Without any additional mechanism to flush data periodically, the exporter would go out of memory pretty quick (and this is common in the area of Prometheus exporters).

@fsiler
Copy link
Author

fsiler commented Oct 27, 2023

This works great, many thanks!

@fsiler fsiler closed this as completed Oct 27, 2023
@fsiler fsiler reopened this Nov 6, 2023
@fsiler
Copy link
Author

fsiler commented Nov 6, 2023

Sorry to bother- was hoping to get a new release with the scrape_errors_total metric included? Wasn't sure if there's a regular release interval.

@burningalchemist
Copy link
Owner

burningalchemist commented Nov 6, 2023

Hi @fsiler, there's no regular release schedule, but I try to release at least every quarter. v0.13 with this feature is hopefully coming this week. 🙂

You can checkout the master branch in the meantime, and build for testing if you like.

@burningalchemist
Copy link
Owner

Hey @fsiler, v0.13 release is available. 👍

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

No branches or pull requests

2 participants