diff --git a/postgres-exporter/main.libsonnet b/postgres-exporter/main.libsonnet index 115cffc35..938f4f215 100644 --- a/postgres-exporter/main.libsonnet +++ b/postgres-exporter/main.libsonnet @@ -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, @@ -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'), + ]), + }, }