Skip to content

Commit cdfe1f8

Browse files
committed
Monitoring for ironic-prometheus-exporter
This commit adds the changes that will allow Prometheus to collect data from the ironic-prometheus-exporter[1] that runs in the ironic-image [2]. - Added Service for the ironic-prometheus-exporter with same run level of the openshift-machine-api. - Added the ServiceMonitor for the ironic-prometheus-exporter - Added PrometheusRule with alerts for baremetal_temp_celsius metric. - Added the ironic-exporter container Note: Using the run level 90 to ServiceMonitor and PrometheusRule to ensure that the Service and the Prometheus Role and RoleBinding have been applied. [1] https://github.com/metal3-io/ironic-prometheus-exporter [2] https://github.com/metal3-io/ironic-image
1 parent c1885a9 commit cdfe1f8

4 files changed

Lines changed: 87 additions & 0 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{if .usingBareMetal}}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: Service
4+
metadata:
5+
name: metal3-baremetalhost-controller
6+
namespace: openshift-machine-api
7+
labels:
8+
app: ironic-exporter
9+
spec:
10+
ports:
11+
- name: http
12+
protocol: TCP
13+
port: 9608
14+
targetPort: 9608
15+
selector:
16+
app: ironic-exporter
17+
clusterIP: None
18+
type: ClusterIP
19+
sessionAffinity: None
20+
status:
21+
loadBalancer: {}
22+
{{- end}}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{if .usingBareMetal}}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
labels:
6+
app: ironic-exporter
7+
name: metal3-baremetalhost-controller
8+
namespace: openshift-machine-api
9+
spec:
10+
endpoints:
11+
- port: "9608-tcp"
12+
scheme: http
13+
path: /metrics
14+
targetPort: 9608
15+
jobLabel: app
16+
namespaceSelector:
17+
matchNames:
18+
- metal3-baremetalhost-controller
19+
selector:
20+
matchLabels:
21+
app: ironic-exporter
22+
{{- end}}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{{if .usingBareMetal}}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: PrometheusRule
4+
metadata:
5+
name: metal3-baremetalhost-controller
6+
namespace: openshift-machine-api
7+
spec:
8+
groups:
9+
- name: metal3-baremetalhost-controller
10+
rules:
11+
- alert: HighCPUTemperature
12+
annotations:
13+
summary: "The baremetal node {{ $labels.node_name }} CPU {{ $labels.entity_id }} is too high"
14+
description: "The baremetal node {{ $labels.node_name }} CPU {{ $labels.entity_id }} was too high in the past 5 minutes. Last measurement {{ $value }}"
15+
expr: baremetal_temp_celsius > 96
16+
for: 5m
17+
labels:
18+
severity: warning
19+
- alert: LowCPUTemperature
20+
annotations:
21+
summary: "The baremetal node {{ $labels.node_name }} CPU {{ $labels.entity_id }} is too low"
22+
description: "The baremetal node {{ $labels.node_name }} CPU {{ $labels.entity_id }} was too low in the past 5 minutes. Last measurement {{ $value }}"
23+
expr: baremetal_temp_celsius < 3
24+
for: 5m
25+
labels:
26+
severity: warning
27+
{{- end}}

pkg/operator/baremetal_pod.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ func newMetal3Containers(config *OperatorConfig, baremetalProvisioningConfig Bar
290290
containers = append(containers, createContainerMetal3IronicApi(config, baremetalProvisioningConfig))
291291
containers = append(containers, createContainerMetal3IronicInspector(config, baremetalProvisioningConfig))
292292
containers = append(containers, createContainerMetal3StaticIpManager(config, baremetalProvisioningConfig))
293+
containers = append(containers, createContainerMetal3IronicExporter(config))
293294
return containers
294295
}
295296

@@ -424,3 +425,18 @@ func createContainerMetal3StaticIpManager(config *OperatorConfig, baremetalProvi
424425
}
425426
return container
426427
}
428+
429+
func createContainerMetal3IronicExporter(config *OperatorConfig) corev1.Container {
430+
431+
container := corev1.Container{
432+
Name: "metal3-ironic-exporter",
433+
Image: config.BaremetalControllers.Ironic,
434+
ImagePullPolicy: "Always",
435+
SecurityContext: &corev1.SecurityContext{
436+
Privileged: pointer.BoolPtr(true),
437+
},
438+
Command: []string{"/bin/runironic-exporter"},
439+
VolumeMounts: volumeMounts,
440+
}
441+
return container
442+
}

0 commit comments

Comments
 (0)