Alerting: Fix and re-enable filters instance labels in log line test (#65622)
Alerting: Fix and re-enable `filters instance labels in log line` test (#65618)
Fix and reenable test
(cherry picked from commit 5e87ea745d)
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -356,8 +357,14 @@ func buildLogQuery(query models.HistoryQuery) (string, error) {
|
||||
logQL := selectorString(selectors)
|
||||
|
||||
labelFilters := ""
|
||||
for k, v := range query.Labels {
|
||||
labelFilters += fmt.Sprintf(" | labels_%s=%q", k, v)
|
||||
labelKeys := make([]string, 0, len(query.Labels))
|
||||
for k := range query.Labels {
|
||||
labelKeys = append(labelKeys, k)
|
||||
}
|
||||
// Ensure that all queries we build are deterministic.
|
||||
sort.Strings(labelKeys)
|
||||
for _, k := range labelKeys {
|
||||
labelFilters += fmt.Sprintf(" | labels_%s=%q", k, query.Labels[k])
|
||||
}
|
||||
|
||||
if labelFilters != "" {
|
||||
|
||||
Reference in New Issue
Block a user