Hi all.
Im new in Grafana, postgresql and this is my first post, so my thanks and apologies in advance in case I do something wrong.
-
What Grafana version and what operating system are you using?
Grafana v10.1.5 on GNU/Linux -
What are you trying to achieve?
Im trying to get a TimeSeries panel graph that represents for each EC2 ‘instance_type’, the number of EC2 INSTANCES running from a postgresql DB fed with cloudquery from AWS. -
How are you trying to achieve it?
I’ve got already some tables that allow me to get the number of instances of each type currently in use in a pie chart dashboard
This is the formula:
select a.instance_type,count(*) from aws_ec2_instances a, aws_organizations_accounts b WHERE a.account_id=b.id and b.name in (${account_names}) and a.region in (${regions}) and (a.tags->>'Proyecto' in ($proyecto) OR ('${sinproyecto}' in ($proyecto) and (a.tags->>'Proyecto'='' or a.tags?'Proyecto'=false or a.tags is null))) group by a.instance_type
And this is the result
In order to have historic data, I’ve being copying data on a daily basis from each table to another table with the same name with ‘h_’ at the beginning of the name.
So for the tables:
aws_ec2_instances and aws_organizations_accounts, their respective historic data tables’s names would be h_aws_ec2instances and h_aws_organizationsaccounts.
Now, based on the previous formula and the historic data tables, I want to create a panel in my dashboard that represents TimeSeries with a line for each ‘instance_type’ along the time, with a point for each day representing how many EC2 instances that existed that day for that particular instance.
I tried this formula:
select a.info_date, a.instance_type,count(*) from h_aws_ec2instances a, h_aws_organizationsaccounts b WHERE a.account_id=b.id and b.name in (${account_names}) and a.region in (${regions}) and (a.tags->>'Proyecto' in ($proyecto) OR ('${sinproyecto}' in ($proyecto) and (a.tags->>'Proyecto'='' or a.tags?'Proyecto'=false or a.tags is null))) group by a.instance_type, a.info_date order by 1 asc;
But this is what I got:
Any idea of what should be my aproach?
Thanks a lot for your time and help
Regards.
Carlos T