Skip to content

Commit a180a14

Browse files
authored
[prometheus-ipmi-exporter] Add ScrapeConfig (#6266)
Signed-off-by: Anes Belfodil <[email protected]>
1 parent e632856 commit a180a14

File tree

4 files changed

+144
-1
lines changed

4 files changed

+144
-1
lines changed

charts/prometheus-ipmi-exporter/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: prometheus-ipmi-exporter
33
description: This is an IPMI exporter for Prometheus.
44
type: application
5-
version: 0.6.3
5+
version: 0.7.0
66
# renovate: github=prometheus-community/ipmi_exporter
77
appVersion: "v1.10.1"
88
keywords:

charts/prometheus-ipmi-exporter/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,36 @@ See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_h
5252
```console
5353
helm show values oci://ghcr.io/prometheus-community/charts/prometheus-ipmi-exporter
5454
```
55+
56+
### ScrapeConfig vs ServiceMonitor
57+
58+
This chart supports both ServiceMonitor (v1) and ScrapeConfig (v1alpha1) from prometheus-operator.
59+
60+
**ScrapeConfig** is recommended for:
61+
62+
- Scraping IPMI targets in remote mode (exporter as a proxy)
63+
- Using file-based service discovery
64+
- More flexibility with relabeling
65+
66+
**Example - Remote IPMI scraping:**
67+
68+
```yaml
69+
scrapeConfig:
70+
enabled: true
71+
mode: remote # Uses /ipmi endpoint with target relabeling
72+
staticConfigs:
73+
- targets:
74+
- 192.168.1.10
75+
- 192.168.1.11
76+
```
77+
78+
**Example - Local exporter metrics:**
79+
80+
```yaml
81+
scrapeConfig:
82+
enabled: true
83+
mode: local # Uses /metrics endpoint directly
84+
staticConfigs:
85+
- targets:
86+
- ipmi-exporter:9290
87+
```
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{{- if .Values.scrapeConfig }}
2+
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1alpha1" ) ( .Values.scrapeConfig.enabled ) }}
3+
{{- $hasStatic := .Values.scrapeConfig.staticConfigs }}
4+
{{- $hasFile := .Values.scrapeConfig.fileSDConfigs }}
5+
{{- $isRemote := eq .Values.scrapeConfig.mode "remote" }}
6+
{{- if not (or $hasStatic $hasFile) }}
7+
{{- fail "scrapeConfig requires either staticConfigs or fileSDConfigs to be defined" }}
8+
{{- end }}
9+
{{- if and $hasStatic $hasFile }}
10+
{{- fail "scrapeConfig cannot have both staticConfigs and fileSDConfigs defined" }}
11+
{{- end }}
12+
apiVersion: monitoring.coreos.com/v1alpha1
13+
kind: ScrapeConfig
14+
metadata:
15+
{{- if .Values.scrapeConfig.labels }}
16+
labels:
17+
{{- toYaml .Values.scrapeConfig.labels | nindent 4 }}
18+
{{- end }}
19+
name: {{ template "prometheus-ipmi-exporter.fullname" . }}
20+
{{- if .Values.scrapeConfig.namespace }}
21+
namespace: {{ .Values.scrapeConfig.namespace }}
22+
{{- end }}
23+
spec:
24+
jobName: {{ .Values.scrapeConfig.jobName | default "ipmi-exporter" }}
25+
{{- if .Values.scrapeConfig.modules }}
26+
params:
27+
module:
28+
{{- toYaml .Values.scrapeConfig.modules | nindent 6 }}
29+
{{- else if $isRemote }}
30+
params:
31+
module:
32+
- default
33+
{{- end }}
34+
scrapeInterval: {{ .Values.scrapeConfig.scrapeInterval | default "1m" }}
35+
scrapeTimeout: {{ .Values.scrapeConfig.scrapeTimeout | default "30s" }}
36+
{{- if .Values.scrapeConfig.metricsPath }}
37+
metricsPath: {{ .Values.scrapeConfig.metricsPath }}
38+
{{- else if $isRemote }}
39+
metricsPath: /ipmi
40+
{{- else }}
41+
metricsPath: /metrics
42+
{{- end }}
43+
scheme: {{ .Values.scrapeConfig.scheme | default "HTTP" }}
44+
{{- if .Values.scrapeConfig.fileSDConfigs }}
45+
fileSDConfigs:
46+
{{- toYaml .Values.scrapeConfig.fileSDConfigs | nindent 4 }}
47+
{{- end }}
48+
{{- if .Values.scrapeConfig.staticConfigs }}
49+
staticConfigs:
50+
{{- toYaml .Values.scrapeConfig.staticConfigs | nindent 4 }}
51+
{{- end }}
52+
{{- if .Values.scrapeConfig.relabelings }}
53+
relabelings:
54+
{{- toYaml .Values.scrapeConfig.relabelings | nindent 4 }}
55+
{{- else if $isRemote }}
56+
relabelings:
57+
- sourceLabels: [__address__]
58+
targetLabel: __param_target
59+
action: replace
60+
- sourceLabels: [__param_target]
61+
targetLabel: instance
62+
action: replace
63+
- targetLabel: __address__
64+
replacement: {{ include "prometheus-ipmi-exporter.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}
65+
action: replace
66+
{{- end }}
67+
{{- if .Values.scrapeConfig.metricRelabelings }}
68+
metricRelabelings:
69+
{{- toYaml .Values.scrapeConfig.metricRelabelings | nindent 4 }}
70+
{{- end }}
71+
{{- end }}
72+
{{- end }}

charts/prometheus-ipmi-exporter/values.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,44 @@ serviceMonitor:
6161
# targetLabels: []
6262
# metricRelabelings: []
6363

64+
scrapeConfig:
65+
# When set true then use a ScrapeConfig to configure scraping
66+
enabled: false
67+
# Set the namespace the ScrapeConfig should be deployed
68+
# namespace: monitoring
69+
# Set labels for the ScrapeConfig
70+
# labels:
71+
# Scraping mode: "local" for direct exporter metrics, "remote" for IPMI target scraping
72+
mode: remote
73+
# Job name for the scrape config
74+
# jobName: ipmi-exporter
75+
# Modules list
76+
# modules:
77+
# - default
78+
# - dcmi
79+
# Set how frequently Prometheus should scrape
80+
# scrapeInterval: 1m
81+
# Set timeout for scrape
82+
# scrapeTimeout: 30s
83+
# Metrics path (defaults: /metrics for local mode, /ipmi for remote mode)
84+
# metricsPath: /ipmi
85+
# Scheme (HTTP or HTTPS)
86+
# scheme: HTTP
87+
# File service discovery configs
88+
# fileSDConfigs:
89+
# - files:
90+
# - /etc/prometheus/secrets/ipmi-exporter/targets.yml
91+
# refreshInterval: 5m
92+
# Static configs
93+
# staticConfigs:
94+
# - targets:
95+
# - 192.168.1.10
96+
# - 192.168.1.11
97+
# Relabelings
98+
# relabelings: []
99+
# Metric relabelings
100+
# metricRelabelings: []
101+
64102
# Configuration file for ipmi_exporter
65103

66104
configSecret:

0 commit comments

Comments
 (0)