Recently, prometheus-operator has been promoted to stable helm chart (https://github.com/helm/charts/tree/master/stable/prometheus-operator).
I'd like to understand how to add a custom application to monitoring by prometheus-operator in a k8s cluster. An example for say gitlab runner which by default provides metrics on 9252 would be appreciated (https://docs.gitlab.com/runner/monitoring/#configuration-of-the-metrics-http-server).
I have a rudimentary yaml that obviously doesn't work but also not provides any feedback on what isn't working:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: gitlab-monitor
# Change this to the namespace the Prometheus instance is running in
namespace: default
labels:
app: gitlab-runner-gitlab-runner
release: prometheus
spec:
selector:
matchLabels:
app: gitlab-runner-gitlab-runner
namespaceSelector:
# matchNames:
# - default
any: true
endpoints:
- port: http-metrics
interval: 15s
This is the prometheus configuration:
> kubectl get prometheus -o yaml
...
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector:
matchLabels:
release: prometheus
...
So the selectors should match. By "not working" I mean that the endpoints do not appear in the prometheus UI.