Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Using template variables in CloudWatch queries
Instead of hard-coding server, application, and sensor names in your metric queries, you can use variables. The variables are listed as dropdown select boxes at the top of the dashboard. These dropdowns make it easy to change the display of data in your dashboard.
For an introduction to templating and template variables, refer to the Templating documentation.
Query variable
The CloudWatch data source provides the following queries that you can specify in the Query Type field in the Variable edit view. They enable you to fill a variable’s options list with values such as region, namespaces, metric names and dimension keys/values.
Read more about the available dimensions in the CloudWatch Metrics and Dimensions Reference.
For details about the metrics CloudWatch provides, please refer to the CloudWatch documentation.
Using variables in queries
Variables can be used in the variable form. Refer to the variable syntax documentation.
Using JSON format template variables
Some queries accept filters in JSON format and Grafana supports the conversion of template variables to JSON.
For example, if env = 'production', 'staging', a Resource ARNs query with the following filter returns ARNs of EC2 instances where the Environment tag is equal to production or staging.
{"Environment":${env:json}}ec2_instance_attribute examples
JSON filters
The ec2_instance_attribute query takes filters in JSON format.
You can specify pre-defined filters of ec2:DescribeInstances.
Note that the actual filtering takes place on Amazon’s servers, not in Grafana.
Filters syntax:
{ "filter_name1": [ "filter_value1" ], "filter_name2": [ "filter_value2" ] }Selecting attributes
Only 1 attribute per instance can be returned. Any flat attribute can be selected (i.e. if the attribute has a single value and isn’t an object or array). Below is a list of available flat attributes:
AmiLaunchIndexArchitectureClientTokenEbsOptimizedEnaSupportHypervisorIamInstanceProfileImageIdInstanceIdInstanceLifecycleInstanceTypeKernelIdKeyNameLaunchTimePlatformPrivateDnsNamePrivateIpAddressPublicDnsNamePublicIpAddressRamdiskIdRootDeviceNameRootDeviceTypeSourceDestCheckSpotInstanceRequestIdSriovNetSupportSubnetIdVirtualizationTypeVpcId
You can select tags by prepending the tag name with Tags.. For example, the tag Name is selected with Tags.Name.



