grafana/docs/sources/datasources/aws-cloudwatch/template-variables/index.md
Jack Baldry 2b14b2d564
Update all links that have destinations outside of /docs/grafana/latest/datasources/ to use docs/reference shortcode (#72051)
* Update all links that have destinations outside of /docs/grafana/latest/datasources/ to use docs/reference shortcode

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Fix typo

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

* Prettier

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

---------

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
2023-07-31 16:34:03 +01:00

5.5 KiB

aliases description keywords labels menuTitle title weight
../../data-sources/aws-cloudwatch/template-variables/
template-queries-cloudwatch/
Guide on using template variables in CloudWatch queries
grafana
aws
cloudwatch
templates
variables
products
cloud
enterprise
oss
Template variables CloudWatch template variables 400

CloudWatch template variables

Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use variables. Grafana lists these variables in dropdown select boxes at the top of the dashboard to help you change the data displayed in your dashboard. Grafana refers to such variables as template variables.

For an introduction to templating and template variables, refer to the [Templating][variables] and [Add and manage variables][add-template-variables] documentation.

Use query variables

You can specify these CloudWatch data source queries in the Variable edit view's Query Type field. Use them to fill a variable's options list with values like regions, namespaces, metric names, and dimension keys/values.

Name List returned
Regions All AWS regions.
Namespaces All namespaces CloudWatch supports.
Metrics Metrics in the namespace. (Specify region or use "default" for custom metrics.)
Dimension Keys Dimension keys in the namespace.
Dimension Values Dimension values matching the specified region, namespace, metric, and dimension_key. Use dimension filters for more specific results.
EBS Volume IDs Volume ids matching the specified region and instance_id.
EC2 Instance Attributes Attributes matching the specified region, attribute_name, and filters.
Resource ARNs ARNs matching the specified region, resource_type, and tags.
Statistics All standard statistics.
LogGroups All log groups matching the specified region.

For details on the available dimensions, refer to the CloudWatch Metrics and Dimensions Reference.

For details about the metrics CloudWatch provides, refer to the CloudWatch documentation.

Use variables in queries

Use Grafana's variable syntax to include variables in queries. For details, refer to the [variable syntax documentation][variable-syntax].

Use ec2_instance_attribute

Filters

The ec2_instance_attribute query takes filters as a filter name and a comma-separated list of values. You can specify pre-defined filters of ec2:DescribeInstances.

Select attributes

A query returns only one attribute per instance. You can select any attribute that has a single value and isn't an object or array, also known as a flat attribute:

  • AmiLaunchIndex
  • Architecture
  • ClientToken
  • EbsOptimized
  • EnaSupport
  • Hypervisor
  • IamInstanceProfile
  • ImageId
  • InstanceId
  • InstanceLifecycle
  • InstanceType
  • KernelId
  • KeyName
  • LaunchTime
  • Platform
  • PrivateDnsName
  • PrivateIpAddress
  • PublicDnsName
  • PublicIpAddress
  • RamdiskId
  • RootDeviceName
  • RootDeviceType
  • SourceDestCheck
  • SpotInstanceRequestId
  • SriovNetSupport
  • SubnetId
  • VirtualizationType
  • VpcId

You can select tags by prepending the tag name with Tags.. For example, select the tag Name by using Tags.Name.

{{% docs/reference %}} [add-template-variables]: "/docs/grafana/ -> /docs/grafana//dashboards/variables/add-template-variables" [add-template-variables]: "/docs/grafana-cloud/ -> /docs/grafana//dashboards/variables/add-template-variables"

[variable-syntax]: "/docs/grafana/ -> /docs/grafana//dashboards/variables/variable-syntax" [variable-syntax]: "/docs/grafana-cloud/ -> /docs/grafana//dashboards/variables/variable-syntax"

[variables]: "/docs/grafana/ -> /docs/grafana//dashboards/variables" [variables]: "/docs/grafana-cloud/ -> /docs/grafana//dashboards/variables" {{% /docs/reference %}}