Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::inhibition_rule Struct Reference

Rule for inhibiting alerts based on other alerts. More...

#include <alert_pipeline.h>

Collaboration diagram for kcenon::monitoring::inhibition_rule:
Collaboration graph

Public Member Functions

bool matches_source (const alert &a) const
 Check if source alert matches this rule.
 
bool should_inhibit (const alert &source, const alert &target) const
 Check if target alert should be inhibited by source.
 

Public Attributes

std::string name
 
alert_labels source_match
 Labels that source alert must have.
 
alert_labels target_match
 Labels that target alert must have.
 
std::vector< std::string > equal
 Labels that must be equal on both.
 

Detailed Description

Rule for inhibiting alerts based on other alerts.

When a source alert is firing, target alerts matching the specified labels are inhibited (silenced).

Examples
alert_pipeline_example.cpp.

Definition at line 261 of file alert_pipeline.h.

Member Function Documentation

◆ matches_source()

bool kcenon::monitoring::inhibition_rule::matches_source ( const alert & a) const
inline

Check if source alert matches this rule.

Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_pipeline.h.

Definition at line 270 of file alert_pipeline.h.

270 {
271 for (const auto& [key, value] : source_match.labels) {
272 if (a.labels.get(key) != value) {
273 return false;
274 }
275 }
276 return true;
277 }
std::unordered_map< std::string, std::string > labels
alert_labels source_match
Labels that source alert must have.

References kcenon::monitoring::alert_labels::get(), kcenon::monitoring::alert::labels, kcenon::monitoring::alert_labels::labels, and source_match.

Referenced by should_inhibit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ should_inhibit()

bool kcenon::monitoring::inhibition_rule::should_inhibit ( const alert & source,
const alert & target ) const
inline

Check if target alert should be inhibited by source.

Examples
/home/runner/work/monitoring_system/monitoring_system/include/kcenon/monitoring/alert/alert_pipeline.h.

Definition at line 282 of file alert_pipeline.h.

282 {
283 // Source must match
284 if (!matches_source(source)) {
285 return false;
286 }
287
288 // Target must match target_match labels
289 for (const auto& [key, value] : target_match.labels) {
290 if (target.labels.get(key) != value) {
291 return false;
292 }
293 }
294
295 // Equal labels must match between source and target
296 for (const auto& label : equal) {
297 if (source.labels.get(label) != target.labels.get(label)) {
298 return false;
299 }
300 }
301
302 return true;
303 }
std::vector< std::string > equal
Labels that must be equal on both.
alert_labels target_match
Labels that target alert must have.
bool matches_source(const alert &a) const
Check if source alert matches this rule.

References equal, kcenon::monitoring::alert_labels::get(), kcenon::monitoring::alert::labels, kcenon::monitoring::alert_labels::labels, matches_source(), and target_match.

Here is the call graph for this function:

Member Data Documentation

◆ equal

std::vector<std::string> kcenon::monitoring::inhibition_rule::equal

◆ name

std::string kcenon::monitoring::inhibition_rule::name

◆ source_match

alert_labels kcenon::monitoring::inhibition_rule::source_match

◆ target_match

alert_labels kcenon::monitoring::inhibition_rule::target_match

The documentation for this struct was generated from the following file: