Open source Enterprise Grafana Cloud

AWS API

Connect the Infinity data source to AWS management APIs to query metrics, list resources, and retrieve cost data.

Before you begin

  • Create an AWS IAM user with programmatic access
  • Note down your Access Key ID and Secret Access Key
  • Assign appropriate IAM permissions for the APIs you want to query (for example, CloudWatch ReadOnly, Cost Explorer ReadOnly)

Configure the data source

  1. In Grafana, navigate to Connections > Data sources.

  2. Click Add new data source and select Infinity.

  3. Expand the Authentication section and select AWS.

  4. Configure the following settings:

    SettingDescriptionExample
    RegionAWS region for your resourcesus-east-1
    ServiceAWS service identifiermonitoring
    Access KeyYour IAM access key IDKEY...
    Secret KeyYour IAM secret access key(stored securely)
  5. In Allowed hosts, enter your AWS endpoint (for example, https://monitoring.us-east-1.amazonaws.com).

  6. Click Save & test.

Tip

Find the appropriate service name in the AWS service endpoints documentation.

Common AWS service identifiers

ServiceIdentifierEndpoint pattern
CloudWatchmonitoringmonitoring.<region>.amazonaws.com
Cost Explorercece.us-east-1.amazonaws.com
EC2ec2ec2.<region>.amazonaws.com
S3s3s3.<region>.amazonaws.com
Lambdalambdalambda.<region>.amazonaws.com

Query examples

List CloudWatch metrics

  1. Set the URL to:

    sh
    https://monitoring.us-east-1.amazonaws.com?Action=ListMetrics&Version=2010-08-01
  2. Set Type to XML (AWS returns XML by default).

  3. Set Parser to Backend.

  4. Set the Root selector to extract the metrics array.

CloudWatch metrics with UQL

Use UQL to transform and filter the AWS XML response:

SQL
parse-xml
| scope "ListMetricsResponse.ListMetricsResult.Metrics.member"
| project "Namespace", "MetricName", "Dimensions"

List EC2 instances

URL:

sh
https://ec2.us-east-1.amazonaws.com?Action=DescribeInstances&Version=2016-11-15

UQL query:

SQL
parse-xml
| scope "DescribeInstancesResponse.reservationSet.item.instancesSet.item"
| project "InstanceId"="instanceId", "State"="instanceState.name", "Type"="instanceType"

Cost Explorer data

Note

Cost Explorer API requires the ce service and is only available in us-east-1.

URL:

sh
https://ce.us-east-1.amazonaws.com

Method: POST

Body (JSON):

JSON
{
  "TimePeriod": {
    "Start": "${__from:date:YYYY-MM-DD}",
    "End": "${__to:date:YYYY-MM-DD}"
  },
  "Granularity": "DAILY",
  "Metrics": ["UnBlendedCost"]
}

Provision the data source

Configure AWS authentication through provisioning:

YAML
apiVersion: 1
datasources:
  - name: AWS Infinity
    type: yesoreyeram-infinity-datasource
    jsonData:
      auth_method: aws
      aws:
        region: us-east-1
        service: monitoring
      allowedHosts:
        - https://monitoring.us-east-1.amazonaws.com
    secureJsonData:
      awsAccessKey: YOUR_ACCESS_KEY
      awsSecretKey: YOUR_SECRET_KEY

Troubleshoot

IssueCauseSolution
403 ForbiddenMissing IAM permissionsVerify your IAM user has the required permissions
SignatureDoesNotMatchIncorrect credentials or regionVerify access key, secret key, and region
Connection timeoutWrong endpointVerify the allowed hosts match your endpoint URL
Empty responseWrong service identifierCheck the AWS service endpoints for the correct identifier