Graph currently AWS EC2 running instances (by tags)(with CloudWatch Datasource)


I am currently using Grafana with CloudWatch Datasource. Everything work actually pretty smoothly. Except one thing that drives me crazy.

I simply want a graph the amount/sum of currently running/active instances [Step 1]. Best case I want to split this by a specific tag (InstanceType)[Step 2].
Is this something thats simply not possible with the Datasource CloudWatch? If so, what’s the best-practise on this? This doesn’t seem like an edge use-case.
I could think of creating CloudWatch Events or creating LogMetrics… but is there really no easier way?

Yours, IPtizer

After another 2h of research, I don’t think it is possible.

The way to go is to create a Lambda function, that gathers the values (i.e. every 5 mins) and pushes them to CloudWatch. I found this on GitHub, which will be a first starting point:

If there are any suggestions on better ways accomplishing this -> Feel free to correct me!