I’m looking for the best way to consume the API event-stream to receive messages in “real time”. I know I can use curl to show it in the console but I want to know which language/framework I can use to develop my own backend/logic.
Anyone use the API event-stream for his own development?
Which language can be used to consume the API event-stream?
any language is possible, best one which wraps sockets and HTTP protocol specs into a library. I’ve done sample implementations with Python and Golang already, and there are other consumers listed here.
I would pick one where you are familiar with, or has less dependencies to install/compile.
The problem is that I don’t know were to start. The API event stream use a POST method, so it’s a long polling request that I don’t know how to develop it in node.js.
I need to read more about that.
I will publish the solution if I find it, or maybe learn Python or Go hehehe
Custom modifications:
Each time the icinga2 restarts, the connections close the socket and it not reconnects. To handle that I modified the node_modules/agentkeepalive/lib/agent.js and added a new value called resetStatus and a new function setCurrentStatus, so each time the connection closes, the count reset to 0 and call the makeRequest function again.
I create a GitHub repo with a full example code about this topic. You can check it and colaborate if you want: icinga2_api_request
Also you can chek an integration with for frontend in this one: icinga2_events_frontend