> Can we check whether the scrape was successful or not? *up == 1*
Unfortunately, *timestamp(up == 1)* doesn't work as you might hope; it returns the current time (the instant that the query was made for), not the time of the last successful scrape. You can do: *timestamp(up) unless up == 0* but then you'll only get the timestamp if the server is currently up, and nothing if it is down. You can use a subquery, which scans the expression over a time range - but I already explained that to you a few weeks ago: https://groups.google.com/g/prometheus-users/c/1zSp7XTbChY/m/3my54aefBwAJ *max_over_time((time() * up)[24h:5m])* Or I think this will work too: *max_over_time((timestamp(up == 1))[24h:5m])* Both of these give an approximation. The subquery as shown evaluates the expression at 5 minute intervals over the last 24 hours; so the timestamp you get is rounded up to the next 5 minute step. On Friday, 16 September 2022 at 07:59:31 UTC+1 [email protected] wrote: > Yes... It will give the timestamp... It is giving the time even though the > specific instance is down. It should not give the timestamp if it didn't > scrape as the instance/server was down. > > Can we check whether the scrape was successful or not? > > The main intention is to find the timestamp because when a server goes > down we can know at what time the last scrape happen. > > > > On Friday, 16 September 2022 at 12:01:50 UTC+5:30 [email protected] wrote: > >> timestamp(up) >> >> On Fri, Sep 16, 2022 at 7:36 AM BHARATH KUMAR <[email protected]> >> wrote: >> >>> Hello, >>> >>> Can we know the last time when the Prometheus scrape the metrics. Is >>> there any metric to find the time when the Prometheus did the scrape? >>> >>> 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 [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/prometheus-users/e28a24ea-921a-4710-9540-0f0c66556ab8n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/prometheus-users/e28a24ea-921a-4710-9540-0f0c66556ab8n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/ff80acc6-c95e-466e-8963-09f740320503n%40googlegroups.com.

