Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to set ServiceMonitor namespace #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ their default values.
| `metrics.port` | TCP port on which the service metrics is exposed | `5001` |
| `metrics.serviceMonitor.annotations` | Prometheus Operator ServiceMonitor annotations | `{}` |
| `metrics.serviceMonitor.enable` | If true, Prometheus Operator ServiceMonitor will be created | `false` |
| `metrics.serviceMonitor.namespace` | Namespace where ServiceMonitor should be installed (defaults to current one) | `""` |
| `metrics.serviceMonitor.labels` | Prometheus Operator ServiceMonitor labels | `{}` |
| `metrics.prometheusRule.annotations` | Prometheus Operator PrometheusRule annotations | `{}` |
| `metrics.prometheusRule.enable` | If true, Prometheus Operator prometheusRule will be created | `false` |
Expand Down
4 changes: 4 additions & 0 deletions templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "docker-registry.fullname" . }}-servicemonitor
namespace: {{ default .Release.Namespace .Values.metrics.serviceMonitor.namespace }}
labels:
app: {{ template "docker-registry.name" . }}-metrics
release: {{ .Release.Name }}
{{- if .Values.metrics.serviceMonitor.labels }}
{{ toYaml .Values.metrics.serviceMonitor.labels | indent 4 }}
{{- end }}
spec:
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "docker-registry.name" . }}
Expand Down
3 changes: 3 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ metrics:
# Create a prometheus-operator servicemonitor
serviceMonitor:
enabled: false
# Namespace where ServiceMonitor should be installed (i.e. `monitoring`)
# Defaults to namespace where the chart is installed.
namespace: ""
labels: {}
# prometheus-operator PrometheusRule defining alerting rules for a Prometheus instance
prometheusRule:
Expand Down