summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2024-04-13 04:51:03 +0300
committerGitHub <noreply@github.com>2024-04-13 02:51:03 +0100
commit80d2dd74d0a3b03342d7768f1478a29c1ff78ca7 (patch)
tree5b7e1b90a5769b7f361b9ea29b8331a82dea7250
parentc5ea422c6f0aa43d3d93705867bde1df31f47b89 (diff)
apply first alarms, then alarm templates (#17398)
apply first alarms, then templates
-rw-r--r--src/health/health_prototypes.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/health/health_prototypes.c b/src/health/health_prototypes.c
index ceefbc2225..87ef27fba1 100644
--- a/src/health/health_prototypes.c
+++ b/src/health/health_prototypes.c
@@ -575,18 +575,27 @@ static void health_prototype_apply_to_rrdset(RRDSET *st, RRD_ALERT_PROTOTYPE *ap
return;
spinlock_lock(&ap->_internal.spinlock);
- for(RRD_ALERT_PROTOTYPE *t = ap; t ; t = t->_internal.next) {
- if(!t->match.enabled)
- continue;
+ for(size_t template = 0; template < 2; template++) {
+ bool want_template = template ? true : false;
- if(!prototype_matches_host(st->rrdhost, t))
- continue;
+ for (RRD_ALERT_PROTOTYPE *t = ap; t; t = t->_internal.next) {
+ if (!t->match.enabled)
+ continue;
- if(!prototype_matches_rrdset(st, t))
- continue;
+ bool is_template = t->match.is_template ? true : false;
- if(rrdcalc_add_from_prototype(st->rrdhost, st, t))
- ap->_internal.uses++;
+ if (is_template != want_template)
+ continue;
+
+ if (!prototype_matches_host(st->rrdhost, t))
+ continue;
+
+ if (!prototype_matches_rrdset(st, t))
+ continue;
+
+ if (rrdcalc_add_from_prototype(st->rrdhost, st, t))
+ ap->_internal.uses++;
+ }
}
spinlock_unlock(&ap->_internal.spinlock);
}