ServiceMonitor Helper
Configure standalone Prometheus ServiceMonitors using the ohMyHelm monitoring helper, including supported schema fields and template limitations.
ServiceMonitor Helper
With the root helper monitoring, you can create standalone monitoring.coreos.com/v1/ServiceMonitor resources for the Prometheus Operator (for example, kube-prometheus-stack or VictoriaMetrics Operator with Prometheus CRD compatibility).
Supported Schema Fields
According to values.schema.json, only the following fields are permitted under monitoring[] and monitoring[].endpoints[] (additionalProperties: false):
| Field | Required | Description |
|---|---|---|
name |
Yes | Name of the ServiceMonitor (metadata.name), spec.jobLabel, and value of the app.kubernetes.io/name selector |
namespace |
Recommended | Target namespace of the ServiceMonitor (for example, monitoring) |
release |
Yes | Value for metadata.labels.release (must match the serviceMonitorSelector of your Prometheus instance) |
endpoints[].port |
Yes | Named port on the target Service (string, for example, metrics or http) |
endpoints[].interval |
Yes | Scrape interval (for example, 15s or 30s) |
endpoints[].path |
Optional | Metrics path (Prometheus default: /metrics) |
endpoints[].scheme |
Optional | Omit in the current release! (See warning below) |
Key Differences and Known Limitations (Release 1.18.0)
Basic Configuration
monitoring:
- name: acme-api
namespace: monitoring
release: prometheus
endpoints:
- port: metrics
interval: 30s
path: /metrics
Resulting Kubernetes manifest:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: acme-api
labels:
release: prometheus
namespace: "monitoring"
spec:
jobLabel: acme-api
selector:
matchExpressions:
- {
key: app.kubernetes.io/name,
operator: In,
values: [acme-api],
}
namespaceSelector:
any: true
endpoints:
- port: metrics
interval: 30s
path: /metrics
Multiple Endpoints and Multiple Services
monitoring:
- name: acme-api
namespace: monitoring
release: kube-prometheus-stack
endpoints:
- port: metrics
interval: 15s
path: /metrics
- port: admin-metrics
interval: 60s
path: /internal/metrics
- name: acme-worker
namespace: monitoring
release: kube-prometheus-stack
endpoints:
- port: metrics
interval: 30s
path: /metrics
Target Service Requirements
For Prometheus to discover the target Service, two conditions must be met:
- The
Servicecarries the labelapp.kubernetes.io/name: <name>(matchingmonitoring[].nameexactly). - The
Servicedefines a named port underspec.ports[]withname: <endpoints[].port>(for example,name: metrics).