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

Multiple queries under 1 metric #117

Closed
LumePart opened this issue Aug 1, 2022 · 3 comments
Closed

Multiple queries under 1 metric #117

LumePart opened this issue Aug 1, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@LumePart
Copy link

LumePart commented Aug 1, 2022

Hello!
It would be very useful to allow for multiple select (and other) queries under 1 metric

An example use case:
Monitoring query completion time

DECLARE @t1 DATETIME;
DECLARE @t2 DATETIME;

SET @t1 = GETDATE();
SELECT /* query */;
SET @t2 = GETDATE();
SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;

And elapsed_ms could go in values to be scraped

It seems that right now, the exporter only takes the first select query and ignores others whether it has a AS command or not

@LumePart LumePart added the enhancement New feature or request label Aug 1, 2022
@burningalchemist
Copy link
Owner

Hi @nootb, let me take a look and thanks for the example. 👍

@burningalchemist
Copy link
Owner

@nootb, sql_exporter is using database/sql package as the interface for the available drivers. As per documentation there are existing limitations.

As far as I know there's a proposal to enable batch queries in database/sql, but it's not merged yet anyway.

If you're interested specifically in query duration, I think this could be possible to fetch from query logs from the underlying drivers. But I've taken a look and there's no standard, so this unfortunately won't work at the moment.

I'd probably design a dedicated exporter for such needs, working with a specific driver directly, so I could utilize features available outside of database/sql interface.

@LumePart
Copy link
Author

LumePart commented Aug 1, 2022

Thanks for the detailed answer!

@LumePart LumePart closed this as completed Aug 1, 2022
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