Use the PromQL query browser (in the Prometheus web interface) to debug 
it.  I suggest you first need to look at the inner query:

up{instance=~"instance"}

and graph it, setting the "instance" regexp to match one or more instances 
of interest. What does it look like? Is it a mixture of 0's and 1's, or all 
0's, or all 1's, or is it absent entirely?  If it's absent entirely, then 
that's a different problem you need to investigate - your scrape job is 
completely broken.

If it's a mixture of 0's and 1's, then try this query:

max_over_time(up{instance=~"instance"}[2d])

It should show 1 for any instant where the server was up at any time over 
the previous 48 hours.  Does it not?

If it's all 0's for at least 48 hours, then

max_over_time(up{instance=~"instance"}[2d])

should show 0.

Once you've understood why your query wasn't working as you were expecting, 
then for partially reachable you can try a query like this:

avg_over_time(up{instance=~"instance"}[2d]) > 0 < 0.9

(setting thresholds as appropriate)

On Tuesday, 9 August 2022 at 13:23:33 UTC+1 chembakay...@gmail.com wrote:

> Hi all,
>
> *First Query :*
> I want to find the servers which have not been reachable for the last X 
> days. It should not be in a reachable state for the last X days. I tried 
> the following query, but it didn't work out.
>
> Query :  max_over_time(up{instance=~"instance"}[Xd]) == 0
>
> The above query gives me the info that servers are not reachable at least 
> for 1 minute. But I want to know the info like it should not be reachable 
> for the last X days.
>
> *Second Query :*
> I want to find the servers which are partially reachable for the last X 
> days and it should not include the info that is totally unreachable state 
> for the X days.
>
> Any leads?
>
> Thanks & regards,
> Bharath Kumar.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/223d9dfb-5ac2-4629-b36a-a305d029fc21n%40googlegroups.com.

Reply via email to