monitoringartist / grafana-aws-cloudwatch-dashboards

:cloud: 40+ Grafana dashboards for AWS CloudWatch metrics: EC2, Lambda, S3, ELB, EMR, EBS, SNS, SES, SQS, RDS, EFS, ElastiCache, Billing, API Gateway, VPN, Step Functions, Route 53, CodeBuild, ...
https://grafana.com/orgs/monitoringartist/dashboards
GNU General Public License v3.0
2.05k stars 791 forks source link

Add template variable for LinkedAccount in AWS/Billing #72

Open christoph-buente opened 4 years ago

christoph-buente commented 4 years ago

AWS cloudwatch metrics for AWS/Billing have an additonal dimension called LinkedAccount for a setup with federated billing. Please add support of a template variable that can be changed to be either '*' for all or a dedicated account id, do filter the costs for that sub account only.

jangaraj commented 4 years ago

Could you provide dashboard example, please? I'm curious about that * filter.

christoph-buente commented 4 years ago

The template variable is a custom one with the hardwired IDs in it for now. No idea if there is a query in cloudwatch to fetch the subaccount ids progammatically.

{
    "allValue": "*",
    "current": {
        "selected": false,
        "text": "All",
        "value": "$__all"
    },
    "hide": 0,
    "includeAll": true,
    "label": "Linked Account",
    "multi": true,
    "name": "subaccount",
    "options": [{
            "selected": true,
            "text": "All",
            "value": "$__all"
        },
        {
            "selected": false,
            "text": "111111111111",
            "value": "111111111111"
        },
        {
            "selected": false,
            "text": "222222222222",
            "value": "222222222222"
        },
        {
            "selected": false,
            "text": "333333333333",
            "value": "333333333333"
        }
    ],
    "query": "111111111111,222222222222,333333333333",
    "skipUrlSync": false,
    "type": "custom"
}

And the query just gets added yet another dimension on top of Currency and Service name like this:

{
    "targets": [{
        "alias": "Total",
        "application": {
            "filter": ""
        },
        "dimensions": {
            "Currency": "USD",
            "LinkedAccount": "$subaccount"
        },
        "expression": "",
        "functions": [],
        "group": {
            "filter": ""
        },
        "highResolution": false,
        "host": {
            "filter": ""
        },
        "id": "",
        "item": {
            "filter": ""
        },
        "matchExact": true,
        "metricName": "EstimatedCharges",
        "mode": 0,
        "namespace": "AWS/Billing",
        "options": {
            "showDisabledItems": false
        },
        "period": "",
        "refId": "A",
        "region": "us-east-1",
        "returnData": false,
        "statistics": [
            "Average"
        ]
    }]
}
christoph-buente commented 4 years ago

I just realized, that even when using the * as the placeholder for all linked accounts, the result does not include the data for the parent account. Which make scews the data, especially when you really want to show the total over all including the payer account.

jangaraj commented 4 years ago

This should list all linked accounts.

dimension_values($region,AWS/Billing,EstimatedCharges,LinkedAccount)

Yeah, that wildchar cloudwatch queries are tricky.

kachhela57 commented 3 years ago

Could you provide dashboard example, please? I'm curious about that * filter.

Hi jan I'm trying to get data in grafana for route53 and for aws billing but in both of them I'm getting no data and for route53 I'm getting this error too (InvalidParameter: 2 validation error(s) found. - minimum field size of 1, GetMetricDataInput.MetricDataQueries[0].MetricStat.Metric.Dimensions[0].Value. - minimum field size of 1, GetMetricDataInput.MetricDataQueries[1].MetricStat.Metric.Dimensions[0].Value.) Can you please help me to solve it will be much appreciated Thankyou guys.. @jangaraj