diff --git a/jsonnet/kube-prometheus/kube-prometheus.libsonnet b/jsonnet/kube-prometheus/kube-prometheus.libsonnet index f59cc80f75cd1d8a13f33636b82a956ac90e283b..b751ce71bfcad3efc2abc40e4525e8d1996fe4bd 100644 --- a/jsonnet/kube-prometheus/kube-prometheus.libsonnet +++ b/jsonnet/kube-prometheus/kube-prometheus.libsonnet @@ -15,7 +15,32 @@ local configMapList = k.core.v1.configMapList; namespace: k.core.v1.namespace.new($._config.namespace), }, grafana+:: { + local serviceLabels = { + app: 'grafana', + }, dashboardDefinitions: configMapList.new(super.dashboardDefinitions), + service+: { + labels+: serviceLabels, + }, + serviceMonitor: { + apiVersion: 'monitoring.coreos.com/v1', + kind: 'ServiceMonitor', + metadata: { + name: 'grafana', + namespace: $._config.namespace, + }, + spec: { + selector: { + matchLabels: serviceLabels, + }, + endpoints: [ + { + port: 'http', + interval: '15s', + }, + ], + }, + }, }, } + { _config+:: { diff --git a/manifests/grafana-service.yaml b/manifests/grafana-service.yaml index 45f77a0dca1d20f1051fc4c19053b7afc9fb5b19..09ec1f97a8917cb65d89510ad950acafd667eda7 100644 --- a/manifests/grafana-service.yaml +++ b/manifests/grafana-service.yaml @@ -1,5 +1,7 @@ apiVersion: v1 kind: Service +labels: + app: grafana metadata: name: grafana namespace: monitoring diff --git a/manifests/grafana-serviceMonitor.yaml b/manifests/grafana-serviceMonitor.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7ede266a5cfcf38e76818aa5571e009870a01e96 --- /dev/null +++ b/manifests/grafana-serviceMonitor.yaml @@ -0,0 +1,12 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: grafana + namespace: monitoring +spec: + endpoints: + - interval: 15s + port: http + selector: + matchLabels: + app: grafana