[v11.0.x] Alerting/Annotations: Return nothing from historian store if filtering by tags (#88140)

Alerting/Annotations: Return nothing from historian store if filtering by tags and matchAny is false (#85488)

* Return nothing from historian store if filtering by tag

(cherry picked from commit cad8190a91)

Co-authored-by: William Wernert <william.wernert@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-05-21 19:33:31 +03:00
committed by GitHub
co-authored by William Wernert
parent b6acbcbcd7
commit 0f10658901
2 changed files with 33 additions and 1 deletions
@@ -78,6 +78,12 @@ func (r *LokiHistorianStore) Get(ctx context.Context, query *annotations.ItemQue
return make([]*annotations.ItemDTO, 0), nil
}
// if the query is filtering on tags, but not on a specific dashboard, we shouldn't query loki
// since state history won't have tags for annotations
if len(query.Tags) > 0 && query.DashboardID == 0 && query.DashboardUID == "" {
return make([]*annotations.ItemDTO, 0), nil
}
rule := &ngmodels.AlertRule{}
if query.AlertID != 0 {
var err error
@@ -173,7 +179,7 @@ func (r *LokiHistorianStore) annotationsFromStream(stream historian.Stream, ac a
}
func (r *LokiHistorianStore) GetTags(ctx context.Context, query *annotations.TagsQuery) (annotations.FindTagsResult, error) {
return annotations.FindTagsResult{}, nil
return annotations.FindTagsResult{Tags: []*annotations.TagsDTO{}}, nil
}
// util