Skip to content

Commit ecefe68

Browse files
committed
Let the prometheus-ha watcher watch the correct directory
This also introduces a `prometheus_config_dir` variable to avoid hardcoding of `/etc/prometheus` at multiple places.
1 parent 88a04ac commit ecefe68

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

prometheus-ksonnet/lib/config.libsonnet

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
prometheus_path: '/prometheus/',
3939
prometheus_port: 9090,
4040
prometheus_web_route_prefix: self.prometheus_path,
41-
prometheus_config_file: '/etc/prometheus/prometheus.yml',
41+
prometheus_config_dir: '/etc/prometheus',
42+
prometheus_config_file: self.prometheus_config_dir + '/prometheus.yml',
4243

4344
// Alertmanager config options.
4445
alertmanager_external_hostname: 'http://alertmanager.%(namespace)s.svc.%(cluster_dns_suffix)s' % self,

prometheus-ksonnet/lib/prometheus-ha-mixin.libsonnet

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local configMap = k.core.v1.configMap;
77
local root = self,
88

99
_config+:: {
10-
prometheus_config_file: '/etc/$(POD_NAME)/prometheus.yml',
10+
prometheus_config_dir: '/etc/$(POD_NAME)',
1111
},
1212

1313
// The '__replica__' label is used by Cortex for deduplication.
@@ -58,6 +58,10 @@ local configMap = k.core.v1.configMap;
5858
container.envType.fromFieldPath('POD_NAME', 'metadata.name'),
5959
]),
6060

61+
prometheus_watch_container+:: container.withEnv([
62+
container.envType.fromFieldPath('POD_NAME', 'metadata.name'),
63+
]),
64+
6165
prometheus_statefulset+:
6266
k.util.configVolumeMount('%s-config-0' % self.name, '/etc/prometheus-0') +
6367
k.util.configVolumeMount('%s-config-1' % self.name, '/etc/prometheus-1') +

prometheus-ksonnet/lib/prometheus.libsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
container.withArgs([
5353
'-v',
5454
'-t',
55-
'-p=/etc/prometheus',
55+
'-p=' + _config.prometheus_config_dir,
5656
'curl',
5757
'-X',
5858
'POST',
@@ -75,7 +75,7 @@
7575
local volumeMount = $.core.v1.volumeMount,
7676

7777
prometheus_config_mount::
78-
$.util.configVolumeMount('%s-config' % self.name, '/etc/prometheus'),
78+
$.util.configVolumeMount('%s-config' % self.name, _config.prometheus_config_dir),
7979

8080
prometheus_statefulset:
8181
statefulset.new(self.name, 1, [

0 commit comments

Comments
 (0)