@@ -103,9 +103,8 @@ func (rb *ruleBuilder) buildRecordingRuleLabels() map[string]string {
103103
104104func (rb * ruleBuilder ) kernelDropsRecording () (* monitoringv1.Rule , error ) {
105105 metric , totalMetric := rb .getMetricsForAlert ()
106- filter := rb .buildLabelFilter ("" )
107- metricsRate := promQLRateFromMetric (metric , "" , filter , "5m" , "" )
108- totalRate := promQLRateFromMetric (totalMetric , "" , filter , "5m" , "" )
106+ metricsRate := promQLRateFromMetric (metric , "" , "" , "5m" , "" )
107+ totalRate := promQLRateFromMetric (totalMetric , "" , "" , "5m" , "" )
109108 metricsSumBy := sumBy (metricsRate , rb .alert .GroupBy , rb .side , "" )
110109 totalSumBy := sumBy (totalRate , rb .alert .GroupBy , rb .side , "" )
111110
@@ -149,9 +148,8 @@ func (rb *ruleBuilder) deviceDropsRecording() (*monitoringv1.Rule, error) {
149148
150149func (rb * ruleBuilder ) ipsecErrorsRecording () (* monitoringv1.Rule , error ) {
151150 metric , totalMetric := rb .getMetricsForAlert ()
152- filter := rb .buildLabelFilter ("" )
153- metricsRate := promQLRateFromMetric (metric , "" , filter , "5m" , "" )
154- totalRate := promQLRateFromMetric (totalMetric , "" , filter , "5m" , "" )
151+ metricsRate := promQLRateFromMetric (metric , "" , "" , "5m" , "" )
152+ totalRate := promQLRateFromMetric (totalMetric , "" , "" , "5m" , "" )
155153 metricsSumBy := sumBy (metricsRate , rb .alert .GroupBy , rb .side , "" )
156154 totalSumBy := sumBy (totalRate , rb .alert .GroupBy , rb .side , "" )
157155 promql := fmt .Sprintf ("100 * (%s) / (%s)" , metricsSumBy , totalSumBy )
@@ -170,10 +168,8 @@ func (rb *ruleBuilder) dnsErrorsRecording() (*monitoringv1.Rule, error) {
170168 }
171169
172170 metric , totalMetric := rb .getMetricsForAlert ()
173- metricsFilter := rb .buildLabelFilter (`DnsFlagsResponseCode!="NoError"` )
174- totalFilter := rb .buildLabelFilter ("" )
175- metricsRate := promQLRateFromMetric (metric , "_count" , metricsFilter , "5m" , "" )
176- totalRate := promQLRateFromMetric (totalMetric , "_count" , totalFilter , "5m" , "" )
171+ metricsRate := promQLRateFromMetric (metric , "_count" , `{DnsFlagsResponseCode!="NoError"}` , "5m" , "" )
172+ totalRate := promQLRateFromMetric (totalMetric , "_count" , "" , "5m" , "" )
177173 metricsSumBy := sumBy (metricsRate , rb .alert .GroupBy , rb .side , "" )
178174 totalSumBy := sumBy (totalRate , rb .alert .GroupBy , rb .side , "" )
179175 promql := fmt .Sprintf ("100 * (%s) / (%s)" , metricsSumBy , totalSumBy )
@@ -187,10 +183,8 @@ func (rb *ruleBuilder) dnsErrorsRecording() (*monitoringv1.Rule, error) {
187183
188184func (rb * ruleBuilder ) netpolDeniedRecording () (* monitoringv1.Rule , error ) {
189185 metric , totalMetric := rb .getMetricsForAlert ()
190- metricsFilter := rb .buildLabelFilter (`action="drop"` )
191- totalFilter := rb .buildLabelFilter ("" )
192- metricsRate := promQLRateFromMetric (metric , "" , metricsFilter , "5m" , "" )
193- totalRate := promQLRateFromMetric (totalMetric , "" , totalFilter , "5m" , "" )
186+ metricsRate := promQLRateFromMetric (metric , "" , `{action="drop"}` , "5m" , "" )
187+ totalRate := promQLRateFromMetric (totalMetric , "" , "" , "5m" , "" )
194188 metricsSumBy := sumBy (metricsRate , rb .alert .GroupBy , rb .side , "" )
195189 totalSumBy := sumBy (totalRate , rb .alert .GroupBy , rb .side , "" )
196190 promql := fmt .Sprintf ("100 * (%s) / (%s)" , metricsSumBy , totalSumBy )
@@ -206,9 +200,8 @@ func (rb *ruleBuilder) latencyTrendRecording() (*monitoringv1.Rule, error) {
206200 offset , duration := rb .alert .GetTrendParams ()
207201
208202 metric , baseline := rb .getMetricsForAlert ()
209- filter := rb .buildLabelFilter ("" )
210- metricsRate := promQLRateFromMetric (metric , "_bucket" , filter , "5m" , "" )
211- baselineRate := promQLRateFromMetric (baseline , "_bucket" , filter , duration , " offset " + offset )
203+ metricsRate := promQLRateFromMetric (metric , "_bucket" , "" , "5m" , "" )
204+ baselineRate := promQLRateFromMetric (baseline , "_bucket" , "" , duration , " offset " + offset )
212205 metricQuantile := histogramQuantile (metricsRate , rb .alert .GroupBy , rb .side , "0.9" )
213206 baselineQuantile := histogramQuantile (baselineRate , rb .alert .GroupBy , rb .side , "0.9" )
214207
0 commit comments