-
-
Notifications
You must be signed in to change notification settings - Fork 97
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Describe the bug
sql query result and sql_exporter metrics are not equal.
To Reproduce
scraped results
postgres@host-1 ~ $ curl localhost:9399/metrics 2>/dev/null | grep 'pg_settings_source_cnt'
# HELP pg_settings_source_cnt Number of settings
# TYPE pg_settings_source_cnt gauge
pg_settings_source_cnt{job="postgresql_common_queries",slave="False",sourcefile="/etc/postgresql-15/postgresql.conf",target="database1"} 82
pg_settings_source_cnt{job="postgresql_common_queries",slave="False",sourcefile="default",target="database1"} 280query use by sql_exporter to get metrics
database1=# select coalesce(sourcefile, 'default') as sourcefile, count(*) as cnt from pg_settings group by sourcefile;
sourcefile | cnt
------------------------------------+-----
default | 273
/etc/postgresql-15/postgresql.conf | 84
(2 rows)Expected behavior
Scraped results and query results are expected to be same.
scrape sourcefile.default is 280
query sourcefile.default is 273
scrape sourcefile."/etc/postgresql-15/postgresql.conf" is 82
query sourcefile."/etc/postgresql-15/postgresql.conf" is 84
Configuration
Metric definition
- metric_name: pg_settings_source_cnt
type: gauge
help: Number of settings
values: [cnt]
static_labels:
slave: False
key_labels: [sourcefile]
query_ref: pg_settings_source
.....
....
....
- query_name: pg_settings_source
query: |
select
coalesce(sourcefile, 'default') as sourcefile,
count(*) as cnt
from pg_settings group by sourcefilesql_exporter.yml
global:
# If scrape_timeout <= 0, no timeout is set unless Prometheus provides one. The default is 10s.
scrape_timeout: 30s
# Subtracted from Prometheus' scrape_timeout to give us some headroom and prevent Prometheus from timing out first.
scrape_timeout_offset: 500ms
# Minimum interval between collector runs: by default (0s) collectors are executed on every scrape.
min_interval: 0s
# Maximum number of open connections to any one target. Metric queries will run concurrently on multiple connections,
# as will concurrent scrapes.
max_connections: 3
# Maximum number of idle connections to any one target. Unless you use very long collection intervals, this should
# always be the same as max_connections.
max_idle_connections: 3
# Maximum number of maximum amount of time a connection may be reused. Expired connections may be closed lazily before reuse.
# If 0, connections are not closed due to a connection's age.
max_connection_lifetime: 5m
# Data source name always has a URI schema that matches the driver name. In some cases (e.g. MySQL)
# the schema gets dropped or replaced to match the driver expected DSN format.
jobs:
- job_name: postgresql_common_queries
collectors: ['postgresql_common_queries']
static_configs:
- targets:
database1: 'postgresql://monuser@localhost:5432/database1?sslmode=disable'
# Collectors (referenced by name) to execute on the target.
# Glob patterns are supported (see <https://pkg.go.dev/path/filepath#Match> for syntax).
# collectors: [postgresql_*]
collector_files:
- "*.collector.yml"Additional context
Add any other context about the problem here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested