Skip to content

Commit

Permalink
[prometheus-snmp-exporter] Fixes prometheus-community#398 and adds so…
Browse files Browse the repository at this point in the history
…me features (prometheus-community#399)

* Fixes prometheus-community#398 and adds some features

- Fixes ServiceMonitor to crawl the correct pods
- Fixes ServiceMonitor to properly work when multiple instances
  of the chart are installed
- Allows specifying relabelings and metricRelabelings configuration
  in ServiceMonitor

Signed-off-by: Andrian Jardan <[email protected]>

* Bumping version to 0.1.0

Signed-off-by: Andrian Jardan <[email protected]>

* Making lint happy with 0.1.1

Signed-off-by: Andrian Jardan <[email protected]>
  • Loading branch information
ni-ajardan authored Nov 26, 2020
1 parent d89c09f commit 9ac09de
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-snmp-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: Prometheus SNMP Exporter
name: prometheus-snmp-exporter
version: 0.1.0
version: 0.1.1
appVersion: 0.19.0
home: https://github.com/prometheus/snmp_exporter
sources:
Expand Down
16 changes: 16 additions & 0 deletions charts/prometheus-snmp-exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,19 @@ scrape_configs:
- target_label: __address__
replacement: my-service-name:9116 # The SNMP exporter's Service name and port.
```
Eaxample configuration via a ServiceMonitor
```yaml
serviceMonitor:
enabled: true
relabelings:
- sourceLabels: [__param_target]
targetLabel: instance
params:
enabled: true
conf:
module:
- fortigate_snmp
target:
- 192.168.1.2 # SNMP device
```
14 changes: 12 additions & 2 deletions charts/prometheus-snmp-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "prometheus-snmp-exporter.name" . }}
name: {{ template "prometheus-snmp-exporter.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
Expand All @@ -18,14 +18,24 @@ spec:
{{- end }}
honorLabels: {{ .Values.serviceMonitor.honorLabels }}
path: {{ .Values.serviceMonitor.path }}
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- if .Values.serviceMonitor.params.enabled }}
params:
{{ toYaml .Values.serviceMonitor.params.conf | indent 6 }}
{{- end }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings: {{ toYaml .Values.serviceMonitor.metricRelabelings | nindent 8 }}
{{- end }}
{{- if .Values.serviceMonitor.relabelings }}
relabelings: {{ toYaml .Values.serviceMonitor.relabelings | nindent 8 }}
{{- end }}
selector:
matchLabels:
app: {{ template "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/name: {{ template "prometheus-snmp-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

0 comments on commit 9ac09de

Please sign in to comment.