Skip to content

Commit

Permalink
add service monitor for consul exporter (prometheus-community#439)
Browse files Browse the repository at this point in the history
Signed-off-by: junnplus <[email protected]>
  • Loading branch information
junnplus authored Dec 2, 2020
1 parent 004e4c9 commit fdabb4c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/prometheus-consul-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "0.4.0"
description: A Helm chart for the Prometheus Consul Exporter
name: prometheus-consul-exporter
version: 0.3.0
version: 0.4.0
keywords:
- metrics
- consul
Expand Down
45 changes: 45 additions & 0 deletions charts/prometheus-consul-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- if $.Values.serviceMonitor }}
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
{{- if .Values.serviceMonitor.labels }}
labels:
{{ toYaml .Values.serviceMonitor.labels | indent 4}}
{{- end }}
name: {{ template "prometheus-consul-exporter.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
spec:
endpoints:
- targetPort: {{ .Values.service.port }}
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.telemetryPath }}
path: {{ .Values.serviceMonitor.telemetryPath }}
{{- end }}
{{- if .Values.serviceMonitor.timeout }}
scrapeTimeout: {{ .Values.serviceMonitor.timeout }}
{{- end }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{ toYaml .Values.serviceMonitor.metricRelabelings | indent 4 }}
{{- end }}
jobLabel: {{ template "prometheus-consul-exporter.fullname" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "prometheus-consul-exporter.name" . }}
release: {{ .Release.Name }}
{{- if .Values.serviceMonitor.targetLabels }}
targetLabels:
{{- range .Values.serviceMonitor.targetLabels }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/prometheus-consul-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ resources: {}
# cpu: 100m
# memory: 128Mi

serviceMonitor:
# When set true then use a ServiceMonitor to configure scraping
enabled: false
# Set the namespace the ServiceMonitor should be deployed
# namespace: monitoring
# Set how frequently Prometheus should scrape
# interval: 30s
# Set path to consul-exporter telemtery-path
# telemetryPath: /metrics
# Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator
# labels:
# Set timeout for scrape
# timeout: 10s
# Set of labels to transfer on the Kubernetes Service onto the target.
# targetLabels: []
# metricRelabelings: []

nodeSelector: {}

tolerations: []
Expand Down

0 comments on commit fdabb4c

Please sign in to comment.