团队,
我创建了一个警报,并且该警报正在运行,但是我需要将其用于两个值。任何提示我如何在消息之间使用OR运算符?当我删除条件后,它就会按预期工作。
工作表达
message: 'Node {{ `{{ $labels.nodename }}` }} was rebooted'
无效的表达式
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 }}
输出:
- alert: NodeReboot
annotations:
message: 'Node was rebooted'
预期
- alert: NodeReboot
annotations:
message: 'Node test-node1 was rebooted'
答案 0 :(得分:0)
如果只打印其中之一,请使用以下条件。
#include <stdio.h>
#include <stdlib.h>
#define STACKSIZE 1000
struct stack
{
int top;
char items[STACKSIZE];
};
void push(struct stack *pb, char x)
{
if(pb->top==STACKSIZE)
printf("The stack is full\n");
else
pb->items[pb->top++]=x;
}
int main()
{
while(1)
{
struct stack balance; //the stack called "balance"
struct stack *b; //the pointer of stack
char line[STACKSIZE]; //input
scanf("%s", line);
if(!strcmp(line, "-1")) //program stops when only "-1"
break;
b->top=0; //initializing top value
for(int i=0;i<STACKSIZE-1;i++)
{
if(line[i]=='(' || line[i]==')') //push '(' and ')' in the input to the stack
push(b, line[i]);
}
printf("test"); //can't reach this line
printf("%s\n", b->items);
}
return 0;
}
如果您都不想设置message: 'Node {{ if $labels.nodename }}{{ $labels.nodename }}{{ else if $labels.node }}{{ $labels.node }}{{ end }} was rebooted'
,而又不想打印,请添加以下IF条件。
was rebooted