Check for host labels when linking alerts for children (#13053)
check for host labels when linking alerts
Emmanuel Vasilakis committed
Jun 2, 2022 at 13:36 UTC
658f8f9073acecf57d330d4b3a875a70e66c3cc5
1 file changed
+25
database/rrdcalc.c
+25
@@ -116,6 +116,31 @@ static inline int rrdcalc_test_additional_restriction(RRDCALC *rc, RRDSET *st){
116
if (rc->plugin_match && !simple_pattern_matches(rc->plugin_pattern, st->plugin_name))
117
return 0;
118
119
+ if (rc->labels) {
120
+ int labels_count=1;
121
+ int labels_match=0;
122
+ char *s = rc->labels;
123
+ while (*s) {
124
+ if (*s==' ')
125
+ labels_count++;
126
+ s++;
127
+ }
128
+ RRDHOST *host = st->rrdhost;
129
+ char cmp[CONFIG_FILE_LINE_MAX+1];
130
+ struct label *move = host->labels.head;
131
+ while(move) {
132
+ snprintf(cmp, CONFIG_FILE_LINE_MAX, "%s=%s", move->key, move->value);
133
+ if (simple_pattern_matches(rc->splabels, move->key) ||
134
+ simple_pattern_matches(rc->splabels, cmp)) {
135
+ labels_match++;
136
+ }
137
+ move = move->next;
138
+ }
139
+
140
+ if (labels_match != labels_count)
141
+ return 0;
142
+ }
143
+
144
return 1;
145
}
146