Annotations/Alerting: Add Loki historian store stub (#78363)

* Add Loki historian store stub

* Add composite store

* Use composite store if Loki historian enabled

* Split store interface into read/write

* Make composite + historian stores read only

* Use variadic constructor for composite

* Modify Loki store enable logic

* Use dskit.concurrency.ForEachJob for parallelism
This commit is contained in:
William Wernert
2023-12-12 17:43:09 -05:00
committed by GitHub
parent 09cef892a5
commit 62bdbe5b44
9 changed files with 486 additions and 14 deletions
+33
View File
@@ -44,6 +44,21 @@ type TagsDTO struct {
Count int64 `json:"count"`
}
// sort tags in ascending order by tag string
type SortedTags []*TagsDTO
func (s SortedTags) Len() int {
return len(s)
}
func (s SortedTags) Less(i, j int) bool {
return s[i].Tag < s[j].Tag
}
func (s SortedTags) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// FindTagsResult is the result of a tags search.
type FindTagsResult struct {
Tags []*TagsDTO `json:"tags"`
@@ -110,6 +125,24 @@ type ItemDTO struct {
Data *simplejson.Json `json:"data"`
}
type SortedItems []*ItemDTO
// sort annotations in descending order by end time, then by start time
func (s SortedItems) Len() int {
return len(s)
}
func (s SortedItems) Less(i, j int) bool {
if s[i].TimeEnd != s[j].TimeEnd {
return s[i].TimeEnd > s[j].TimeEnd
}
return s[i].Time > s[j].Time
}
func (s SortedItems) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
type annotationType int
const (