Dashboard Migrations: V34 CloudWatch Multi-Statistics Migration (#106656)

* wip: trying to understand how to get the ds info from migrator

* add datasource info provider

* Use DS service to fetch DS data

* add more tests cases to match with migrator cases

* Add snapshots

* Non-existing DS

* Add different DS for snapshots

* fix import

* Fix tests: guard against double initialization

* don't use full datasource package in test

* min version should be 35

* fix test

* fix conversion test

* Dashboards: Support schemaVersion v35 migration in backend

* Dashboards: Support schemaVersion v34 migration in backend

* Apply suggestions from code review

Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>

* Apply feedback

* Remove unused parameters

---------

Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com>
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
Ivan Ortega Alba
2025-06-19 07:03:14 +00:00
committed by GitHub
co-authored by Stephanie Hingtgen Todd Treece Haris Rozajac
parent 1264b5a619
commit 238cff5e8a
13 changed files with 5560 additions and 1 deletions
@@ -5,7 +5,7 @@ import (
)
const (
MIN_VERSION = 34
MIN_VERSION = 33
LATEST_VERSION = 41
)
@@ -26,6 +26,7 @@ type DataSourceInfoProvider interface {
func GetMigrations(dsInfoProvider DataSourceInfoProvider) map[int]SchemaVersionMigrationFunc {
return map[int]SchemaVersionMigrationFunc{
34: V34,
35: V35,
36: V36(dsInfoProvider),
37: V37,
@@ -0,0 +1,339 @@
package schemaversion
// V34 migrates CloudWatch queries that use multiple statistics into separate queries.
//
// This migration addresses CloudWatch queries where a single query uses multiple statistics
// (e.g., statistics: ['Max', 'Min']). The migration splits these into separate queries,
// each with a single statistic (e.g., one query with statistic: 'Max', another with statistic: 'Min').
//
// The migration works by:
// 1. Identifying CloudWatch queries in panel targets that have a 'statistics' array
// 2. Creating separate queries for each statistic in the array
// 3. Replacing the original 'statistics' array with a single 'statistic' field
// 4. Generating new refIds for additional queries (B, C, D, etc.)
// 5. Applying the same logic to CloudWatch annotation queries
// 6. Adding statistic suffixes to annotation names when multiple annotations are created
//
// Panel Query Example - Multiple Statistics:
//
// Before migration:
//
// target: {
// refId: "A",
// dimensions: {"InstanceId": "i-123"},
// namespace: "AWS/EC2",
// region: "us-east-1",
// metricName: "CPUUtilization",
// statistics: ["Average", "Maximum", "Minimum"]
// }
//
// After migration:
//
// targets: [
// { refId: "A", dimensions: {"InstanceId": "i-123"}, namespace: "AWS/EC2", region: "us-east-1", metricName: "CPUUtilization", statistic: "Average" },
// { refId: "B", dimensions: {"InstanceId": "i-123"}, namespace: "AWS/EC2", region: "us-east-1", metricName: "CPUUtilization", statistic: "Maximum" },
// { refId: "C", dimensions: {"InstanceId": "i-123"}, namespace: "AWS/EC2", region: "us-east-1", metricName: "CPUUtilization", statistic: "Minimum" }
// ]
//
// Annotation Query Example - Multiple Statistics:
// Before migration:
//
// annotation: {
// name: "CloudWatch Alerts",
// dimensions: {"InstanceId": "i-123"},
// namespace: "AWS/EC2",
// region: "us-east-1",
// prefixMatching: false,
// statistics: ["Maximum", "Minimum"]
// }
//
// After migration:
//
// annotations: [
// { name: "CloudWatch Alerts - Maximum", dimensions: {"InstanceId": "i-123"}, namespace: "AWS/EC2", region: "us-east-1", prefixMatching: false, statistic: "Maximum" },
// { name: "CloudWatch Alerts - Minimum", dimensions: {"InstanceId": "i-123"}, namespace: "AWS/EC2", region: "us-east-1", prefixMatching: false, statistic: "Minimum" }
// ]
func V34(dashboard map[string]interface{}) error {
dashboard["schemaVersion"] = int(34)
// Migrate panel queries if panels exist
panels, _ := dashboard["panels"].([]interface{})
for _, panel := range panels {
p, ok := panel.(map[string]interface{})
if !ok {
continue
}
migrateCloudWatchQueriesInPanel(p)
// Handle nested panels in collapsed rows
nestedPanels, hasNested := p["panels"].([]interface{})
if !hasNested {
continue
}
for _, nestedPanel := range nestedPanels {
np, ok := nestedPanel.(map[string]interface{})
if !ok {
continue
}
migrateCloudWatchQueriesInPanel(np)
}
}
// Always migrate annotation queries regardless of whether panels exist
migrateCloudWatchAnnotationQueries(dashboard)
return nil
}
// migrateCloudWatchQueriesInPanel migrates CloudWatch queries within a panel that use multiple statistics.
func migrateCloudWatchQueriesInPanel(panel map[string]interface{}) {
targets, ok := panel["targets"].([]interface{})
if !ok {
return
}
var newTargets []interface{}
var additionalTargets []interface{}
for _, target := range targets {
t, ok := target.(map[string]interface{})
if !ok {
newTargets = append(newTargets, target)
continue
}
if !isCloudWatchQuery(t) {
newTargets = append(newTargets, target)
continue
}
// Check if this query has multiple statistics
statistics, hasStatistics := t["statistics"].([]interface{})
if !hasStatistics || len(statistics) <= 1 {
// Convert single statistic or no statistics to proper format
if hasStatistics && len(statistics) == 1 {
if stat, ok := statistics[0].(string); ok {
t["statistic"] = stat
}
}
delete(t, "statistics")
newTargets = append(newTargets, t)
continue
}
// Split query with multiple statistics into separate queries
// First, collect all valid statistics
var validStatistics []string
for _, stat := range statistics {
statString, ok := stat.(string)
if !ok {
continue
}
validStatistics = append(validStatistics, statString)
}
// If no valid statistics found, remove statistics field and keep original query
if len(validStatistics) == 0 {
delete(t, "statistics")
newTargets = append(newTargets, t)
continue
}
// Create separate queries for each valid statistic
for i, statString := range validStatistics {
// Create a copy of the original query
newQuery := make(map[string]interface{})
for k, v := range t {
if k != "statistics" {
newQuery[k] = v
}
}
// Set the single statistic
newQuery["statistic"] = statString
if i == 0 {
// First query replaces the original
newTargets = append(newTargets, newQuery)
} else {
// Additional queries get new refIds and are added at the end
newQuery["refId"] = generateNextRefId(append(targets, additionalTargets...), len(additionalTargets))
additionalTargets = append(additionalTargets, newQuery)
}
}
}
// Append additional queries at the end
panel["targets"] = append(newTargets, additionalTargets...)
}
// migrateCloudWatchAnnotationQueries migrates CloudWatch annotation queries that use multiple statistics.
func migrateCloudWatchAnnotationQueries(dashboard map[string]interface{}) {
annotations, ok := dashboard["annotations"].(map[string]interface{})
if !ok {
return
}
annotationsList, ok := annotations["list"].([]interface{})
if !ok {
return
}
var additionalAnnotations []interface{}
for i, annotation := range annotationsList {
a, ok := annotation.(map[string]interface{})
if !ok {
continue
}
if !isLegacyCloudWatchAnnotationQuery(a) {
continue
}
// Check if this annotation has multiple statistics
statistics, hasStatistics := a["statistics"].([]interface{})
if !hasStatistics || len(statistics) <= 1 {
// Convert single statistic to proper format
if hasStatistics && len(statistics) == 1 {
if stat, ok := statistics[0].(string); ok {
// Create new annotation with single statistic
newAnnotation := make(map[string]interface{})
for k, v := range a {
if k != "statistics" {
newAnnotation[k] = v
}
}
newAnnotation["statistic"] = stat
annotationsList[i] = newAnnotation
}
} else {
// Always remove statistics field, even if empty or no statistics
newAnnotation := make(map[string]interface{})
for k, v := range a {
if k != "statistics" {
newAnnotation[k] = v
}
}
annotationsList[i] = newAnnotation
}
continue
}
// Split annotation with multiple statistics into separate annotations
// First, collect all valid statistics
var validStatistics []string
for _, stat := range statistics {
statString, ok := stat.(string)
if !ok {
continue
}
validStatistics = append(validStatistics, statString)
}
// If no valid statistics found, remove statistics field and keep original annotation
if len(validStatistics) == 0 {
// Create new annotation without statistics field
newAnnotation := make(map[string]interface{})
for k, v := range a {
if k != "statistics" {
newAnnotation[k] = v
}
}
annotationsList[i] = newAnnotation
continue
}
// Create new annotations for each valid statistic, replace original with first one
originalName, hasName := a["name"].(string)
for j, statString := range validStatistics {
// Create new annotation for this statistic
newAnnotation := make(map[string]interface{})
for k, v := range a {
if k != "statistics" {
newAnnotation[k] = v
}
}
// Set the single statistic
newAnnotation["statistic"] = statString
// Set the name with statistic suffix if multiple valid statistics
if len(validStatistics) > 1 && hasName {
newAnnotation["name"] = originalName + " - " + statString
}
if j == 0 {
// Replace the original annotation with the first new one
annotationsList[i] = newAnnotation
} else {
// Add additional annotations to be appended later
additionalAnnotations = append(additionalAnnotations, newAnnotation)
}
}
}
// Add additional annotations to the end of the list
if len(additionalAnnotations) > 0 {
annotations["list"] = append(annotationsList, additionalAnnotations...)
}
}
// isCloudWatchQuery checks if a query target is a CloudWatch query.
func isCloudWatchQuery(target map[string]interface{}) bool {
// Check for required CloudWatch query fields
_, hasDimensions := target["dimensions"]
_, hasNamespace := target["namespace"]
_, hasRegion := target["region"]
_, hasMetricName := target["metricName"]
return hasDimensions && hasNamespace && hasRegion && hasMetricName
}
// isLegacyCloudWatchAnnotationQuery checks if an annotation is a legacy CloudWatch annotation query.
func isLegacyCloudWatchAnnotationQuery(annotation map[string]interface{}) bool {
// Check for required CloudWatch annotation fields
_, hasDimensions := annotation["dimensions"]
_, hasNamespace := annotation["namespace"]
_, hasRegion := annotation["region"]
_, hasPrefixMatching := annotation["prefixMatching"]
_, hasStatistics := annotation["statistics"]
return hasDimensions && hasNamespace && hasRegion && hasPrefixMatching && hasStatistics
}
// generateNextRefId generates a new refId for additional queries created during migration.
func generateNextRefId(allTargets []interface{}, additionalIndex int) string {
// Collect all existing refIds
used := make(map[string]bool)
for _, target := range allTargets {
if t, ok := target.(map[string]interface{}); ok {
if refId, ok := t["refId"].(string); ok && refId != "" {
used[refId] = true
}
}
}
// Generate next available refId starting from A
for c := 'A'; c <= 'Z'; c++ {
candidate := string(c)
if !used[candidate] {
return candidate
}
}
// If all single letters are taken, use double letters
for c1 := 'A'; c1 <= 'Z'; c1++ {
for c2 := 'A'; c2 <= 'Z'; c2++ {
candidate := string(c1) + string(c2)
if !used[candidate] {
return candidate
}
}
}
// Fallback (should never happen in practice)
return "X" + string(rune('0'+additionalIndex))
}
@@ -0,0 +1,714 @@
package schemaversion_test
import (
"testing"
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
)
func TestV34(t *testing.T) {
tests := []migrationTestCase{
{
name: "splits CloudWatch query with multiple statistics into separate queries",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"type": "timeseries",
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistics": []interface{}{"Average", "Maximum", "Minimum"},
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"type": "timeseries",
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Average",
},
map[string]interface{}{
"refId": "B",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Maximum",
},
map[string]interface{}{
"refId": "C",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Minimum",
},
},
},
},
},
},
{
name: "converts single statistic array to statistic field",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistics": []interface{}{"Average"},
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Average",
},
},
},
},
},
},
{
name: "does not migrate non-CloudWatch queries",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"expr": "up",
"datasource": "prometheus",
"statistics": []interface{}{"Average", "Maximum"},
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"expr": "up",
"datasource": "prometheus",
"statistics": []interface{}{"Average", "Maximum"},
},
},
},
},
},
},
{
name: "migrates CloudWatch annotation queries with multiple statistics",
input: map[string]interface{}{
"annotations": map[string]interface{}{
"list": []interface{}{
map[string]interface{}{
"name": "CloudWatch Annotation",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistics": []interface{}{"Minimum", "Sum"},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"annotations": map[string]interface{}{
"list": []interface{}{
map[string]interface{}{
"name": "CloudWatch Annotation - Minimum",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistic": "Minimum",
},
map[string]interface{}{
"name": "CloudWatch Annotation - Sum",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistic": "Sum",
},
},
},
},
},
{
name: "handles invalid statistics in CloudWatch annotation queries",
input: map[string]interface{}{
"annotations": map[string]interface{}{
"list": []interface{}{
map[string]interface{}{
"name": "CloudWatch Annotation",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistics": []interface{}{123, "Sum", nil},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"annotations": map[string]interface{}{
"list": []interface{}{
map[string]interface{}{
"name": "CloudWatch Annotation",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistic": "Sum",
},
},
},
},
},
{
name: "handles multiple valid statistics mixed with invalid ones in annotation",
input: map[string]interface{}{
"annotations": map[string]interface{}{
"list": []interface{}{
map[string]interface{}{
"name": "CloudWatch Annotation",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistics": []interface{}{123, "Sum", nil, "Average"},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"annotations": map[string]interface{}{
"list": []interface{}{
map[string]interface{}{
"name": "CloudWatch Annotation - Sum",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistic": "Sum",
},
map[string]interface{}{
"name": "CloudWatch Annotation - Average",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistic": "Average",
},
},
},
},
},
{
name: "handles CloudWatch annotation with all invalid statistics",
input: map[string]interface{}{
"annotations": map[string]interface{}{
"list": []interface{}{
map[string]interface{}{
"name": "CloudWatch Annotation",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistics": []interface{}{123, nil, map[string]interface{}{"invalid": "value"}},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"annotations": map[string]interface{}{
"list": []interface{}{
map[string]interface{}{
"name": "CloudWatch Annotation",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
},
},
},
},
},
{
name: "handles mixed query types in same panel",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistics": []interface{}{"Average", "Maximum"},
},
map[string]interface{}{
"refId": "B",
"expr": "up",
"datasource": "prometheus",
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Average",
},
map[string]interface{}{
"refId": "B",
"expr": "up",
"datasource": "prometheus",
},
map[string]interface{}{
"refId": "C",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Maximum",
},
},
},
},
},
},
{
name: "handles CloudWatch query without statistics field",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
},
},
},
},
},
},
{
name: "handles missing targets gracefully",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"type": "timeseries",
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"type": "timeseries",
},
},
},
},
{
name: "handles missing annotations gracefully",
input: map[string]interface{}{
"panels": []interface{}{},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{},
},
},
{
name: "handles empty statistics array",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistics": []interface{}{},
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
},
},
},
},
},
},
{
name: "handles invalid statistics values gracefully",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistics": []interface{}{123, nil, "Average", map[string]interface{}{"invalid": "value"}},
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Average",
},
},
},
},
},
},
{
name: "handles CloudWatch query with all invalid statistics",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistics": []interface{}{123, nil, map[string]interface{}{"invalid": "value"}},
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
},
},
},
},
},
},
{
name: "preserves other query properties during migration",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistics": []interface{}{"Average", "Maximum"},
"period": "300",
"alias": "CPU Usage",
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"id": 1,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Average",
"period": "300",
"alias": "CPU Usage",
},
map[string]interface{}{
"refId": "B",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistic": "Maximum",
"period": "300",
"alias": "CPU Usage",
},
},
},
},
},
},
{
name: "migrates CloudWatch queries in nested panels (collapsed rows)",
input: map[string]interface{}{
"panels": []interface{}{
map[string]interface{}{
"collapsed": true,
"gridPos": map[string]interface{}{
"h": 1,
"w": 24,
"x": 0,
"y": 89,
},
"id": 96,
"title": "DynamoDB",
"type": "row",
"panels": []interface{}{
map[string]interface{}{
"gridPos": map[string]interface{}{
"h": 8,
"w": 12,
"x": 0,
"y": 0,
},
"id": 4,
"targets": []interface{}{
map[string]interface{}{
"refId": "C",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "default",
"metricName": "CPUUtilization",
"statistics": []interface{}{"Average", "Minimum", "p12.21"},
},
map[string]interface{}{
"refId": "B",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-2",
"metricName": "CPUUtilization",
"statistics": []interface{}{"Sum"},
},
},
},
map[string]interface{}{
"id": 5,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-456"},
"namespace": "AWS/EC2",
"region": "us-west-1",
"metricName": "NetworkIn",
"statistics": []interface{}{"Sum", "Min"},
},
},
},
},
},
},
},
expected: map[string]interface{}{
"schemaVersion": int(34),
"panels": []interface{}{
map[string]interface{}{
"collapsed": true,
"gridPos": map[string]interface{}{
"h": 1,
"w": 24,
"x": 0,
"y": 89,
},
"id": 96,
"title": "DynamoDB",
"type": "row",
"panels": []interface{}{
map[string]interface{}{
"gridPos": map[string]interface{}{
"h": 8,
"w": 12,
"x": 0,
"y": 0,
},
"id": 4,
"targets": []interface{}{
map[string]interface{}{
"refId": "C",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "default",
"metricName": "CPUUtilization",
"statistic": "Average",
},
map[string]interface{}{
"refId": "B",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "us-east-2",
"metricName": "CPUUtilization",
"statistic": "Sum",
},
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "default",
"metricName": "CPUUtilization",
"statistic": "Minimum",
},
map[string]interface{}{
"refId": "D",
"dimensions": map[string]interface{}{"InstanceId": "i-123"},
"namespace": "AWS/EC2",
"region": "default",
"metricName": "CPUUtilization",
"statistic": "p12.21",
},
},
},
map[string]interface{}{
"id": 5,
"targets": []interface{}{
map[string]interface{}{
"refId": "A",
"dimensions": map[string]interface{}{"InstanceId": "i-456"},
"namespace": "AWS/EC2",
"region": "us-west-1",
"metricName": "NetworkIn",
"statistic": "Sum",
},
map[string]interface{}{
"refId": "B",
"dimensions": map[string]interface{}{"InstanceId": "i-456"},
"namespace": "AWS/EC2",
"region": "us-west-1",
"metricName": "NetworkIn",
"statistic": "Min",
},
},
},
},
},
},
},
},
}
runMigrationTests(t, tests, schemaversion.V34)
}
@@ -0,0 +1,375 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": "Non Default Test Datasource",
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": "non-default-test-ds-uid",
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": "default",
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": "non-existing-ds",
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"name": "CloudWatch Annotation Single Stat",
"enable": true,
"iconColor": "red",
"dimensions": {
"InstanceId": "i-123456"
},
"namespace": "AWS/EC2",
"region": "us-east-1",
"prefixMatching": false,
"statistics": ["Average"]
},
{
"name": "CloudWatch Annotation Multiple Stats",
"enable": true,
"iconColor": "blue",
"dimensions": {
"InstanceId": "i-789012"
},
"namespace": "AWS/RDS",
"region": "us-west-2",
"prefixMatching": false,
"statistics": ["Maximum", "Minimum", "Sum"]
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"type": "graph",
"options": {},
"title": "No Legend Config",
"id": 1,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
}
},
{
"options": {
"legend": true
},
"title": "Boolean Legend True",
"id": 2,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
}
},
{
"options": {
"legend": false
},
"title": "Boolean Legend False",
"id": 3,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
}
},
{
"options": {
"legend": {
"displayMode": "hidden"
}
},
"title": "Hidden DisplayMode",
"id": 4,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
}
},
{
"options": {
"legend": {
"showLegend": false
}
},
"title": "ShowLegend False",
"id": 5,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
}
},
{
"options": {
"legend": {
"displayMode": "table"
}
},
"title": "Visible Legend",
"id": 6,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
}
},
{
"datasource": "default",
"title": "Mixed Datasources Panel",
"id": 7,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"targets": [
{
"datasource": "non-default-test-ds-uid"
},
{
"datasource": "Non Default Test Datasource"
}
]
},
{
"datasource": {
"uid": "-- Mixed --"
},
"title": "Mixed Panel with Mixed Targets",
"id": 8,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"targets": [
{
"datasource": "non-default-test-ds-uid"
},
{
"datasource": "Non Default Test Datasource"
}
]
},
{
"datasource": "non-existing-ds",
"title": "Non-existing Datasource Panel",
"id": 9,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"targets": [
{
"datasource": "non-existing-ds"
}
]
},
{
"type": "timeseries",
"title": "Timeseries Panel with Hidden Axes",
"id": 10,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": []
}
},
{
"type": "timeseries",
"title": "CloudWatch Single Query Multiple Stats",
"id": 11,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"targets": [
{
"refId": "A",
"dimensions": {
"InstanceId": "i-123456"
},
"namespace": "AWS/EC2",
"region": "us-east-1",
"metricName": "CPUUtilization",
"statistics": ["Average", "Maximum", "Minimum"],
"period": "300",
"alias": "CPU Usage"
}
]
},
{
"type": "timeseries",
"title": "Mixed CloudWatch and Prometheus Queries",
"id": 12,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"targets": [
{
"refId": "A",
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"namespace": "AWS/ApplicationELB",
"region": "us-west-2",
"metricName": "RequestCount",
"statistics": ["Sum", "Average"]
},
{
"refId": "B",
"expr": "up",
"datasource": "prometheus"
},
{
"refId": "C",
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"namespace": "AWS/RDS",
"region": "us-east-1",
"metricName": "DatabaseConnections",
"statistics": ["Maximum"]
}
]
},
{
"type": "row",
"collapsed": true,
"title": "Collapsed Row with CloudWatch",
"id": 13,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"panels": [
{
"type": "timeseries",
"title": "Nested CloudWatch Panel",
"id": 14,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"targets": [
{
"refId": "A",
"dimensions": {
"QueueName": "my-queue"
},
"namespace": "AWS/SQS",
"region": "us-east-1",
"metricName": "ApproximateNumberOfMessages",
"statistics": ["Average", "Maximum", "Sum"]
}
]
}
]
}
],
"preload": false,
"refresh": true,
"schemaVersion": 33,
"tags": [],
"templating": {
"list": [
{
"type": "query",
"datasource": "default",
"name": "default_var"
},
{
"type": "query",
"datasource": "Non Default Test Datasource",
"name": "es_var_by_name"
},
{
"type": "query",
"datasource": "non-default-test-ds-uid",
"name": "es_var_by_uid"
},
{
"type": "query",
"datasource": null,
"name": "null_var"
},
{
"type": "query",
"datasource": "non-existing-ds",
"name": "non_existing_var"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"]
},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -0,0 +1,462 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": "Non Default Test Datasource",
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": "non-default-test-ds-uid",
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": "default",
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": "non-existing-ds",
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"dimensions": {
"InstanceId": "i-123456"
},
"enable": true,
"iconColor": "red",
"name": "CloudWatch Annotation Single Stat",
"namespace": "AWS/EC2",
"prefixMatching": false,
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Maximum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Maximum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Minimum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Minimum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Sum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Sum"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {},
"title": "No Legend Config",
"type": "graph"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": true
},
"title": "Boolean Legend True"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": false
},
"title": "Boolean Legend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"displayMode": "hidden"
}
},
"title": "Hidden DisplayMode"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"showLegend": false
}
},
"title": "ShowLegend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"displayMode": "table"
}
},
"title": "Visible Legend"
},
{
"datasource": "default",
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 7,
"targets": [
{
"datasource": "non-default-test-ds-uid"
},
{
"datasource": "Non Default Test Datasource"
}
],
"title": "Mixed Datasources Panel"
},
{
"datasource": {
"uid": "-- Mixed --"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 8,
"targets": [
{
"datasource": "non-default-test-ds-uid"
},
{
"datasource": "Non Default Test Datasource"
}
],
"title": "Mixed Panel with Mixed Targets"
},
{
"datasource": "non-existing-ds",
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"id": 9,
"targets": [
{
"datasource": "non-existing-ds"
}
],
"title": "Non-existing Datasource Panel"
},
{
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 10,
"title": "Timeseries Panel with Hidden Axes",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 11,
"targets": [
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "C",
"region": "us-east-1",
"statistic": "Minimum"
}
],
"title": "CloudWatch Single Query Multiple Stats",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"id": 12,
"targets": [
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "A",
"region": "us-west-2",
"statistic": "Sum"
},
{
"datasource": "prometheus",
"expr": "up",
"refId": "B"
},
{
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"metricName": "DatabaseConnections",
"namespace": "AWS/RDS",
"refId": "C",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "D",
"region": "us-west-2",
"statistic": "Average"
}
],
"title": "Mixed CloudWatch and Prometheus Queries",
"type": "timeseries"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"id": 13,
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 14,
"targets": [
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "C",
"region": "us-east-1",
"statistic": "Sum"
}
],
"title": "Nested CloudWatch Panel",
"type": "timeseries"
}
],
"title": "Collapsed Row with CloudWatch",
"type": "row"
}
],
"preload": false,
"refresh": true,
"schemaVersion": 34,
"tags": [],
"templating": {
"list": [
{
"datasource": "default",
"name": "default_var",
"type": "query"
},
{
"datasource": "Non Default Test Datasource",
"name": "es_var_by_name",
"type": "query"
},
{
"datasource": "non-default-test-ds-uid",
"name": "es_var_by_uid",
"type": "query"
},
{
"datasource": null,
"name": "null_var",
"type": "query"
},
{
"datasource": "non-existing-ds",
"name": "non_existing_var",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -0,0 +1,475 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": "Non Default Test Datasource",
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": "non-default-test-ds-uid",
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": "default",
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": "non-existing-ds",
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"dimensions": {
"InstanceId": "i-123456"
},
"enable": true,
"iconColor": "red",
"name": "CloudWatch Annotation Single Stat",
"namespace": "AWS/EC2",
"prefixMatching": false,
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Maximum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Maximum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Minimum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Minimum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Sum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Sum"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {},
"title": "No Legend Config",
"type": "graph"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": true
},
"title": "Boolean Legend True"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": false
},
"title": "Boolean Legend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"displayMode": "hidden"
}
},
"title": "Hidden DisplayMode"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"showLegend": false
}
},
"title": "ShowLegend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"displayMode": "table"
}
},
"title": "Visible Legend"
},
{
"datasource": "default",
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 7,
"targets": [
{
"datasource": "non-default-test-ds-uid"
},
{
"datasource": "Non Default Test Datasource"
}
],
"title": "Mixed Datasources Panel"
},
{
"datasource": {
"uid": "-- Mixed --"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 8,
"targets": [
{
"datasource": "non-default-test-ds-uid"
},
{
"datasource": "Non Default Test Datasource"
}
],
"title": "Mixed Panel with Mixed Targets"
},
{
"datasource": "non-existing-ds",
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"id": 9,
"targets": [
{
"datasource": "non-existing-ds"
}
],
"title": "Non-existing Datasource Panel"
},
{
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": [
{
"matcher": {
"id": "byType",
"options": "time"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "auto"
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 10,
"title": "Timeseries Panel with Hidden Axes",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 11,
"targets": [
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "C",
"region": "us-east-1",
"statistic": "Minimum"
}
],
"title": "CloudWatch Single Query Multiple Stats",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"id": 12,
"targets": [
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "A",
"region": "us-west-2",
"statistic": "Sum"
},
{
"datasource": "prometheus",
"expr": "up",
"refId": "B"
},
{
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"metricName": "DatabaseConnections",
"namespace": "AWS/RDS",
"refId": "C",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "D",
"region": "us-west-2",
"statistic": "Average"
}
],
"title": "Mixed CloudWatch and Prometheus Queries",
"type": "timeseries"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"id": 13,
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 14,
"targets": [
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "C",
"region": "us-east-1",
"statistic": "Sum"
}
],
"title": "Nested CloudWatch Panel",
"type": "timeseries"
}
],
"title": "Collapsed Row with CloudWatch",
"type": "row"
}
],
"preload": false,
"refresh": true,
"schemaVersion": 35,
"tags": [],
"templating": {
"list": [
{
"datasource": "default",
"name": "default_var",
"type": "query"
},
{
"datasource": "Non Default Test Datasource",
"name": "es_var_by_name",
"type": "query"
},
{
"datasource": "non-default-test-ds-uid",
"name": "es_var_by_uid",
"type": "query"
},
{
"datasource": null,
"name": "null_var",
"type": "query"
},
{
"datasource": "non-existing-ds",
"name": "non_existing_var",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -0,0 +1,526 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"dimensions": {
"InstanceId": "i-123456"
},
"enable": true,
"iconColor": "red",
"name": "CloudWatch Annotation Single Stat",
"namespace": "AWS/EC2",
"prefixMatching": false,
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Maximum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Maximum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Minimum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Minimum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Sum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Sum"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {},
"title": "No Legend Config",
"type": "graph"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": true
},
"title": "Boolean Legend True"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": false
},
"title": "Boolean Legend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"displayMode": "hidden"
}
},
"title": "Hidden DisplayMode"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"showLegend": false
}
},
"title": "ShowLegend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"displayMode": "table"
}
},
"title": "Visible Legend"
},
{
"datasource": null,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 7,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Datasources Panel"
},
{
"datasource": {
"uid": "-- Mixed --"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 8,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Panel with Mixed Targets"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"id": 9,
"targets": [
{
"datasource": {
"uid": "non-existing-ds"
}
}
],
"title": "Non-existing Datasource Panel"
},
{
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": [
{
"matcher": {
"id": "byType",
"options": "time"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "auto"
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 10,
"title": "Timeseries Panel with Hidden Axes",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 11,
"targets": [
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "C",
"region": "us-east-1",
"statistic": "Minimum"
}
],
"title": "CloudWatch Single Query Multiple Stats",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"id": 12,
"targets": [
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "A",
"region": "us-west-2",
"statistic": "Sum"
},
{
"datasource": {
"uid": "prometheus"
},
"expr": "up",
"refId": "B"
},
{
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"metricName": "DatabaseConnections",
"namespace": "AWS/RDS",
"refId": "C",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "D",
"region": "us-west-2",
"statistic": "Average"
}
],
"title": "Mixed CloudWatch and Prometheus Queries",
"type": "timeseries"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"id": 13,
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 14,
"targets": [
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "C",
"region": "us-east-1",
"statistic": "Sum"
}
],
"title": "Nested CloudWatch Panel",
"type": "timeseries"
}
],
"title": "Collapsed Row with CloudWatch",
"type": "row"
}
],
"preload": false,
"refresh": true,
"schemaVersion": 36,
"tags": [],
"templating": {
"list": [
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "default_var",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_name",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_uid",
"type": "query"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "null_var",
"type": "query"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"name": "non_existing_var",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -0,0 +1,535 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"dimensions": {
"InstanceId": "i-123456"
},
"enable": true,
"iconColor": "red",
"name": "CloudWatch Annotation Single Stat",
"namespace": "AWS/EC2",
"prefixMatching": false,
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Maximum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Maximum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Minimum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Minimum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Sum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Sum"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {},
"title": "No Legend Config",
"type": "graph"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": {
"displayMode": "list",
"showLegend": true
}
},
"title": "Boolean Legend True"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Boolean Legend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Hidden DisplayMode"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "ShowLegend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"displayMode": "table",
"showLegend": true
}
},
"title": "Visible Legend"
},
{
"datasource": null,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 7,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Datasources Panel"
},
{
"datasource": {
"uid": "-- Mixed --"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 8,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Panel with Mixed Targets"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"id": 9,
"targets": [
{
"datasource": {
"uid": "non-existing-ds"
}
}
],
"title": "Non-existing Datasource Panel"
},
{
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": [
{
"matcher": {
"id": "byType",
"options": "time"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "auto"
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 10,
"title": "Timeseries Panel with Hidden Axes",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 11,
"targets": [
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "C",
"region": "us-east-1",
"statistic": "Minimum"
}
],
"title": "CloudWatch Single Query Multiple Stats",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"id": 12,
"targets": [
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "A",
"region": "us-west-2",
"statistic": "Sum"
},
{
"datasource": {
"uid": "prometheus"
},
"expr": "up",
"refId": "B"
},
{
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"metricName": "DatabaseConnections",
"namespace": "AWS/RDS",
"refId": "C",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "D",
"region": "us-west-2",
"statistic": "Average"
}
],
"title": "Mixed CloudWatch and Prometheus Queries",
"type": "timeseries"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"id": 13,
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 14,
"targets": [
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "C",
"region": "us-east-1",
"statistic": "Sum"
}
],
"title": "Nested CloudWatch Panel",
"type": "timeseries"
}
],
"title": "Collapsed Row with CloudWatch",
"type": "row"
}
],
"preload": false,
"refresh": true,
"schemaVersion": 37,
"tags": [],
"templating": {
"list": [
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "default_var",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_name",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_uid",
"type": "query"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "null_var",
"type": "query"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"name": "non_existing_var",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -0,0 +1,535 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"dimensions": {
"InstanceId": "i-123456"
},
"enable": true,
"iconColor": "red",
"name": "CloudWatch Annotation Single Stat",
"namespace": "AWS/EC2",
"prefixMatching": false,
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Maximum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Maximum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Minimum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Minimum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Sum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Sum"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {},
"title": "No Legend Config",
"type": "graph"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": {
"displayMode": "list",
"showLegend": true
}
},
"title": "Boolean Legend True"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Boolean Legend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Hidden DisplayMode"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "ShowLegend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"displayMode": "table",
"showLegend": true
}
},
"title": "Visible Legend"
},
{
"datasource": null,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 7,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Datasources Panel"
},
{
"datasource": {
"uid": "-- Mixed --"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 8,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Panel with Mixed Targets"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"id": 9,
"targets": [
{
"datasource": {
"uid": "non-existing-ds"
}
}
],
"title": "Non-existing Datasource Panel"
},
{
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": [
{
"matcher": {
"id": "byType",
"options": "time"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "auto"
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 10,
"title": "Timeseries Panel with Hidden Axes",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 11,
"targets": [
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "C",
"region": "us-east-1",
"statistic": "Minimum"
}
],
"title": "CloudWatch Single Query Multiple Stats",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"id": 12,
"targets": [
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "A",
"region": "us-west-2",
"statistic": "Sum"
},
{
"datasource": {
"uid": "prometheus"
},
"expr": "up",
"refId": "B"
},
{
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"metricName": "DatabaseConnections",
"namespace": "AWS/RDS",
"refId": "C",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "D",
"region": "us-west-2",
"statistic": "Average"
}
],
"title": "Mixed CloudWatch and Prometheus Queries",
"type": "timeseries"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"id": 13,
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 14,
"targets": [
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "C",
"region": "us-east-1",
"statistic": "Sum"
}
],
"title": "Nested CloudWatch Panel",
"type": "timeseries"
}
],
"title": "Collapsed Row with CloudWatch",
"type": "row"
}
],
"preload": false,
"refresh": true,
"schemaVersion": 38,
"tags": [],
"templating": {
"list": [
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "default_var",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_name",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_uid",
"type": "query"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "null_var",
"type": "query"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"name": "non_existing_var",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -0,0 +1,535 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"dimensions": {
"InstanceId": "i-123456"
},
"enable": true,
"iconColor": "red",
"name": "CloudWatch Annotation Single Stat",
"namespace": "AWS/EC2",
"prefixMatching": false,
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Maximum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Maximum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Minimum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Minimum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Sum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Sum"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {},
"title": "No Legend Config",
"type": "graph"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": {
"displayMode": "list",
"showLegend": true
}
},
"title": "Boolean Legend True"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Boolean Legend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Hidden DisplayMode"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "ShowLegend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"displayMode": "table",
"showLegend": true
}
},
"title": "Visible Legend"
},
{
"datasource": null,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 7,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Datasources Panel"
},
{
"datasource": {
"uid": "-- Mixed --"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 8,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Panel with Mixed Targets"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"id": 9,
"targets": [
{
"datasource": {
"uid": "non-existing-ds"
}
}
],
"title": "Non-existing Datasource Panel"
},
{
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": [
{
"matcher": {
"id": "byType",
"options": "time"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "auto"
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 10,
"title": "Timeseries Panel with Hidden Axes",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 11,
"targets": [
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "C",
"region": "us-east-1",
"statistic": "Minimum"
}
],
"title": "CloudWatch Single Query Multiple Stats",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"id": 12,
"targets": [
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "A",
"region": "us-west-2",
"statistic": "Sum"
},
{
"datasource": {
"uid": "prometheus"
},
"expr": "up",
"refId": "B"
},
{
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"metricName": "DatabaseConnections",
"namespace": "AWS/RDS",
"refId": "C",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "D",
"region": "us-west-2",
"statistic": "Average"
}
],
"title": "Mixed CloudWatch and Prometheus Queries",
"type": "timeseries"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"id": 13,
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 14,
"targets": [
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "C",
"region": "us-east-1",
"statistic": "Sum"
}
],
"title": "Nested CloudWatch Panel",
"type": "timeseries"
}
],
"title": "Collapsed Row with CloudWatch",
"type": "row"
}
],
"preload": false,
"refresh": true,
"schemaVersion": 39,
"tags": [],
"templating": {
"list": [
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "default_var",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_name",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_uid",
"type": "query"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "null_var",
"type": "query"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"name": "non_existing_var",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -0,0 +1,535 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"dimensions": {
"InstanceId": "i-123456"
},
"enable": true,
"iconColor": "red",
"name": "CloudWatch Annotation Single Stat",
"namespace": "AWS/EC2",
"prefixMatching": false,
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Maximum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Maximum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Minimum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Minimum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Sum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Sum"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {},
"title": "No Legend Config",
"type": "graph"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": {
"displayMode": "list",
"showLegend": true
}
},
"title": "Boolean Legend True"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Boolean Legend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Hidden DisplayMode"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "ShowLegend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"displayMode": "table",
"showLegend": true
}
},
"title": "Visible Legend"
},
{
"datasource": null,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 7,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Datasources Panel"
},
{
"datasource": {
"uid": "-- Mixed --"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 8,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Panel with Mixed Targets"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"id": 9,
"targets": [
{
"datasource": {
"uid": "non-existing-ds"
}
}
],
"title": "Non-existing Datasource Panel"
},
{
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": [
{
"matcher": {
"id": "byType",
"options": "time"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "auto"
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 10,
"title": "Timeseries Panel with Hidden Axes",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 11,
"targets": [
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "C",
"region": "us-east-1",
"statistic": "Minimum"
}
],
"title": "CloudWatch Single Query Multiple Stats",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"id": 12,
"targets": [
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "A",
"region": "us-west-2",
"statistic": "Sum"
},
{
"datasource": {
"uid": "prometheus"
},
"expr": "up",
"refId": "B"
},
{
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"metricName": "DatabaseConnections",
"namespace": "AWS/RDS",
"refId": "C",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "D",
"region": "us-west-2",
"statistic": "Average"
}
],
"title": "Mixed CloudWatch and Prometheus Queries",
"type": "timeseries"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"id": 13,
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 14,
"targets": [
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "C",
"region": "us-east-1",
"statistic": "Sum"
}
],
"title": "Nested CloudWatch Panel",
"type": "timeseries"
}
],
"title": "Collapsed Row with CloudWatch",
"type": "row"
}
],
"preload": false,
"refresh": "",
"schemaVersion": 40,
"tags": [],
"templating": {
"list": [
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "default_var",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_name",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_uid",
"type": "query"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "null_var",
"type": "query"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"name": "non_existing_var",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -0,0 +1,523 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations \u0026 Alerts",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by Name",
"type": "dashboard"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"enable": true,
"name": "Test Annotation by UID",
"type": "dashboard"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"enable": true,
"name": "Test Default Annotation",
"type": "dashboard"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"enable": true,
"name": "Test Non-existing Annotation",
"type": "dashboard"
},
{
"dimensions": {
"InstanceId": "i-123456"
},
"enable": true,
"iconColor": "red",
"name": "CloudWatch Annotation Single Stat",
"namespace": "AWS/EC2",
"prefixMatching": false,
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Maximum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Maximum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Minimum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Minimum"
},
{
"dimensions": {
"InstanceId": "i-789012"
},
"enable": true,
"iconColor": "blue",
"name": "CloudWatch Annotation Multiple Stats - Sum",
"namespace": "AWS/RDS",
"prefixMatching": false,
"region": "us-west-2",
"statistic": "Sum"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {},
"title": "No Legend Config",
"type": "graph"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"legend": {
"displayMode": "list",
"showLegend": true
}
},
"title": "Boolean Legend True"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Boolean Legend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "Hidden DisplayMode"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"displayMode": "list",
"showLegend": false
}
},
"title": "ShowLegend False"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 6,
"options": {
"legend": {
"displayMode": "table",
"showLegend": true
}
},
"title": "Visible Legend"
},
{
"datasource": null,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 7,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Datasources Panel"
},
{
"datasource": {
"uid": "-- Mixed --"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 8,
"targets": [
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
}
}
],
"title": "Mixed Panel with Mixed Targets"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 32
},
"id": 9,
"targets": [
{
"datasource": {
"uid": "non-existing-ds"
}
}
],
"title": "Non-existing Datasource Panel"
},
{
"fieldConfig": {
"defaults": {
"custom": {
"axisPlacement": "hidden"
}
},
"overrides": [
{
"matcher": {
"id": "byType",
"options": "time"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "auto"
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 40
},
"id": 10,
"title": "Timeseries Panel with Hidden Axes",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 40
},
"id": 11,
"targets": [
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"alias": "CPU Usage",
"dimensions": {
"InstanceId": "i-123456"
},
"metricName": "CPUUtilization",
"namespace": "AWS/EC2",
"period": "300",
"refId": "C",
"region": "us-east-1",
"statistic": "Minimum"
}
],
"title": "CloudWatch Single Query Multiple Stats",
"type": "timeseries"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 48
},
"id": 12,
"targets": [
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "A",
"region": "us-west-2",
"statistic": "Sum"
},
{
"datasource": {
"uid": "prometheus"
},
"expr": "up",
"refId": "B"
},
{
"dimensions": {
"DBInstanceIdentifier": "my-db"
},
"metricName": "DatabaseConnections",
"namespace": "AWS/RDS",
"refId": "C",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"LoadBalancer": "my-load-balancer"
},
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"refId": "D",
"region": "us-west-2",
"statistic": "Average"
}
],
"title": "Mixed CloudWatch and Prometheus Queries",
"type": "timeseries"
},
{
"collapsed": true,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 56
},
"id": 13,
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 14,
"targets": [
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "A",
"region": "us-east-1",
"statistic": "Average"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "B",
"region": "us-east-1",
"statistic": "Maximum"
},
{
"dimensions": {
"QueueName": "my-queue"
},
"metricName": "ApproximateNumberOfMessages",
"namespace": "AWS/SQS",
"refId": "C",
"region": "us-east-1",
"statistic": "Sum"
}
],
"title": "Nested CloudWatch Panel",
"type": "timeseries"
}
],
"title": "Collapsed Row with CloudWatch",
"type": "row"
}
],
"preload": false,
"refresh": "",
"schemaVersion": 41,
"tags": [],
"templating": {
"list": [
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "default_var",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_name",
"type": "query"
},
{
"datasource": {
"apiVersion": "1",
"type": "loki",
"uid": "non-default-test-ds-uid"
},
"name": "es_var_by_uid",
"type": "query"
},
{
"datasource": {
"type": "prometheus",
"uid": "default-ds-uid"
},
"name": "null_var",
"type": "query"
},
{
"datasource": {
"uid": "non-existing-ds"
},
"name": "non_existing_var",
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "utc",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
@@ -988,6 +988,10 @@ export class DashboardMigrator {
}
}
// Migrates CloudWatch annotation queries that use multiple statistics into separate queries.
// For example, if an annotation query uses ['Max', 'Min'] statistics, it will be split into
// two separate annotation queries - one with 'Max' and another with 'Min'.
// The new annotation queries are added to the end of the annotations list.
migrateCloudWatchAnnotationQuery() {
for (const annotation of this.dashboard.annotations.list) {
if (isLegacyCloudWatchAnnotationQuery(annotation)) {