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/apps/dashboard/pkg/migration/schemaversion/v39.go

60 lines
1.4 KiB

package schemaversion
// V39 updates the configuration of the Timeseries to table transformation
// to support multiple options per query
func V39(dashboard map[string]interface{}) error {
dashboard["schemaVersion"] = int(39)
panels, ok := dashboard["panels"].([]interface{})
if !ok {
return nil
}
for _, panel := range panels {
p, ok := panel.(map[string]interface{})
if !ok {
continue
}
transformations, ok := p["transformations"].([]interface{})
if !ok {
continue
}
for _, transformation := range transformations {
t, ok := transformation.(map[string]interface{})
if !ok {
continue
}
// If we run into a timeSeriesTable transformation
// and it doesn't have undefined options then we migrate
if t["id"] != "timeSeriesTable" {
continue
}
options, ok := t["options"].(map[string]interface{})
if !ok {
continue
}
refIdStats, ok := options["refIdToStat"].(map[string]interface{})
if !ok {
continue
}
// For each {refIdtoStat} record which maps refId to a statistic
// we add that to the stat property of the new
// RefIdTransformerOptions interface which includes multiple settings
transformationOptions := make(map[string]interface{})
for refId, stat := range refIdStats {
transformationOptions[refId] = map[string]interface{}{"stat": stat}
}
// Update the options
t["options"] = transformationOptions
}
}
return nil
}