How to make sql_exporter consider different database versions when fetching data? #473
-
When I use the exporter fetching data from Mysql's information schema tables , different version of databases have different metrics table name. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @blueeye2015, there is no way to set conditionals for queries, as we would need an additional query to identify the version of the database. And each database has a different way to store the version. It doesn't play well with the agnostic nature of this exporter. So currently the config file might need to be pre-rendered based on the requirements. It happens outside of sql_exporter anyways. Other available options are (in the order of increasing complexity):
Version-specific queries work fine within a context of a single database engine, so it might be a bit tricky to come up with a generic and reliable solution. Overall, I might get back to it after v1.0 is released. Until then, we have to use one of the options above. |
Beta Was this translation helpful? Give feedback.
-
For PostgreSQL, I've created views that call a function. That function contains the logic to check for which version is installed and runs the appropriate query. Makes it more complicated from the database end, but vastly simplifies it from the exporter end and is a lot more flexible long term. If another version change comes out, just update the function and everything continues to work as before without any other changes needed. Pretty sure the same could be done for mysql |
Beta Was this translation helpful? Give feedback.
Hi @blueeye2015, there is no way to set conditionals for queries, as we would need an additional query to identify the version of the database. And each database has a different way to store the version. It doesn't play well with the agnostic nature of this exporter.
So currently the config file might need to be pre-rendered based on the requirements. It happens outside of sql_exporter anyways.
Other available options are (in the order of increasing complexity):
sql_exporter
and call them separately with query parameter/metrics?jobs[]=job_name
;