Querying EC2 attributes from instance IDs

I am using Prometheus with EC2 SD and relabelling instance to ec2 instance id. In my dashboard, I want to display instance names instead of instance IDs. I tried passing $node below to ec2_instance_attribute filter but it doesn’t work.

Hi,

Are you using some pre-built dashboard that you’re trying to modify? That has node variable defined earlier and now you’ve created an instant variable? Then you need to change the filters in all panel queries so that they use your new variable.

Marcus

I am using the dashboard from here https://grafana.com/dashboards/405. The node variable is taken from list of instances from Prometheus but I want instance names from EC2 to be displayed instead using their instance id.

At the moment, I just query EC2 instance names from EC2 and perform another query on another variable to get EC2 instance id from the name. The list of instances from Prometheus is way shorter than the list of instances from EC2.

image

I’m not quite follow. Do you have instance=ec2 instance id as label in prometheus? And you want to filter by instance names instead of instance IDs. Then I guess you need to get instance name as label in prometheus as well.

Marcus

Yes you got it right! I don’t want to add the instance name as a label since they can be changed unlike instance id. Changing the instance name will cause each name change to be listed down in the filter.

Hi,

If you can use some other datasource that supports template variables that could be a viable solution. For mysql/postgres for example you can render different key/value pairs where you should be able to have instance id as key and ec2 name as value and then use the template variable to filter prometheus by instance id. Should be possible to combine this solution with prometheus and other datasources as well.

Marcus

Hi,
I’m new to Grafana, could you please tell me how to configure EC2 instances with node exporter and prometheus.
I have prometheus as a data source and node exporter on an instance but unable to configure it for other instances.
Thanks in advance.