nixos/hosts/vm/victoriametrics/rules/bird.nix

164 lines
3.8 KiB
Nix

{ critical, warning, ... }:
{
records."bird:protocol_up:bgp_all".expr = ''
label_replace(
bird_protocol_up{proto="BGP"},
"group", "$1",
"instance", "^([^0-9\\.]+)-[0-9]+.*"
)
'';
# FIXME: sessions en cours d'installation, pas encore monitorées
records."bird:protocol_up:bgp".expr = ''
bird:protocol_up:bgp_all
unless
bird:protocol_up:bgp_all{
group="edge",
name=~"^(viarezo|isp[12]|rezel)[46]$"
}
'';
# Sessions qui ne sont volontairement pas redondées
# au sein d'un groupe
records."bird:protocol_up:bgp:non_redundant".expr = ''
bird:protocol_up:bgp{
group="edge",
name=~"^(oti|crans|legacy|edge)[46]$"
}
'';
# Sessions qui le sont
records."bird:protocol_up:bgp:redundant".expr = ''
bird:protocol_up:bgp
unless
bird:protocol_up:bgp:non_redundant
'';
alerts.BirdBGPRedundancyDegraded = {
expr = ''
(
count by (group, name) (
bird:protocol_up:bgp:redundant{state="Established"}
) + (
count by (group, name) (
bird:protocol_up:bgp:redundant{state!="Established"} * 0
)
)
) < 2
'';
for = "0m";
labels = warning;
annotations = {
Session = "{{ $labels.name }}";
Count = "{{ $value }}";
Group = "{{ $labels.group }}";
};
};
alerts.BirdBGPDown = {
expr = ''
(
count by (group, name) (
bird:protocol_up:bgp{state="Established"}
) + (
count by (group, name) (
bird:protocol_up:bgp{state!="Established"} * 0
)
)
) == 0
'';
for = "0m";
labels = critical;
annotations = {
Session = "{{ $labels.name }}";
Group = "{{ $labels.group }}";
};
};
# TODO: warning pour redondant ?
alerts.BirdBGPNoExportedPrefixRedundant = {
expr = ''
bird_protocol_prefix_export_count{
export_filter!="REJECT",
} * on (instance, name) group_left (group) (
bird:protocol_up:bgp:redundant{state="Established"}
) == 0
'';
for = "0m";
labels = critical;
annotations = {
Session = "{{ $labels.name }}";
Group = "{{ $labels.group }}";
};
};
alerts.BirdBGPNoImportedPrefixRedundant = {
expr = ''
bird_protocol_prefix_import_count{
import_filter!="REJECT",
} * on (instance, name) group_left (group) (
bird:protocol_up:bgp:redundant{state="Established"}
) == 0
'';
for = "0m";
labels = critical;
annotations = {
Session = "{{ $labels.name }}";
Group = "{{ $labels.group }}";
};
};
alerts.BirdBGPNoExportedPrefixNonRedundant = {
expr = ''
sum by (group) (
bird_protocol_prefix_export_count{
export_filter!="REJECT",
} * on (instance, name) group_left (group) (
bird:protocol_up:bgp:non_redundant{state="Established"}
)
) == 0
'';
for = "0m";
labels = critical;
annotations = {
Session = "{{ $labels.name }}";
Group = "{{ $labels.group }}";
};
};
alerts.BirdBGPNoImportedPrefixNonRedundant = {
expr = ''
sum by (group) (
bird_protocol_prefix_import_count{
import_filter!="REJECT",
} * on (instance, name) group_left (group) (
bird:protocol_up:bgp:non_redundant{state="Established"}
)
) == 0
'';
for = "0m";
labels = critical;
annotations = {
Session = "{{ $labels.name }}";
Group = "{{ $labels.group }}";
};
};
alerts.BirdOSPFNeighboursChange = {
expr = ''
changes(bird_ospf_neighbor_count[5m]) > 0
or changes(bird_ospfv3_neighbor_count[5m]) > 0
'';
for = "0m";
labels = warning;
};
alerts.BirdOSPFDown = {
expr = "bird_ospf_running == 0";
for = "0m";
labels = critical;
annotations.Instance = "{{ $labels.name }}";
};
}