www.icinga.org
#icingacamp – Berlin – 03/01/2016
ICINGA 2 – APIFY THEM ALL
• Michael Friedrich
• Core developer, Vagrant boxes
• Senior Developer @NETWAYS
• ~7 years #icingalove
• monitoring-portal.org
• @dnsmichi
ICINGA2 - API
We had “APIs”
• HTTP with RESTful Url Schema
• ApiUser config object
• X.509 and/or Basic Auth
ApiUser Object
# vim /etc/icinga2/conf.d/api-users.conf
object ApiUser "root" {
password = "icinga”
permissions = [ "*" ]
}
ApiUser Permissions
permissions = [
{
permission = "objects/query/Host"
filter = {{ regex("^Linux", host.vars.os) }}
},
{
permission = "objects/query/Service"
filter = {{ regex("^Linux", service.vars.os) }}
}
]
• create, modify and delete objects
• retrieve information and run actions
• subscribe to events
• manage configuration packages
• Configuration management
• New standard config API
• Support for Packages and Stages
• Support for Zones
• Used by the Icinga Director
• Event Streams
• Based on Types and Filters
CheckResult, StateChange, Notification,
Acknowledgement*, Comment*, Downtime*
• Example
/v1/events?queue=camp&types=CheckResult
• Status, Objects, Actions and Events
• Simple filter
• services?service=localhost!ping6
• Advanced filter
• type=Service&filter=service.name==%22ping6%22
• (Hint: assign where expressions)
Demo
API CLIENTS
Icinga Studio
Icinga2 console
# ICINGA2_API_PASSWORD=icinga icinga2 console --connect
'https://root@localhost:5665/' --eval
'get_host(NodeName).last_check_result.command' | python -m
json.tool
[
"/usr/lib64/nagios/plugins/check_ping",
"-H",
"127.0.0.1",
"-c",
"5000,100%",
"-w",
"3000,80%"
]
Icinga 2 Dashing
Icinga Director
Wait for Tom! 
ICINGA 2 API – WHAT’S NEXT?
• Libraries
• Foreman, Puppet Hook?
• Logstash integration?
• Nagstamon, NagVis, …?
• Send a PR:
https://github.com/Icinga/icinga2-api-
examples
CONCLUSION
• Download Icinga 2
• Play with the Vagrant boxes
• Check the API docs
• Share your ideas & API clients
THANK YOU!
www.icinga.org
dev.icinga.org
git.icinga.org
@icinga
/icinga
+icinga

Icinga2 - Apify them all

Editor's Notes

  • #7 PERMISSIONS URL ENDPOINT SUPPORTS FILTERS actions/<action> /v1/actions Yes config/query /v1/config No config/modify /v1/config No objects/query/<type> /v1/objects Yes objects/create/<type> /v1/objects No objects/modify/<type> /v1/objects Yes objects/delete/<type> /v1/objects Yes status/query/<type> /v1/status Yes events/<type> /v1/events No console /v1/console No
  • #13 PAW Normal Dashing Grafana Studio Events Console AWS clippy