grafana-aws-cloudwatch-dashboards icon indicating copy to clipboard operation
grafana-aws-cloudwatch-dashboards copied to clipboard

Add template variable for LinkedAccount in AWS/Billing

Open christoph-buente opened this issue 4 years ago • 5 comments

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.

christoph-buente avatar Mar 06 '20 13:03 christoph-buente

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

jangaraj avatar Mar 06 '20 14:03 jangaraj

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 avatar Mar 06 '20 14:03 christoph-buente

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.

christoph-buente avatar Mar 06 '20 14:03 christoph-buente

This should list all linked accounts.

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

Yeah, that wildchar cloudwatch queries are tricky.

jangaraj avatar Mar 09 '20 18:03 jangaraj

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

kachhela57 avatar May 03 '21 10:05 kachhela57