Skip to content

Commit

Permalink
Add withQueriesYaml() method to postgres-exporter (#1188)
Browse files Browse the repository at this point in the history
* Add withQueriesYaml() method to postgres-exporter

We need this file in order to use PG_EXPORTER_EXTEND_QUERY_PATH.

* Add postgres-exporter version disclaimer
  • Loading branch information
rafa-munoz authored Apr 10, 2024
1 parent b5e3f0e commit c2eec98
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions postgres-exporter/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ local k = import 'ksonnet-util/kausal.libsonnet';
data_source_uri='$(HOSTNAME):$(PORT)/postgres',
data_source_name='',
ssl=true,
// Note that upgrading to an image version greater than 0.12.1
// will break dependencies using `withQueriesYaml`.
image='quay.io/prometheuscommunity/postgres-exporter:v0.10.0',
):: {
local this = self,
Expand Down Expand Up @@ -79,4 +81,22 @@ local k = import 'ksonnet-util/kausal.libsonnet';
),
]),
},

// Upgrading to an image version greater than 0.12.1
// will break this function.
withQueriesYaml(content):: {
container+:
k.core.v1.container.withVolumeMounts([
k.core.v1.volumeMount.new(
'queries-yaml',
'/etc/pg_exporter/queries.yaml',
),
])
+ k.core.v1.configMap.new('queries-yaml', {
'queries.yaml': content,
})
+ k.core.v1.container.withEnvMixin([
envVar.new('PG_EXPORTER_EXTEND_QUERY_PATH', '/etc/pg_exporter/queries.yaml'),
]),
},
}

0 comments on commit c2eec98

Please sign in to comment.