The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/queryhistory/queryhistory_details.go

36 lines
628 B

package queryhistory
import (
"encoding/json"
"slices"
"github.com/grafana/grafana/pkg/components/simplejson"
)
type DataQuery struct {
Datasource Datasource `json:"datasource"`
}
func FindDataSourceUIDs(queriesJSON *simplejson.Json) ([]string, error) {
uids := make([]string, 0)
queries := []DataQuery{}
bytes, err := queriesJSON.ToDB()
if err != nil {
return uids, err
}
err = json.Unmarshal(bytes, &queries)
if err != nil {
return uids, err
}
for _, query := range queries {
if !slices.Contains(uids, query.Datasource.UID) {
uids = append(uids, query.Datasource.UID)
}
}
return uids, nil
}