Skip to content

Commit

Permalink
feat: reorder terms
Browse files Browse the repository at this point in the history
first check alarm then warning and afterwards check for normal and anomalous
  • Loading branch information
rahul-kriplani-jnpr committed Feb 12, 2025
1 parent 48d9913 commit 17610f3
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ healthbot {
}
}
type float;
description "JAIML anomaly detection on input traffic field";
description "JAIML anomaly detection on input traffic rate field";
}
field out-errors-count-anomaly {
formula {
Expand All @@ -247,7 +247,7 @@ healthbot {
}
}
type float;
description "JAIML anomaly detection on output traffic field";
description "JAIML anomaly detection on output traffic rate field";
}
/*
* Anomaly detection logic.
Expand All @@ -258,16 +258,18 @@ healthbot {
description "Sets health based on input traffic exceed threshold";
frequency 1offset;
/*
* Sets color to green when in-util is below low-threshold
* Sets color to red and sends out an anomaly notification
* when the interface input traffic ($in-util) is
* above high threshold (high-threshold)
*/
term interface-in-traffic-normal {
term is-interface-in-traffic-abnormal {
when {
less-than "$in-util" "$low-threshold";
}
greater-than-or-equal-to "$in-util" "$high-threshold";
}
then {
status {
color green;
message "$interface-name input traffic:$in-mbps mbps is $in-util % of interface speed $speed mbps is normal";
color red;
message "$interface-name input traffic:$in-mbps mbps is $in-util % of interface speed $speed mbps is above high threshold";
}
}
}
Expand All @@ -289,32 +291,30 @@ healthbot {
}
}
/*
* Sets color to red and sends out an anomaly notification
* when the interface input traffic ($in-util) is
* above high threshold (high-threshold)
*/
term is-interface-in-traffic-abnormal {
* Sets color to yellow when in-mbps is not in between predicted range.
*/
term is-in-mbps-anomalous {
when {
greater-than-or-equal-to "$in-util" "$high-threshold";
equal-to "$in-mbps-anomaly" 1;
}
then {
status {
color red;
message "$interface-name input traffic:$in-mbps mbps is $in-util % of interface speed $speed mbps is above high threshold";
color yellow;
message "$interface-name, input traffic:$in-mbps mbps is not between the predicted range of ($in-mbps-anomaly-lower-boundary) and ($in-mbps-anomaly-upper-boundary)";
}
}
}
/*
* Sets color to yellow when in-mbps is not in between predicted range.
*/
term is-in-mbps-anomalous {
* Sets color to green when in-util is below low-threshold
*/
term interface-in-traffic-normal {
when {
equal-to "$in-mbps-anomaly" 1;
}
less-than "$in-util" "$low-threshold";
}
then {
status {
color yellow;
message "$interface-name, input traffic:$in-mbps mbps is not between the predicted range of ($in-mbps-anomaly-lower-boundary) and ($in-mbps-anomaly-upper-boundary)";
color green;
message "$interface-name input traffic:$in-mbps mbps is $in-util % of interface speed $speed mbps is normal";
}
}
}
Expand Down Expand Up @@ -519,16 +519,18 @@ healthbot {
description "Sets health based on output traffic exceed threshold";
frequency 1offset;
/*
* Sets color to green when out-util is below low threshold
* Sets color to red and sends out an anomaly notification when
* the interface output traffic ($out-util) is
* above high threshold (high-threshold)
*/
term is-interface-stats-normal {
term is-interface-stats-abnormal {
when {
less-than "$out-util" "$low-threshold";
}
greater-than-or-equal-to "$out-util" "$high-threshold";
}
then {
status {
color green;
message "$interface-name output traffic:$out-mbps mbps is $out-util % of interface speed $speed mbps is normal";
color red;
message "$interface-name output traffic:$out-mbps mbps is $out-util % of interface speed $speed mbps is above high threshold";
}
}
}
Expand All @@ -550,32 +552,30 @@ healthbot {
}
}
/*
* Sets color to red and sends out an anomaly notification when
* the interface output traffic ($out-util) is
* above high threshold (high-threshold)
*/
term is-interface-stats-abnormal {
* Sets color to yellow when out-mbps is not in between predicted range.
*/
term is-out-mbps-anomalous {
when {
greater-than-or-equal-to "$out-util" "$high-threshold";
equal-to "$out-mbps-anomaly" 1;
}
then {
status {
color red;
message "$interface-name output traffic:$out-mbps mbps is $out-util % of interface speed $speed mbps is above high threshold";
color yellow;
message "$interface-name, output traffic:$out-mbps mbps is not between the predicted range of ($out-mbps-anomaly-lower-boundary) and ($out-mbps-anomaly-upper-boundary)";
}
}
}
/*
* Sets color to yellow when out-mbps is not in between predicted range.
*/
term is-out-mbps-anomalous {
* Sets color to green when out-util is below low threshold
*/
term is-interface-stats-normal {
when {
equal-to "$out-mbps-anomaly" 1;
}
less-than "$out-util" "$low-threshold";
}
then {
status {
color yellow;
message "$interface-name, output traffic:$out-mbps mbps is not between the predicted range of ($out-mbps-anomaly-lower-boundary) and ($out-mbps-anomaly-upper-boundary)";
color green;
message "$interface-name output traffic:$out-mbps mbps is $out-util % of interface speed $speed mbps is normal";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,36 @@ healthbot {
synopsis "Interface optical rx high power KPI";
description "Sets health based on Interface optical rx high power";
frequency 1offset;
/*
* Sets color to red when optics rx power is greater-than rx-high-alarm-threshold.
*/
term rx-above-high-alarm-threshold {
when {
greater-than "$optics-rx-power" "$rx-high-alarm-threshold";
}
then {
status {
color red;
message "$interface-name,lane $lane-index Rx power $optics-rx-power is above high alarm threshold ($rx-high-alarm-threshold)";
}
}
}
/*
* Sets color to yellow when optics rx power is greater-than-or-equal-to rx-high-warning-threshold
* and less-than-or-equal-to rx-high-alarm-threshold
*/
term rx-above-high-warning-threshold {
when {
greater-than-or-equal-to "$optics-rx-power" "$rx-high-warning-threshold";
less-than-or-equal-to "$optics-rx-power" "$rx-high-alarm-threshold";
}
then {
status {
color yellow;
message "$interface-name,lane $lane-index Rx power $optics-rx-power is above high warning threshold ($rx-high-warning-threshold) ";
}
}
}
/*
* Sets color to green when optic rx power is betweeen rx-below-low-warning-threshold
* and rx-high-warning-threshold
Expand All @@ -404,18 +434,16 @@ healthbot {
}
}
/*
* Sets color to yellow when optics rx power is greater-than-or-equal-to rx-high-warning-threshold
* and less-than-or-equal-to rx-high-alarm-threshold
* Sets color to yellow when optics rx power is not in between predicted range.
*/
term rx-above-high-warning-threshold {
term is-optics-rx-power-anomalous {
when {
greater-than-or-equal-to "$optics-rx-power" "$rx-high-warning-threshold";
less-than-or-equal-to "$optics-rx-power" "$rx-high-alarm-threshold";
equal-to "$optics-rx-power-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name,lane $lane-index Rx power $optics-rx-power is above high warning threshold ($rx-high-warning-threshold) ";
message "$interface-name,lane $lane-index Rx power is not between the predicted range of ($optics-rx-power-anomaly-lower-boundary) and ($optics-rx-power-anomaly-upper-boundary)";
}
}
}
Expand All @@ -436,54 +464,55 @@ healthbot {
}
}
/*
* Sets color to red when optics rx power is greater-than rx-high-alarm-threshold.
* Sets color to red when optics rx power is lesser-than rx-low-alarm-threshold.
*/
term rx-above-high-alarm-threshold {
term rx-below-low-alarm-threshold {
when {
greater-than "$optics-rx-power" "$rx-high-alarm-threshold";
less-than "$optics-rx-power" "$rx-low-alarm-threshold";
}
then {
status {
color red;
message "$interface-name,lane $lane-index Rx power $optics-rx-power is above high alarm threshold ($rx-high-alarm-threshold)";
message "$interface-name,lane $lane-index Rx power $optics-rx-power is below low alarm threshold ($rx-low-alarm-threshold)";
}
}
}
}
trigger interface-optical-tx-power {
alert-type interfaces.tx.power.interface-optical-tx-power;
synopsis "Interface optical tx high power KPI";
description "Sets health based on Interface optical tx high power";
frequency 1offset;
/*
* Sets color to red when optics rx power is lesser-than rx-low-alarm-threshold.
* Sets color to red when optics tx power is greater-than tx-high-alarm-threshold.
*/
term rx-below-low-alarm-threshold {
term tx-above-high-alarm-threshold {
when {
less-than "$optics-rx-power" "$rx-low-alarm-threshold";
greater-than "$optics-tx-power" "$tx-high-alarm-threshold";
}
then {
status {
color red;
message "$interface-name,lane $lane-index Rx power $optics-rx-power is below low alarm threshold ($rx-low-alarm-threshold)";
message "$interface-name,lane $lane-index Tx power $optics-tx-power is above alarm threshold ($tx-high-alarm-threshold)";
}
}
}
/*
* Sets color to yellow when optics rx power is greater-than-or-equal-to rx-high-warning-threshold
* and less-than-or-equal-to rx-high-alarm-threshold
* Sets color to yellow when optic tx power is greater-than-or-equal-to tx-high-warning-threshold
* and less-than-or-equal-to tx-high-alarm-threshold
*/
term is-optics-rx-power-anomalous {
term tx-above-high-warning-threshold {
when {
equal-to "$optics-rx-power-anomaly" 1;
}
greater-than-or-equal-to "$optics-tx-power" "$tx-high-warning-threshold";
less-than-or-equal-to "$optics-tx-power" "$tx-high-alarm-threshold";
}
then {
status {
color yellow;
message "$interface-name,lane $lane-index Rx power is not between the predicted range of ($optics-rx-power-anomaly-lower-boundary) and ($optics-rx-power-anomaly-upper-boundary)";
message "$interface-name,lane $lane-index Tx power $optics-tx-power is above warning threshold ($tx-high-warning-threshold)";
}
}
}
}
trigger interface-optical-tx-power {
alert-type interfaces.tx.power.interface-optical-tx-power;
synopsis "Interface optical tx high power KPI";
description "Sets health based on Interface optical tx high power";
frequency 1offset;
/*
* Sets color to green when optic tx power is betweeen tx-low-warning-threshold
* and tx-high-warning-threshold
Expand All @@ -501,18 +530,16 @@ healthbot {
}
}
/*
* Sets color to yellow when optic tx power is greater-than-or-equal-to tx-high-warning-threshold
* and less-than-or-equal-to tx-high-alarm-threshold
* Sets color to yellow when optics tx power is not in between predicted range.
*/
term tx-above-high-warning-threshold {
term is-optics-tx-power-anomalous {
when {
greater-than-or-equal-to "$optics-tx-power" "$tx-high-warning-threshold";
less-than-or-equal-to "$optics-tx-power" "$tx-high-alarm-threshold";
}
equal-to "$optics-tx-power-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name,lane $lane-index Tx power $optics-tx-power is above warning threshold ($tx-high-warning-threshold)";
message "$interface-name,lane $lane-index Tx power is not between the predicted range of ($optics-tx-power-anomaly-lower-boundary) and ($optics-tx-power-anomaly-upper-boundary)";
}
}
}
Expand All @@ -532,20 +559,6 @@ healthbot {
}
}
}
/*
* Sets color to red when optics tx power is greater-than tx-high-alarm-threshold.
*/
term tx-above-high-alarm-threshold {
when {
greater-than "$optics-tx-power" "$tx-high-alarm-threshold";
}
then {
status {
color red;
message "$interface-name,lane $lane-index Tx power $optics-tx-power is above alarm threshold ($tx-high-alarm-threshold)";
}
}
}
/*
* Sets color to red when optics tx power is greater-than tx-low-alarm-threshold.
*/
Expand All @@ -560,20 +573,6 @@ healthbot {
}
}
}
/*
* Sets color to yellow when optics tx power is not in between predicted range.
*/
term is-optics-tx-power-anomalous {
when {
equal-to "$optics-tx-power-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name,lane $lane-index Tx power is not between the predicted range of ($optics-tx-power-anomaly-lower-boundary) and ($optics-tx-power-anomaly-upper-boundary)";
}
}
}
}
variable interface-name {
value .*;
Expand Down
Loading

0 comments on commit 17610f3

Please sign in to comment.