Don't print errors from reading filtered alerts (#16417)
Emmanuel Vasilakis committed
Nov 15, 2023 at 14:36 UTC
db86eb91b78fe584752afe44e2a362539b4d5ee2
1 file changed
+7
-2
health/health_config.c
+7
-2
@@ -583,6 +583,7 @@ static int health_readfile(const char *filename, void *data) {
583
struct alert_config *alert_cfg = NULL;
584
585
int ignore_this = 0;
586
+ bool filtered_config = false;
587
size_t line = 0, append = 0;
588
char *s;
589
while((s = fgets(&buffer[append], (int)(HEALTH_CONF_MAX_LINE - append), fp)) || append) {
@@ -680,8 +681,10 @@ static int health_readfile(const char *filename, void *data) {
681
alert_cfg->alarm = string_dup(rc->name);
682
alert_cfg->source = health_source_file(line, filename);
683
ignore_this = 0;
684
+ filtered_config = false;
685
} else {
686
rc = NULL;
687
+ filtered_config = true;
688
}
689
}
690
else if(hash == hash_template && !strcasecmp(key, HEALTH_TEMPLATE_KEY)) {
@@ -727,8 +730,10 @@ static int health_readfile(const char *filename, void *data) {
730
alert_cfg->template_key = string_dup(rt->name);
731
alert_cfg->source = health_source_file(line, filename);
732
ignore_this = 0;
733
+ filtered_config = false;
734
} else {
735
rt = NULL;
736
+ filtered_config = true;
737
}
738
}
739
else if(hash == hash_os && !strcasecmp(key, HEALTH_OS_KEY)) {
@@ -1320,8 +1325,8 @@ static int health_readfile(const char *filename, void *data) {
1325
}
1326
}
1327
else {
1323
- netdata_log_error("Health configuration at line %zu of file '%s' has unknown key '%s'. Expected either '" HEALTH_ALARM_KEY "' or '" HEALTH_TEMPLATE_KEY "'.",
1324
- line, filename, key);
1328
+ if (!filtered_config)
1329
+ netdata_log_error("Health configuration at line %zu of file '%s' has unknown key '%s'. Expected either '" HEALTH_ALARM_KEY "' or '" HEALTH_TEMPLATE_KEY "'.", line, filename, key);
1330
}
1331
}
1332