diff --git a/doc/99-redis.md b/doc/99-redis.md index 5da9cfdb7..eb6b32f8e 100644 --- a/doc/99-redis.md +++ b/doc/99-redis.md @@ -1,4 +1,46 @@ -### Keys +# Icinga2 Redis +## Subscriptions and events + +Using the redis feature allows you to add subscriptions for events which will then be served by Icinga 2 over Redis. + +Possible event types: + +* CheckResult +* StateChange +* Notification +* AcknowledgementSet +* AcknowledgementCleared +* CommentAdded +* CommentRemoved +* DowntimeAdded +* DowntimeRemoved +* DowntimeStarted +* DowntimeTriggered + +### Creating a subscription +A subscription is created by creating a new key `icinga:subscription:` in redis with a set of event types. All +events matching the the type of those listed will then be added to a list at `icinga:event:`. The events are +rotated on a first-in-first-out basis, the default limit is (TODO) and can be overwritten by setting +`icinga:subscription::limit` to the desired ammount. + +The events are saved as json encoded strings, similar to the API. + +It is recommended to use `LPOP` to read from the list and discard read events at the same time. + +Example: + +``` +$ redis-cli +127.0.0.1:6379> SADD icinga:subscription:noma-2 "Notification" "CheckResult" +(integer) 2 +127.0.0.1:6379> SET icinga:subscription:noma-2:limit 500 +OK +... +127.0.0.1:6379> LRANGE icinga:event:noma-2 0 1 +1) "{\"check_result\":{\"active\":true,\"check_source\":\"icinga-1\",\"command\":[\"/usr/lib/nagios/plugins/check_ping\" ... ]}}" +1) "{\"check_result\":{\"active\":true,\"check_source\":\"icinga-2\",\"command\":[\"/usr/lib/nagios/plugins/check_ping\" ... ]}}" +``` + All Keys are prefixed with "icinga:" @@ -10,4 +52,3 @@ config:{type} | Hash | Config | Has all the config with name config:{type}:checksum | Hash | Checksums | Key is name, returns a json encoded string of checksums subscription:{name} | String | sub description | json string describing the subsciption event:{name} | List | sub output | Publish endpoint for subscription of the same name -:trigger::configchange | List | ? | I have no idea what this is or where it comes from