# Get service/host history with API

**URL:** <https://community.icinga.com/t/get-service-host-history-with-api/1388>\
**Category:** Icinga 2\
**Tags:** api\
**Created:** [June 4, 2019, 10:25am UTC](https://community.icinga.com/t/get-service-host-history-with-api/1388 "2019-06-04T10:25:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nrousseau](https://community.icinga.com/letter_avatar_proxy/v4/letter/n/edb3f5/32.png) [@nrousseau](https://community.icinga.com/u/nrousseau)\
**Post date:** [June 4, 2019, 10:25am UTC](https://community.icinga.com/t/get-service-host-history-with-api/1388/1 "2019-06-04T10:25:34Z")

</div>

Hello,  
I’m new here, maybe you can help me with my question.

I use the API quite a lot to query information about the hosts or services, also to create/remove downtime, acknowledgement, etc. Very powerfull tool and the documentation is also quite good to understand the filters.

I wonder if there is a way to get the history of a given host or service, either using curl or icingacli. I’m talking about the history you can see in Icingaweb2 when you click on the history tab for a given host/service.  
I have not found anything about this so right now my only option would be to dig directly into the database which I would like to avoid if possible.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [June 4, 2019, 10:58am UTC](https://community.icinga.com/t/get-service-host-history-with-api/1388/2 "2019-06-04T10:58:22Z")

</div>

Hi,

the REST API is a status and config API and allows to query the runtime state of the core. There’s no history backend for this kind of API.

The data you’re seeing with Icinga Web 2 is stored in a database, namely DB IDO. Relational databases have proven to work reliably with storing and retrieving historical event data. As such, if you want to retrieve that data, the Icinga Web 2 API (format=json) is a good candidate. Keep in mind that automated queries and long running SQL statements may harm operations, so using that with care and a caching daemon in the middle is a good advise.

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![nrousseau](https://community.icinga.com/letter_avatar_proxy/v4/letter/n/edb3f5/32.png) [@nrousseau](https://community.icinga.com/u/nrousseau)\
**Post date:** [June 4, 2019, 12:57pm UTC](https://community.icinga.com/t/get-service-host-history-with-api/1388/3 "2019-06-04T12:57:38Z")

</div>

Hello,

Thank you for the quick answer.  
When you say IcingaWeb2 API, do you mean something like :

```auto
 curl -H 'Accept: application/json' -i 'https://localhost/icingaweb2/monitoring/service/history?host=somehost&service=someservice' 
```

Or is there something else that I’m missing ?

Regards.

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [June 4, 2019, 1:13pm UTC](https://community.icinga.com/t/get-service-host-history-with-api/1388/4 "2019-06-04T13:13:38Z")

</div>

Ah, I forgot, this only works for the main history view. This can be filtered as well, and needs the [JSON format](https://icinga.com/docs/icingaweb2/latest/doc/20-Advanced-Topics/#global-url-parameters).

```auto
http://192.168.33.5/icingaweb2/monitoring/list/eventhistory?timestamp%3E=-7%20days&(service_description=random-001)&modifyFilter=&format=json

```

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![nrousseau](https://community.icinga.com/letter_avatar_proxy/v4/letter/n/edb3f5/32.png) [@nrousseau](https://community.icinga.com/u/nrousseau)\
**Post date:** [June 4, 2019, 2:34pm UTC](https://community.icinga.com/t/get-service-host-history-with-api/1388/5 "2019-06-04T14:34:36Z")

</div>

Perfect !

When using curl, it actually returns json format even if you don’t specify it, I also did not have to specify “modifyFilter=” to hide the filter.

This worked for me to get history of service “myservice” applied to host “myhost” in a json format.

```auto
curl -s -u admin:admin -H 'Accept: application/json' 'https://localhost/icingaweb2/monitoring/list/eventhistory?timestamp%3E=-10%20hours&host_name=myhost&service_description=myservice'
```

Thank you.

---

<div class="post-metadata">

**Author:** ![liuyanagit](https://community.icinga.com/user_avatar/community.icinga.com/liuyanagit/32/2401_2.png) [@liuyanagit](https://community.icinga.com/u/liuyanagit)\
**Post date:** [October 10, 2019, 9:44am UTC](https://community.icinga.com/t/get-service-host-history-with-api/1388/6 "2019-10-10T09:44:51Z")

</div>

> [@nrousseau](#):
>
> curl -s -u admin:admin -H ‘Accept: application/json’ ‘[https://localhost/icingaweb2/monitoring/list/eventhistory?timestamp\>=-10%20hours&host\_name=myhost&service\_description=myservice](https://localhost/icingaweb2/monitoring/list/eventhistory?timestamp%3E=-10%20hours&host_name=myhost&service_description=myservice)’

hi, do you know where is the document about icingaweb2 api? i want to set acknowledge\_notify through the icingaweb2 api, but i could not find the documentation in anywhere.

---

<div class="post-metadata">

**Author:** ![skupjoe](https://community.icinga.com/user_avatar/community.icinga.com/skupjoe/32/6357_2.png) [@skupjoe](https://community.icinga.com/u/skupjoe)\
**Post date:** [May 2, 2020, 12:35am UTC](https://community.icinga.com/t/get-service-host-history-with-api/1388/7 "2020-05-02T00:35:49Z")

</div>

I am wondering about where the Icinga Web API documentation is as well. I’ve found docu for Icinga’s core and Director API, but not Icinga Web.
