Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: interface health anomaly fields and term #1009

Open
wants to merge 3 commits into
base: jcloud
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions juniper_official/interface/check-interface-fec-crc-framing-errors.rule
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,51 @@ healthbot {
type integer;
description "Checks for output CRC errors";
}
field fec-corrected-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$fec-corrected";
}
}
type integer;
description "JAIML anomaly detection for FEC corrected errors field";
}
field fec-uncorrected-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$fec-uncorrected";
}
}
type integer;
description "JAIML anomaly detection for FEC un-corrected errors field";
}
field framing-errors-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$framing-errors";
}
}
type integer;
description "JAIML anomaly detection for framing errors field";
}
field input-crc-errors-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$input-crc-errors";
}
}
type integer;
description "JAIML anomaly detection for input CRC errors field";
}
field output-crc-errors-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$output-crc-errors";
}
}
type integer;
description "JAIML anomaly detection for output CRC errors field";
}
/*
* Anomaly detection logic.
*/
Expand Down Expand Up @@ -136,6 +181,20 @@ healthbot {
}
}
}
/*
* Sets color to yellow when fec-corrected-errors is not in between predicted range.
*/
term is-fec-corrected-errors-anomalous {
when {
equal-to "$fec-corrected-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name, FEC corrected errors $fec-corrected is not between the predicted range of ($fec-corrected-anomaly-lower-boundary) and ($fec-corrected-anomaly-upper-boundary)";
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this I should use next?
what will be the correct syntax?
then {
next {
? the next term, define it or just use its name?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can anomaly be 1 when green condition is met?If yes then enable "Evalute next term" for both the green and red terms else only for the red term.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anomaly can be 1 for both green and red.
the user guide talks about enabling evaluate next term from UI, how to enable it programatically from the rule?

Copy link
Collaborator

@vvikramb vvikramb Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do it through mgd, something like this :

rule test {
trigger testing {
term test {
then {
next;
}
}
}
}

Also check below points

Enable "Evaluate next terms" for interface-input-errors and interface-output-errors triggers in "check-interface-in-out-errors-traffic-state-flaps" rule

For "check-optical-signal-loss-fec-tx-rx-power",no need to change the order of red and yellow terms, just add the anomaly term before the red terms and enable "Evalute next term" in previous and anomaly terms.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For check-optical-signal-loss-fec-tx-rx-power.rule the triggers interface-optical-rx-power and interface-optical-tx-power has two red terms, so I have added anomaly term before the first red term.

}
trigger fec-uncorrected-errors {
alert-type interfaces.errors.fec-uncorrected-errors;
Expand Down Expand Up @@ -174,6 +233,20 @@ healthbot {
message "FEC Uncorrected Errors $fec-uncorrected on $interface-name has increased";
}
}
}
/*
* Sets color to yellow when fec-uncorrected-errors is not in between predicted range.
*/
term is-fec-uncorrected-errors-anomalous {
when {
equal-to "$fec-uncorrected-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name, FEC uncorrected errors $fec-uncorrected is not between the predicted range of ($fec-uncorrected-anomaly-lower-boundary) and ($fec-uncorrected-anomaly-upper-boundary)";
}
}
}
}
trigger framing-errors {
Expand Down Expand Up @@ -217,6 +290,20 @@ healthbot {
}
}
}
/*
* Sets color to yellow when framing-errors is not in between predicted range.
*/
term is-framing-errors-anomalous {
when {
equal-to "$framing-errors-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name, framing errors $framing-errors is not between the predicted range of ($framing-errors-anomaly-lower-boundary) and ($framing-errors-anomaly-upper-boundary)";
}
}
}
}
trigger input-crc-errors {
alert-type interfaces.rx_errors.crc.input-crc-errors;
Expand Down Expand Up @@ -256,6 +343,20 @@ healthbot {
}
}
}
/*
* Sets color to yellow when input-crc-errors is not in between predicted range.
*/
term is-input-crc-errors-anomalous {
when {
equal-to "$input-crc-errors-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name, input CRC errors $input-crc-errors is not between the predicted range of ($input-crc-errors-anomaly-lower-boundary) and ($input-crc-errors-anomaly-upper-boundary)";
}
}
}
}
trigger output-crc-errors {
alert-type interfaces.tx_errors.crc.output-crc-errors;
Expand Down Expand Up @@ -295,6 +396,20 @@ healthbot {
}
}
}
/*
* Sets color to yellow when output-crc-errors is not in between predicted range.
*/
term is-output-crc-errors-anomalous {
when {
equal-to "$output-crc-errors-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name, output CRC errors $output-crc-errors is not between the predicted range of ($output-crc-errors-anomaly-lower-boundary) and ($output-crc-errors-anomaly-upper-boundary)";
}
}
}
}
/*
* Variables with default values. Default values can be changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,42 @@ healthbot {
type integer;
description "Interface speed";
}
field in-errors-count-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$in-errors-count";
}
}
type integer;
description "JAIML anomaly detection on input errors count field";
}
field in-mbps-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$in-mbps";
}
}
type float;
description "JAIML anomaly detection on input traffic rate field";
}
field out-errors-count-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$out-errors-count";
}
}
type integer;
description "JAIML anomaly detection on output errors count field";
}
field out-mbps-anomaly {
formula {
jaiml-anomaly-detection {
field-name "$out-mbps";
}
}
type float;
description "JAIML anomaly detection on output traffic rate field";
}
/*
* Anomaly detection logic.
*/
Expand All @@ -222,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 @@ -253,18 +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 green when in-util is below low-threshold
*/
term interface-in-traffic-normal {
when {
less-than "$in-util" "$low-threshold";
}
then {
status {
color green;
message "$interface-name input traffic:$in-mbps mbps is $in-util % of interface speed $speed mbps is normal";
}
}
}
Expand Down Expand Up @@ -310,6 +360,20 @@ healthbot {
message "Input errors are increasing continuously on $interface-name, Error count is:$in-errors-count";
}
}
}
/*
* Sets color to yellow when in-errors-count is not in between predicted range.
*/
term is-in-errors-count-anomalous {
when {
equal-to "$in-errors-count-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name, input errors count $in-errors-count is not between the predicted range of ($in-errors-count-anomaly-lower-boundary) and ($in-errors-count-anomaly-upper-boundary)";
}
}
}
}
trigger interface-link-flaps {
Expand Down Expand Up @@ -433,6 +497,20 @@ healthbot {
message "Output errors are increasing continuously on $interface-name, Error count is:$out-errors-count";
}
}
}
/*
* Sets color to yellow when out-errors-count is not in between predicted range.
*/
term is-out-errors-count-anomalous {
when {
equal-to "$out-errors-count-anomaly" 1;
}
then {
status {
color yellow;
message "$interface-name, output errors count $out-errors-count is not between the predicted range of ($out-errors-count-anomaly-lower-boundary) and ($out-errors-count-anomaly-upper-boundary)";
}
}
}
}
trigger interface-output-traffic {
Expand All @@ -441,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 @@ -472,18 +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 green when out-util is below low threshold
*/
term is-interface-stats-normal {
when {
less-than "$out-util" "$low-threshold";
}
then {
status {
color green;
message "$interface-name output traffic:$out-mbps mbps is $out-util % of interface speed $speed mbps is normal";
}
}
}
Expand Down
Loading