-
Expected BehaviorI would like to be able to define a Grafana variable with a CloudWatch datasource in my Jsonnet code. The expected JSON output for the variable should look like this: {
"current": {
"selected": false,
"text": "app/alb-name123123",
"value": "app/alb-name123123"
},
"datasource": {
"type": "cloudwatch",
"uid": "cloudwatch-ds"
},
"definition": "",
"hide": 0,
"includeAll": false,
"label": "alb_name",
"multi": false,
"name": "ALB",
"options": [],
"query": {
"dimensionFilters": {},
"dimensionKey": "LoadBalancer",
"logGroupPrefix": "",
"metricName": "RequestCount",
"namespace": "AWS/ApplicationELB",
"queryType": "dimensionValues",
"refId": "CloudWatchVariableQueryEditor-VariableQuery",
"region": "default",
"resourceType": "",
"tags": {}
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"type": "query"
} Current BehaviorCurrently, I am unable to find a way to specify a CloudWatch datasource for a Grafana variable using Graffonet. Environment
Possible SolutionAny suggestions for a possible solution or workaround. |
Beta Was this translation helpful? Give feedback.
Answered by
Duologic
Feb 22, 2024
Replies: 1 comment 1 reply
-
It looks like this is possible with the current grafonnet, example: local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
local query = g.dashboard.variable.query;
local cloudwatch = g.query.cloudWatch.CloudWatchMetricsQuery;
query.new(
'ALB',
cloudwatch.withQueryType('dimensionValues')
+ cloudwatch.withNamespace('AWS/ApplicationELB')
+ cloudwatch.withRefId('CloudWatchVariableQueryEditor-VariableQuery')
+ cloudwatch.withMetricName('RequestCount')
+ { dimensionKey: 'LoadBalancer' } // didn't find in `cloudwatch`
)
+ query.withDatasource('cloudwatch', 'cloudwatch-ds')
+ query.generalOptions.withLabel('alb_name')
+ query.generalOptions.withCurrent('app/alb-name123123')
+ { multi:: false } // workaround for bug on `withCurrent` |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
isarns
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like this is possible with the current grafonnet, example: