How to access last 20 state changes


I am using Icinga 2 in version r2.12.5-1 on Ubuntu 20.04.2, but also on CentOS 7, 8 RHEL 7 and 8. The version on each platform can differ only a bit.

I read in the Advanced Topics - How it works section that icinga saves the last 20 state changes for every host and service when flapping detection is enabled. Is there any way to access these last 20 states?

Of course I know about the IDO DB. But here’s the problem: It now happened a few times that state changes were not saved to the IDO DB. This may happened because either the master or the IDO DB were offline for a short while. In any case, the state changes were no longer consistent. We now try to add the missing changes to the IDO DB so IcingaWeb shows the correct state again.

As I know I can only access the latest soft and hard states using the API. But it would be very nice if I also could access the last 20 changes. Do you have any idea? Are there some files we can parse and read from?

Thank you.

These values are not exposed via the API:

However, they are persisted to the icinga2.state file, so you could try to read them from there. I’m not sure if these are useful for you though. It’s not the last 20 state changes but a set of 20 bits for the last 20 checks each describing if that check resulted in a state change.

1 Like

As a work around for not being exposed in the API, you could store either of the following in redis (or anything else):

  • Use an API listener to listen for state changes and update data store of your choice
  • Scrape the services to get the last_state_change and previous_state_change values to put into a data store of your choice.