Alerting: Improve performance of /api/prometheus for large numbers of alerts. (#89268)

* Alerting: Optimize sorting alert instances.

* Also change other Labels fields for consistency
This commit is contained in:
Steve Simpson
2024-06-17 12:25:47 +02:00
committed by GitHub
parent a7726ff813
commit 43a246f431
4 changed files with 49 additions and 57 deletions
@@ -21,10 +21,11 @@ func makeAlerts(amount int) []Alert {
alerts := make([]Alert, amount)
for i := 0; i < len(alerts); i++ {
alerts[i].Labels = make(map[string]string)
lbls := make(map[string]string)
for label := 0; label < numLabels; label++ {
alerts[i].Labels[fmt.Sprintf("label_%d", label)] = fmt.Sprintf("label_%d_value_%d", label, i%100)
lbls[fmt.Sprintf("label_%d", label)] = fmt.Sprintf("label_%d_value_%d", label, i%100)
}
alerts[i].Labels = LabelsFromMap(lbls)
if i%100 < percentAlerting {
alerts[i].State = "alerting"