I'm looking for a query to get the average uptime of the server on which prometheus runs over the last week. It should be about 15h/week, so about 8-10 %.
I'm using Prometheus 2.5.0 with node_exporter on CentOS 7.6.1810. My most promising experiments would be:
1 - avg_over_time(up{job="prometheus"}[7d])
This is what I've found when looking for ways to get average uptimes, but it gives me exactly 1. (My guess is it ignores the times in which no scrapes happened?)
2 - sum_over_time(up{job="prometheus"}[7d]) * 15 / 604800
This technically works, but is dependent on the scrape interval, which is 15s in my case. I can't seem to find a way to get said interval from prometheus' config, so I have to hardcode it into the query.
I've also tried to find ways to get all start and end times of a job, but to no avail thus far.