-
Notifications
You must be signed in to change notification settings - Fork 803
User defined configuration to run the query for different database server version from single yml file #428
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
Conversation
By default query will run on all the databases if "runonserver" is not provided.
If user want the query to be run on multiple database versions, use below string.
runonserver: "9.5, 9.6"
Example yml file as below. ( e.g. below query will run only on database version 9.5 )
pg_replication:
query: "SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp())) as lag"
master: true
runonserver: "9.5"
metrics:
- lag:
usage: "GAUGE"
description: "Replication lag behind master in seconds"
Instead of having db version string from yml file, user can define the range of
database server version where query is to be executed.
If user want to run the query on database version greater than 10.0.0, use below format.
runonserver: ">=10.0.0"
Below are the example of db version range user can defined in yml file.
<=10.1.0
>=12.1.0
=11.0.0
<9.6.0 || >=11.0.0
|
@wrouesnel Can you please update what is wrong here ? |
Only Server type hold that value.
|
@neel5481 Have a few questions:
|
|
@cobolbaby When user want to execute queries on specific database only to collect metrics, "RunOnServer" will be useful and it will be used along with "PG_EXPORTER_EXTEND_QUERY_PATH" where user defined the queries in yaml file and give to the exporter. You can check detail usage in the commit message. |
|
@neel5481 After trying and debugging, I found that only the exporter's startup configuration |
|
postgres_exporter/cmd/postgres_exporter/postgres_exporter.go Lines 1468 to 1476 in 1dc2104
Are you sure that the above logic should be placed in the loop logic? |
Yes, you are right. Do you have any suggestion where should we add this skip block after reading the actual database version and runonserver given in yaml file, before I debug ? |
Can you please verify this pull request ? |
|
LGTM. In fact, I have already commited #503, but still need to do more for |
|
Ah I spent ages thinking something was wrong with my flow through the codebase instead of questioning the codebase :p Thanks for raising this issue, @neel5481 your changes were what I was thinking to do too so thanks for making them. This should be merged ASAP I think @wrouesnel (if you dont mind please) |
…rver version from single yml file (prometheus-community#428) * Run the query for specific database version if provided from yml file. By default query will run on all the databases if "runonserver" is not provided. If user want the query to be run on multiple database versions, use below string. runonserver: "9.5, 9.6" Example yml file as below. ( e.g. below query will run only on database version 9.5 ) pg_replication: query: "SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp())) as lag" master: true runonserver: "9.5" metrics: - lag: usage: "GAUGE" description: "Replication lag behind master in seconds" * Fixed the below review comments given by Ashesh Vashi Instead of having db version string from yml file, user can define the range of database server version where query is to be executed. If user want to run the query on database version greater than 10.0.0, use below format. runonserver: ">=10.0.0" Below are the example of db version range user can defined in yml file. <=10.1.0 >=12.1.0 =11.0.0 <9.6.0 || >=11.0.0 * Remove the call from unused places where 'runOnServer' is not required. Only Server type hold that value. * Fix compilation issues. * Fix the issue with Debugln to print the database server version
User can define the range of database server version where query is to be executed in yml configuration file.
If user want to run the query on database version greater than 10.0.0, use below format.
runonserver: ">=10.0.0"