Aggregating timestamp for uptime number

with athena data source is there a way to sum all timestamp entries (field name “timestamp”) to one number which is a percentage of entries per minutes, meaning if


2024-03-11 01:10:00
2024-03-11 01:09:00
2024-03-11 01:08:00
2024-03-11 01:07:00
2024-03-11 01:06:00 
2024-03-11 01:05:00 
2024-03-11 01:04:00 
2024-03-11 01:03:00 
2024-03-11 01:01:00

the 2 minute is absent, and I want a query that will return a 90%

Hello,

I’m not sure of what you are asking. But as I understand it, you could just count the number of field you have:

SELECT COUNT(DISTINCT timestamp) FROM your_table_name

and then perform your percentage calculation?

Regards

not quite, Let’s suppose I always should have 1-2 entry per minute, but if I don’t - it means something went wrong. And I want to know the ratio of success/failure here

I already make use of DISTINCT DATE_TRUNC('minute', "timestamp") as timestamp to make sure I only select 1 message per minute, but not sure how to:

  • detect if there is a gap and how
  • account for it in the end percentage number

Also, I do not know if there a way to take each 5 min or take each 5th row?

Ok, will try, I had no idea grafana can be so different depending on datasource.

1 Like