@@ -98,37 +98,49 @@ func TestBuildRules_DefaultWithFeaturesAndDisabled(t *testing.T) {
9898 assert .Equal (t , []string {
9999 "netobserv:health:packet_drops_kernel:namespace:src:rate2m" ,
100100 "netobserv:health:packet_drops_kernel:namespace:dst:rate2m" ,
101- "PacketDropsByKernel_PerSrcNamespaceWarning" ,
102- "PacketDropsByKernel_PerDstNamespaceWarning" ,
103101 "netobserv:health:packet_drops_kernel:node:src:rate2m" ,
104102 "netobserv:health:packet_drops_kernel:node:dst:rate2m" ,
105- "PacketDropsByKernel_PerSrcNodeWarning" ,
106- "PacketDropsByKernel_PerDstNodeWarning" ,
107103 "PacketDropsByDevice_PerNodeWarning" ,
108- "IPsecErrors_Critical" ,
109- "IPsecErrors_PerSrcNodeCritical" ,
110- "IPsecErrors_PerDstNodeCritical" ,
104+ "PacketDropsByDevice_PerNodeInfo" ,
105+ "IPsecErrors_Warning" ,
106+ "IPsecErrors_PerSrcNodeWarning" ,
107+ "IPsecErrors_PerDstNodeWarning" ,
111108 "DNSErrors_Warning" ,
112109 "DNSErrors_PerDstNamespaceWarning" ,
113110 "DNSErrors_PerDstNamespaceInfo" ,
114111 "netobserv:health:dns_nxdomain:namespace:dst:rate2m" ,
115112 "netobserv:health:netpol_denied:namespace:src:rate2m" ,
116113 "netobserv:health:netpol_denied:namespace:dst:rate2m" ,
117- "NetpolDenied_PerSrcNamespaceWarning" ,
118- "NetpolDenied_PerDstNamespaceWarning" ,
119114 "netobserv:health:tcp_latency_increase_p90:namespace:src:rate2m" ,
120115 "netobserv:health:tcp_latency_increase_p90:namespace:dst:rate2m" ,
121116 "netobserv:health:ingress_5xx_errors:namespace:src:rate2m" ,
122117 "netobserv:health:ingress_http_latency_increase_avg:namespace:src:rate2m" ,
123118 "NetObservNoFlows" ,
124119 }, allNames (rules ))
125- assert .Contains (t , rules [2 ].Annotations ["description" ], "NetObserv is detecting more than 20% of packets dropped by the kernel [source namespace={{ $labels.namespace }}]" )
126- assert .Equal (t , `{"alertThreshold":"20","unit":"%","namespaceLabels":["namespace"]}` , rules [2 ].Annotations ["netobserv_io_network_health" ])
127- assert .Contains (t , rules [6 ].Annotations ["description" ], "NetObserv is detecting more than 10% of packets dropped by the kernel [source node={{ $labels.node }}]" )
128- assert .Equal (t , `{"alertThreshold":"10","unit":"%","nodeLabels":["node"]}` , rules [6 ].Annotations ["netobserv_io_network_health" ])
129- assert .Contains (t , rules [8 ].Annotations ["description" ], "node-exporter is reporting more than 5% of dropped packets [node={{ $labels.instance }}]" )
130- assert .Equal (t , `{"alertThreshold":"5","unit":"%","nodeLabels":["instance"]}` , rules [8 ].Annotations ["netobserv_io_network_health" ])
131- assert .Contains (t , rules [len (rules )- 1 ].Annotations ["description" ], "NetObserv flowlogs-pipeline is not receiving any flow" )
120+ r := findRule ("PacketDropsByDevice_PerNodeWarning" , rules )
121+ assert .NotNil (t , r )
122+ assert .Equal (t , "node-exporter is reporting more than 10% of dropped packets [node={{ $labels.instance }}]." , r .Annotations ["description" ])
123+ assert .Equal (t , `{"alertThreshold":"10","unit":"%","nodeLabels":["instance"]}` , r .Annotations ["netobserv_io_network_health" ])
124+ r = findRule ("IPsecErrors_Warning" , rules )
125+ assert .NotNil (t , r )
126+ assert .Equal (t , "NetObserv is detecting more than 2% of IPsec errors." , r .Annotations ["description" ])
127+ assert .Equal (t , `{"alertThreshold":"2","unit":"%"}` , r .Annotations ["netobserv_io_network_health" ])
128+ r = findRule ("DNSErrors_PerDstNamespaceWarning" , rules )
129+ assert .NotNil (t , r )
130+ assert .Equal (t , "NetObserv is detecting more than 10% of DNS errors [dest. namespace={{ $labels.namespace }}] (other than NX_DOMAIN)." , r .Annotations ["description" ])
131+ assert .Contains (t , r .Annotations ["netobserv_io_network_health" ], `{"alertThreshold":"10","unit":"%","namespaceLabels":["namespace"]` )
132+ r = findRule ("NetObservNoFlows" , rules )
133+ assert .NotNil (t , r )
134+ assert .Contains (t , r .Annotations ["description" ], "NetObserv flowlogs-pipeline is not receiving any flow" )
135+ }
136+
137+ func findRule (name string , rules []monitoringv1.Rule ) * monitoringv1.Rule {
138+ for i := range rules {
139+ if rules [i ].Alert == name {
140+ return & rules [i ]
141+ }
142+ }
143+ return nil
132144}
133145
134146func TestBuildRules_DefaultWithFeaturesAndAllDisabled (t * testing.T ) {
0 commit comments