diff --git a/collector/builder-config.yaml b/collector/builder-config.yaml index c95b0242bd3..3c882a2264a 100644 --- a/collector/builder-config.yaml +++ b/collector/builder-config.yaml @@ -122,8 +122,8 @@ replaces: - github.com/thanos-io/objstore => github.com/grafana/objstore v0.0.0-20250210100727-533688b5600d # TODO - remove forks when changes are merged upstream — non-singleton cadvisor - github.com/google/cadvisor => github.com/grafana/cadvisor grafana-v0.54.1-noglobals - # TODO - track exporter-package-v0.18.1 branch of grafana fork; remove once merged upstream - - github.com/prometheus-community/postgres_exporter => github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363 + # TODO - this tracks exporter-package-v0.19.0 branch of grafana fork; remove once all patches are merged upstream + - github.com/prometheus-community/postgres_exporter => github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf # TODO - remove once PR is merged upstream - https://github.com/prometheus/mysqld_exporter/pull/774 - github.com/prometheus/mysqld_exporter => github.com/grafana/mysqld_exporter v0.17.2-0.20250226152553-be612e3fdedd # TODO: replace node_exporter with custom fork for multi usage. https://github.com/prometheus/node_exporter/pull/2812 @@ -144,4 +144,4 @@ replaces: - sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.20.4 # Fork to grafana repo to address issue with freebsd build tags. This can be removed once https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/42645 is fixed - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filestatsreceiver => github.com/grafana/opentelemetry-collector-contrib/receiver/filestatsreceiver v0.0.0-20260126095124-0af81a9e8966 - # END GENERATED REPLACES \ No newline at end of file + # END GENERATED REPLACES diff --git a/collector/go.mod b/collector/go.mod index 7802129bee4..a7b6e728329 100644 --- a/collector/go.mod +++ b/collector/go.mod @@ -773,10 +773,10 @@ require ( github.com/prometheus/client_golang v1.23.2 // indirect github.com/prometheus/client_golang/exp v0.0.0-20250914183048-a974e0d45e0a // indirect github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.67.4 // indirect + github.com/prometheus/common v0.67.5 // indirect github.com/prometheus/common/assets v0.2.0 // indirect github.com/prometheus/consul_exporter v0.8.0 // indirect - github.com/prometheus/exporter-toolkit v0.15.0 // indirect + github.com/prometheus/exporter-toolkit v0.15.1 // indirect github.com/prometheus/memcached_exporter v0.13.0 // indirect github.com/prometheus/mysqld_exporter v0.17.2 // indirect github.com/prometheus/node_exporter v1.9.1 // indirect @@ -1061,7 +1061,7 @@ replace github.com/thanos-io/objstore => github.com/grafana/objstore v0.0.0-2025 replace github.com/google/cadvisor => github.com/grafana/cadvisor v0.0.0-20260204200106-865a22723970 -replace github.com/prometheus-community/postgres_exporter => github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363 +replace github.com/prometheus-community/postgres_exporter => github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf replace github.com/prometheus/mysqld_exporter => github.com/grafana/mysqld_exporter v0.17.2-0.20250226152553-be612e3fdedd diff --git a/collector/go.sum b/collector/go.sum index ceb71a08949..091a2aa33b7 100644 --- a/collector/go.sum +++ b/collector/go.sum @@ -1181,8 +1181,8 @@ github.com/grafana/opentelemetry-ebpf-profiler v0.0.202602-0.20260123050037-c33a github.com/grafana/opentelemetry-ebpf-profiler v0.0.202602-0.20260123050037-c33a6e86a2f5/go.mod h1:oqSk8XwYnL4saX2ZdpfnTJV9vURSNaVjK6yomOAVIPI= github.com/grafana/otel-profiling-go v0.5.1 h1:stVPKAFZSa7eGiqbYuG25VcqYksR6iWvF3YH66t4qL8= github.com/grafana/otel-profiling-go v0.5.1/go.mod h1:ftN/t5A/4gQI19/8MoWurBEtC6gFw8Dns1sJZ9W4Tls= -github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363 h1:/vCopugIegPx9brm+E9+4bMQ6uIsZujCoE7su3bLLbk= -github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363/go.mod h1:dOdKpz09HRMtkSs8kba90eNmrL81E+LMotcP7eW9/ek= +github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf h1:GaBnxd6zH0+QaZuMBWra2MdjKUWTI8edIQx1dXMLau8= +github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf/go.mod h1:4zH24t6LEqkdL3ZfBTtp0kGHOBr6komR55CrmL2AAg4= github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg= github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= github.com/grafana/pyroscope/api v1.2.0 h1:SfHDZcEZ4Vbj/Jj3bTOSpm4IDB33wLA2xBYxROhiL4U= @@ -2112,16 +2112,16 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.31.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.67.4 h1:yR3NqWO1/UyO1w2PhUvXlGQs/PtFmoveVO0KZ4+Lvsc= -github.com/prometheus/common v0.67.4/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI= +github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= +github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= github.com/prometheus/common/assets v0.2.0 h1:0P5OrzoHrYBOSM1OigWL3mY8ZvV2N4zIE/5AahrSrfM= github.com/prometheus/common/assets v0.2.0/go.mod h1:D17UVUE12bHbim7HzwUvtqm6gwBEaDQ0F+hIGbFbccI= github.com/prometheus/consul_exporter v0.8.0 h1:2z3drFic65WFoHaJRKkmnJRRlBLmmxVqT8L9LO2yxAo= github.com/prometheus/consul_exporter v0.8.0/go.mod h1:KHTgkT1/oLpXKC4+mKZV63hZSMHuKskUnHoenEave4Y= github.com/prometheus/exporter-toolkit v0.7.0/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g= github.com/prometheus/exporter-toolkit v0.7.1/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g= -github.com/prometheus/exporter-toolkit v0.15.0 h1:Pcle5sSViwR1x0gdPd0wtYrPQENBieQAM7TmT0qtb2U= -github.com/prometheus/exporter-toolkit v0.15.0/go.mod h1:OyRWd2iTo6Xge9Kedvv0IhCrJSBu36JCfJ2yVniRIYk= +github.com/prometheus/exporter-toolkit v0.15.1 h1:XrGGr/qWl8Gd+pqJqTkNLww9eG8vR/CoRk0FubOKfLE= +github.com/prometheus/exporter-toolkit v0.15.1/go.mod h1:P/NR9qFRGbCFgpklyhix9F6v6fFr/VQB/CVsrMDGKo4= github.com/prometheus/memcached_exporter v0.13.0 h1:d246RYODFCXy39XA8S2PBrqp5jLCSvl9b4KsYspDCHk= github.com/prometheus/memcached_exporter v0.13.0/go.mod h1:fp7Wk6v0RFijeP3Syvd1TShBSJoCG5iFfvPdi5dCMEU= github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos= diff --git a/dependency-replacements.yaml b/dependency-replacements.yaml index 003727d37f5..d9f8a69ec9a 100644 --- a/dependency-replacements.yaml +++ b/dependency-replacements.yaml @@ -79,9 +79,9 @@ replaces: dependency: github.com/google/cadvisor replacement: github.com/grafana/cadvisor grafana-v0.54.1-noglobals - - comment: TODO - track exporter-package-v0.18.1 branch of grafana fork; remove once merged upstream + - comment: TODO - this tracks exporter-package-v0.19.0 branch of grafana fork; remove once all patches are merged upstream dependency: github.com/prometheus-community/postgres_exporter - replacement: github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363 + replacement: github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf - comment: TODO - remove once PR is merged upstream - https://github.com/prometheus/mysqld_exporter/pull/774 dependency: github.com/prometheus/mysqld_exporter diff --git a/docs/sources/reference/components/prometheus/prometheus.exporter.postgres.md b/docs/sources/reference/components/prometheus/prometheus.exporter.postgres.md index b4b74f0697d..9c6c53abaff 100644 --- a/docs/sources/reference/components/prometheus/prometheus.exporter.postgres.md +++ b/docs/sources/reference/components/prometheus/prometheus.exporter.postgres.md @@ -45,6 +45,8 @@ There are a number of environment variables that aren't recommended for use, as Refer to the [`postgres_exporter` repository](https://github.com/prometheus-community/postgres_exporter#environment-variables) for a full list of environment variables. {{< /admonition >}} +The `prometheus.exporter.postgres` component configures the embedded [`postgres_exporter`](https://github.com/prometheus-community/postgres_exporter) to run with a collection timeout of 10 seconds. + By default, the same set of metrics is enabled as in the upstream [`postgres_exporter`](https://github.com/prometheus-community/postgres_exporter/). If `custom_queries_config_path` is set, additional metrics defined in the given configuration file will be exposed. If `disable_default_metrics` is set to `true`, only the metrics defined in the `custom_queries_config_path` file will be exposed. @@ -132,10 +134,13 @@ The `stat_statements` block configures the selection of both the query ID and th This configuration takes effect only when the `stat_statements` collector is enabled. The following arguments are supported: -| Name | Type | Description | Default | Required | -| --------------- | -------- | --------------------------------------------------- | ------- | -------- | -| `include_query` | `bool` | Enable the selection of query ID and SQL statement. | `false` | no | -| `query_length` | `number` | Maximum length of the statement query text. | `120` | no | +| Name | Type | Description | Default | Required | +| ------------------- | -------------- | --------------------------------------------------- | ------- | -------- | +| `exclude_databases` | `list(string)` | Comma-separated list of database names to exclude. | `[]` | no | +| `exclude_users` | `list(string)` | Comma-separated list of user names to exclude. | `[]` | no | +| `include_query` | `bool` | Enable the selection of query ID and SQL statement. | `false` | no | +| `limit` | `number` | Maximum number of statements to fetch. | `100` | no | +| `query_length` | `number` | Maximum length of the statement query text. | `120` | no | ## Exported fields diff --git a/extension/alloyengine/go.mod b/extension/alloyengine/go.mod index b52460629a9..8bdaa2d6a4c 100644 --- a/extension/alloyengine/go.mod +++ b/extension/alloyengine/go.mod @@ -733,9 +733,9 @@ require ( github.com/prometheus/client_golang v1.23.2 // indirect github.com/prometheus/client_golang/exp v0.0.0-20250914183048-a974e0d45e0a // indirect github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.67.4 // indirect + github.com/prometheus/common v0.67.5 // indirect github.com/prometheus/consul_exporter v0.8.0 // indirect - github.com/prometheus/exporter-toolkit v0.15.0 // indirect + github.com/prometheus/exporter-toolkit v0.15.1 // indirect github.com/prometheus/memcached_exporter v0.13.0 // indirect github.com/prometheus/mysqld_exporter v0.17.2 // indirect github.com/prometheus/node_exporter v1.9.1 // indirect @@ -1034,8 +1034,8 @@ replace github.com/thanos-io/objstore => github.com/grafana/objstore v0.0.0-2025 // TODO - remove forks when changes are merged upstream — non-singleton cadvisor replace github.com/google/cadvisor => github.com/grafana/cadvisor v0.0.0-20260204200106-865a22723970 -// TODO - track exporter-package-v0.18.1 branch of grafana fork; remove once merged upstream -replace github.com/prometheus-community/postgres_exporter => github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363 +// TODO - this tracks exporter-package-v0.19.0 branch of grafana fork; remove once all patches are merged upstream +replace github.com/prometheus-community/postgres_exporter => github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf // TODO - remove once PR is merged upstream - https://github.com/prometheus/mysqld_exporter/pull/774 replace github.com/prometheus/mysqld_exporter => github.com/grafana/mysqld_exporter v0.17.2-0.20250226152553-be612e3fdedd diff --git a/extension/alloyengine/go.sum b/extension/alloyengine/go.sum index d6b61c8e5f5..d1b01271474 100644 --- a/extension/alloyengine/go.sum +++ b/extension/alloyengine/go.sum @@ -1199,8 +1199,8 @@ github.com/grafana/opentelemetry-ebpf-profiler v0.0.202602-0.20260123050037-c33a github.com/grafana/opentelemetry-ebpf-profiler v0.0.202602-0.20260123050037-c33a6e86a2f5/go.mod h1:oqSk8XwYnL4saX2ZdpfnTJV9vURSNaVjK6yomOAVIPI= github.com/grafana/otel-profiling-go v0.5.1 h1:stVPKAFZSa7eGiqbYuG25VcqYksR6iWvF3YH66t4qL8= github.com/grafana/otel-profiling-go v0.5.1/go.mod h1:ftN/t5A/4gQI19/8MoWurBEtC6gFw8Dns1sJZ9W4Tls= -github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363 h1:/vCopugIegPx9brm+E9+4bMQ6uIsZujCoE7su3bLLbk= -github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363/go.mod h1:dOdKpz09HRMtkSs8kba90eNmrL81E+LMotcP7eW9/ek= +github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf h1:GaBnxd6zH0+QaZuMBWra2MdjKUWTI8edIQx1dXMLau8= +github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf/go.mod h1:4zH24t6LEqkdL3ZfBTtp0kGHOBr6komR55CrmL2AAg4= github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg= github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= github.com/grafana/pyroscope/api v1.2.0 h1:SfHDZcEZ4Vbj/Jj3bTOSpm4IDB33wLA2xBYxROhiL4U= @@ -2106,16 +2106,16 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.31.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.67.4 h1:yR3NqWO1/UyO1w2PhUvXlGQs/PtFmoveVO0KZ4+Lvsc= -github.com/prometheus/common v0.67.4/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI= +github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= +github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= github.com/prometheus/common/assets v0.2.0 h1:0P5OrzoHrYBOSM1OigWL3mY8ZvV2N4zIE/5AahrSrfM= github.com/prometheus/common/assets v0.2.0/go.mod h1:D17UVUE12bHbim7HzwUvtqm6gwBEaDQ0F+hIGbFbccI= github.com/prometheus/consul_exporter v0.8.0 h1:2z3drFic65WFoHaJRKkmnJRRlBLmmxVqT8L9LO2yxAo= github.com/prometheus/consul_exporter v0.8.0/go.mod h1:KHTgkT1/oLpXKC4+mKZV63hZSMHuKskUnHoenEave4Y= github.com/prometheus/exporter-toolkit v0.7.0/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g= github.com/prometheus/exporter-toolkit v0.7.1/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g= -github.com/prometheus/exporter-toolkit v0.15.0 h1:Pcle5sSViwR1x0gdPd0wtYrPQENBieQAM7TmT0qtb2U= -github.com/prometheus/exporter-toolkit v0.15.0/go.mod h1:OyRWd2iTo6Xge9Kedvv0IhCrJSBu36JCfJ2yVniRIYk= +github.com/prometheus/exporter-toolkit v0.15.1 h1:XrGGr/qWl8Gd+pqJqTkNLww9eG8vR/CoRk0FubOKfLE= +github.com/prometheus/exporter-toolkit v0.15.1/go.mod h1:P/NR9qFRGbCFgpklyhix9F6v6fFr/VQB/CVsrMDGKo4= github.com/prometheus/memcached_exporter v0.13.0 h1:d246RYODFCXy39XA8S2PBrqp5jLCSvl9b4KsYspDCHk= github.com/prometheus/memcached_exporter v0.13.0/go.mod h1:fp7Wk6v0RFijeP3Syvd1TShBSJoCG5iFfvPdi5dCMEU= github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos= diff --git a/go.mod b/go.mod index c85081acdb7..770b2ca27df 100644 --- a/go.mod +++ b/go.mod @@ -202,7 +202,7 @@ require ( github.com/prometheus/client_golang v1.23.2 github.com/prometheus/client_golang/exp v0.0.0-20250914183048-a974e0d45e0a github.com/prometheus/client_model v0.6.2 - github.com/prometheus/common v0.67.4 + github.com/prometheus/common v0.67.5 github.com/prometheus/consul_exporter v0.8.0 github.com/prometheus/memcached_exporter v0.13.0 github.com/prometheus/mysqld_exporter v0.17.2 @@ -838,7 +838,7 @@ require ( github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/prometheus-community/go-runit v0.1.0 // indirect github.com/prometheus-community/prom-label-proxy v0.12.1 // indirect - github.com/prometheus/exporter-toolkit v0.15.0 // indirect + github.com/prometheus/exporter-toolkit v0.15.1 // indirect github.com/prometheus/otlptranslator v1.0.0 // indirect github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect @@ -1077,8 +1077,8 @@ replace github.com/thanos-io/objstore => github.com/grafana/objstore v0.0.0-2025 // TODO - remove forks when changes are merged upstream — non-singleton cadvisor replace github.com/google/cadvisor => github.com/grafana/cadvisor v0.0.0-20260204200106-865a22723970 -// TODO - track exporter-package-v0.18.1 branch of grafana fork; remove once merged upstream -replace github.com/prometheus-community/postgres_exporter => github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363 +// TODO - this tracks exporter-package-v0.19.0 branch of grafana fork; remove once all patches are merged upstream +replace github.com/prometheus-community/postgres_exporter => github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf // TODO - remove once PR is merged upstream - https://github.com/prometheus/mysqld_exporter/pull/774 replace github.com/prometheus/mysqld_exporter => github.com/grafana/mysqld_exporter v0.17.2-0.20250226152553-be612e3fdedd diff --git a/go.sum b/go.sum index 4ecb83da2fb..3b418cf5066 100644 --- a/go.sum +++ b/go.sum @@ -1209,8 +1209,8 @@ github.com/grafana/opentelemetry-ebpf-profiler v0.0.202602-0.20260123050037-c33a github.com/grafana/opentelemetry-ebpf-profiler v0.0.202602-0.20260123050037-c33a6e86a2f5/go.mod h1:oqSk8XwYnL4saX2ZdpfnTJV9vURSNaVjK6yomOAVIPI= github.com/grafana/otel-profiling-go v0.5.1 h1:stVPKAFZSa7eGiqbYuG25VcqYksR6iWvF3YH66t4qL8= github.com/grafana/otel-profiling-go v0.5.1/go.mod h1:ftN/t5A/4gQI19/8MoWurBEtC6gFw8Dns1sJZ9W4Tls= -github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363 h1:/vCopugIegPx9brm+E9+4bMQ6uIsZujCoE7su3bLLbk= -github.com/grafana/postgres_exporter v0.0.0-20250930111128-c8f6a9f4d363/go.mod h1:dOdKpz09HRMtkSs8kba90eNmrL81E+LMotcP7eW9/ek= +github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf h1:GaBnxd6zH0+QaZuMBWra2MdjKUWTI8edIQx1dXMLau8= +github.com/grafana/postgres_exporter v0.0.0-20260212092411-d256e52d0faf/go.mod h1:4zH24t6LEqkdL3ZfBTtp0kGHOBr6komR55CrmL2AAg4= github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg= github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= github.com/grafana/pyroscope/api v1.2.0 h1:SfHDZcEZ4Vbj/Jj3bTOSpm4IDB33wLA2xBYxROhiL4U= @@ -2121,16 +2121,16 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.31.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.67.4 h1:yR3NqWO1/UyO1w2PhUvXlGQs/PtFmoveVO0KZ4+Lvsc= -github.com/prometheus/common v0.67.4/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI= +github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= +github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= github.com/prometheus/common/assets v0.2.0 h1:0P5OrzoHrYBOSM1OigWL3mY8ZvV2N4zIE/5AahrSrfM= github.com/prometheus/common/assets v0.2.0/go.mod h1:D17UVUE12bHbim7HzwUvtqm6gwBEaDQ0F+hIGbFbccI= github.com/prometheus/consul_exporter v0.8.0 h1:2z3drFic65WFoHaJRKkmnJRRlBLmmxVqT8L9LO2yxAo= github.com/prometheus/consul_exporter v0.8.0/go.mod h1:KHTgkT1/oLpXKC4+mKZV63hZSMHuKskUnHoenEave4Y= github.com/prometheus/exporter-toolkit v0.7.0/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g= github.com/prometheus/exporter-toolkit v0.7.1/go.mod h1:ZUBIj498ePooX9t/2xtDjeQYwvRpiPP2lh5u4iblj2g= -github.com/prometheus/exporter-toolkit v0.15.0 h1:Pcle5sSViwR1x0gdPd0wtYrPQENBieQAM7TmT0qtb2U= -github.com/prometheus/exporter-toolkit v0.15.0/go.mod h1:OyRWd2iTo6Xge9Kedvv0IhCrJSBu36JCfJ2yVniRIYk= +github.com/prometheus/exporter-toolkit v0.15.1 h1:XrGGr/qWl8Gd+pqJqTkNLww9eG8vR/CoRk0FubOKfLE= +github.com/prometheus/exporter-toolkit v0.15.1/go.mod h1:P/NR9qFRGbCFgpklyhix9F6v6fFr/VQB/CVsrMDGKo4= github.com/prometheus/memcached_exporter v0.13.0 h1:d246RYODFCXy39XA8S2PBrqp5jLCSvl9b4KsYspDCHk= github.com/prometheus/memcached_exporter v0.13.0/go.mod h1:fp7Wk6v0RFijeP3Syvd1TShBSJoCG5iFfvPdi5dCMEU= github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos= diff --git a/internal/component/prometheus/exporter/postgres/postgres.go b/internal/component/prometheus/exporter/postgres/postgres.go index 1a883bc7330..e6fc35d6146 100644 --- a/internal/component/prometheus/exporter/postgres/postgres.go +++ b/internal/component/prometheus/exporter/postgres/postgres.go @@ -78,8 +78,11 @@ type AutoDiscovery struct { // StatStatementFlags describe the flags to pass along the activation of the stat_statements collector type StatStatementFlags struct { - IncludeQuery bool `alloy:"include_query,attr,optional"` - QueryLength uint `alloy:"query_length,attr,optional"` + IncludeQuery bool `alloy:"include_query,attr,optional"` + QueryLength uint `alloy:"query_length,attr,optional"` + Limit uint `alloy:"limit,attr,optional"` + ExcludeDatabases []string `alloy:"exclude_databases,attr,optional"` + ExcludeUsers []string `alloy:"exclude_users,attr,optional"` } // SetToDefault implements syntax.Defaulter. @@ -107,8 +110,11 @@ func (s *StatStatementFlags) Convert() *postgres_exporter.StatStatementFlags { return nil } return &postgres_exporter.StatStatementFlags{ - IncludeQuery: s.IncludeQuery, - QueryLength: s.QueryLength, + IncludeQuery: s.IncludeQuery, + QueryLength: s.QueryLength, + Limit: s.Limit, + ExcludeDatabases: s.ExcludeDatabases, + ExcludeUsers: s.ExcludeUsers, } } diff --git a/internal/static/integrations/postgres_exporter/postgres_exporter.go b/internal/static/integrations/postgres_exporter/postgres_exporter.go index d80d264277c..03a6dd014f8 100644 --- a/internal/static/integrations/postgres_exporter/postgres_exporter.go +++ b/internal/static/integrations/postgres_exporter/postgres_exporter.go @@ -7,15 +7,14 @@ import ( "os" "strings" - "github.com/alecthomas/kingpin/v2" "github.com/go-kit/log" "github.com/grafana/alloy/internal/runtime/logging" "github.com/grafana/alloy/internal/static/integrations" integrations_v2 "github.com/grafana/alloy/internal/static/integrations/v2" "github.com/grafana/alloy/internal/static/integrations/v2/metricsutils" "github.com/lib/pq" - "github.com/prometheus-community/postgres_exporter/cmd/postgres_exporter" "github.com/prometheus-community/postgres_exporter/collector" + postgres_exporter "github.com/prometheus-community/postgres_exporter/exporter" config_util "github.com/prometheus/common/config" ) @@ -45,8 +44,11 @@ type Config struct { // Config for the stat_statement collector flags type StatStatementFlags struct { - IncludeQuery bool - QueryLength uint + IncludeQuery bool + QueryLength uint + Limit uint + ExcludeDatabases []string + ExcludeUsers []string } // Name returns the name of the integration this config is for. @@ -161,18 +163,17 @@ func New(log log.Logger, cfg *Config) (integrations.Integration, error) { if err != nil { return nil, err } - logger := slog.New(logging.NewSlogGoKitHandler(log)) e := postgres_exporter.NewExporter( dsns, + logger, postgres_exporter.DisableDefaultMetrics(cfg.DisableDefaultMetrics), postgres_exporter.WithUserQueriesPath(cfg.QueryPath), postgres_exporter.DisableSettingsMetrics(cfg.DisableSettingsMetrics), postgres_exporter.AutoDiscoverDatabases(cfg.AutodiscoverDatabases), postgres_exporter.ExcludeDatabases(cfg.ExcludeDatabases), postgres_exporter.IncludeDatabases(strings.Join(cfg.IncludeDatabases, ",")), - postgres_exporter.WithLogger(logger), postgres_exporter.WithMetricPrefix("pg"), ) @@ -181,32 +182,31 @@ func New(log log.Logger, cfg *Config) (integrations.Integration, error) { return integrations.NewCollectorIntegration(cfg.Name(), integrations.WithCollectors(e)), nil } - // This is a hack to force the command line flag values for the stat_statements collector. - // These flags are not exposed outside the package and cannot be mutated afterwards. - if cfg.StatStatementFlags != nil && cfg.StatStatementFlags.IncludeQuery { - includeQueryFlag := kingpin.CommandLine.GetFlag("collector.stat_statements.include_query") - queryLengthFlag := kingpin.CommandLine.GetFlag("collector.stat_statements.query_length") - - if includeQueryFlag == nil || queryLengthFlag == nil { - return nil, fmt.Errorf("failed to find collector.stat_statements.include_query or collector.stat_statements.query_length in postgres_exporter") - } - - err := includeQueryFlag.Model().Value.Set("true") - if err != nil { - return nil, fmt.Errorf("failed to set include query flag using Kingpin : %w", err) - } - - err = queryLengthFlag.Model().Value.Set(fmt.Sprintf("%d", cfg.StatStatementFlags.QueryLength)) - if err != nil { - return nil, fmt.Errorf("failed to set query length flag using Kingpin : %w", err) - } + // Build per-instance collector options. + collectorOpts := []collector.Option{ + collector.WithCollectionTimeout("10s"), + } + if cfg.StatStatementFlags != nil { + collectorOpts = append(collectorOpts, collector.WithStatStatementsConfig(collector.StatStatementsConfig{ + IncludeQuery: cfg.StatStatementFlags.IncludeQuery, + QueryLength: cfg.StatStatementFlags.QueryLength, + Limit: cfg.StatStatementFlags.Limit, + ExcludeDatabases: cfg.StatStatementFlags.ExcludeDatabases, + ExcludeUsers: cfg.StatStatementFlags.ExcludeUsers, + })) } // On top of the exporter's metrics, the postgres exporter also has metrics exposed via collector package. // However, these can only work for the first DSN provided. This matches the current implementation of the exporter. // TODO: Once https://github.com/prometheus-community/postgres_exporter/issues/999 is addressed, update the exporter // and change this. - c, err := collector.NewPostgresCollector(logger, cfg.ExcludeDatabases, dsns[0], cfg.EnabledCollectors) + c, err := collector.NewPostgresCollector( + logger, + cfg.ExcludeDatabases, + dsns[0], + cfg.EnabledCollectors, + collectorOpts..., + ) if err != nil { return nil, fmt.Errorf("failed to create postgres_exporter collector: %w", err) }