Detect systemd service restart using prometheus

25 Views Asked by At

I want to trigger an alert if a systemd service restarts. If I am able to capture time between a service inactive and active state, then I think I am able to create such alert. We know we can delay triggering an alert by using:

- alert: TestAlert
  expr: service_inactive == 1
  for: 1m

Instead of triggering above alert I want to store it's output to track the time and use an expression like: if the time between inactive to active state is < 1m then it means that the service has been restarted. Is there any way to do so?

0

There are 0 best solutions below