Skip to content

Commit 3c0c1a5

Browse files
craig5mrueg
authored andcommitted
add interval to prometheus service monitor
We have a use-case where we need to modify the default scrape interval on a number of apps, including coredns. This PR simply adds support to change it. (It should be backwards compatible with existing implmentations.) Test/verification: ``` $ helm template charts/coredns --set prometheus.monitor.enabled=true --set prometheus.monitor.interval=60s |grep servicemonitor.yaml -A 22 apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: RELEASE-NAME-coredns labels: app.kubernetes.io/managed-by: "Helm" app.kubernetes.io/instance: "RELEASE-NAME" helm.sh/chart: "coredns-1.16.5" k8s-app: "coredns" kubernetes.io/cluster-service: "true" kubernetes.io/name: "CoreDNS" app.kubernetes.io/name: coredns spec: selector: matchLabels: app.kubernetes.io/instance: "RELEASE-NAME" k8s-app: "coredns" app.kubernetes.io/name: coredns app.kubernetes.io/component: metrics endpoints: - port: metrics interval: 60s ``` Signed-off-by: Craig Sebenik <[email protected]>
1 parent 939b013 commit 3c0c1a5

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

charts/coredns/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ The command removes all the Kubernetes components associated with the chart and
6363
| `prometheus.monitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false` |
6464
| `prometheus.monitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | {} |
6565
| `prometheus.monitor.namespace` | Selector to select which namespaces the Endpoints objects are discovered from. | `""` |
66+
| `prometheus.monitor.interval` | Scrape interval for polling the metrics endpoint. (E.g. "30s") | `""` |
6667
| `service.clusterIP` | IP address to assign to service | `""` |
6768
| `service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""` |
6869
| `service.externalIPs` | External IP addresses | [] |

charts/coredns/templates/servicemonitor.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ spec:
3030
app.kubernetes.io/component: metrics
3131
endpoints:
3232
- port: metrics
33+
{{- if .Values.prometheus.monitor.interval }}
34+
interval: {{ .Values.prometheus.monitor.interval }}
35+
{{- end }}
3336
{{- end }}

charts/coredns/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ prometheus:
6363
enabled: false
6464
additionalLabels: {}
6565
namespace: ""
66+
interval: ""
6667

6768
service:
6869
# clusterIP: ""

0 commit comments

Comments
 (0)