Team,
I have created an alert and it is working but I need to use it for two values. any hint how can i use the OR operator in between message? when i remove the condition then it works as expected.
working expression
message: 'Node {{ `{{ $labels.nodename }}` }} was rebooted'
not working expression
message: 'Node {{- if or `{{ $labels.nodename }}` `{{ $labels.node }}` }} was rebooted {{- end }}'
- alert: NodeReboot
annotations:
message: 'Node {{- if or `{{ $labels.nodename }}` `{{ $labels.node }}` }} was rebooted {{- end }}'
runbook_url: TODO
expr: (time() - node_boot_time_seconds)/60 < 15
for: {{ .Values.genericAlerts.alertDefinitions.NodeReboot.for }}
{{- if .Values.genericAlerts.alertDefinitions.NodeReboot.labels }}
labels:
{{ toYaml .Values.genericAlerts.alertDefinitions.NodeReboot.labels | indent 8 }}
{{- end }}
{{- end }}
{{- if .Values.genericAlerts.alertDefinitions.GpuNodeMissingPowerLabel.enabled }}
output:
- alert: NodeReboot
annotations:
message: 'Node was rebooted'
expected
- alert: NodeReboot
annotations:
message: 'Node test-node1 was rebooted'
If you want to print only one of them, use the following condition.
If you don't want to print
was rebooted
if none of them is set, then add the following IF condition.