diff --git a/docs/clmc-development-guide.md b/docs/clmc-development-guide.md index 4584bff2a3238fc6f456c61a6f154d3a41b9bfa5..af16d0ede5ca0a346680d22f7f84854bcd91221d 100644 --- a/docs/clmc-development-guide.md +++ b/docs/clmc-development-guide.md @@ -374,3 +374,25 @@ All tests are implemented using *Python* and *Pytest*. The integration tests (lo ```bash lxc exec test-runner -- pytest -s --tb=short -rfp --pyargs /opt/clmc/src/test/clmctest ``` + +#### Implementation details of the Alerts API + +The Alerts API is implemented on top of the Kapacitor HTTP API and includes the following main parts: + +* Wrapper interfaces for the Kapacitor HTTP API +* Parsing and validation of a TOSCA-compliant CLMC-specific alerts configuration document +* Kapacitor task templates + +When creating/updating alerts, the following steps are performed (in the specified order): + +1) TOSCA alerts configuration document is parsed as a yaml file +2) yaml content is parsed as a TOSCA document +3) the TOSCA document is validated against the CLMC alerts specification schema +4) if a TOSCA resource specification document was passed too, parse it as a TOSCA document and compare both documents for inconsistencies +5) go through each policy and trigger in the alerts configuration document and extract the data +6) convert the extracted data from each trigger to a Kapacitor task based on the chosen event type (determines which Kapacitor task template to use) +7) the Kapacitor task identifier is generated based on the sfc, sfc instance, policy and trigger identifiers and represents a hash of the concatenation of these identifiers +8) the Kapacitor topic is named after the Kapacitor task (they share the same identifier) +9) register all URLs as Kapacitor HTTP handlers for the created Kapacitor topic +10) the Kapacitor handler identifier is generated as a hash of the concatenated sfc, sfc instance, policy and trigger identifiers with the handler URL +11) return a response which contains the errors (if any) that were encountered while interacting with Kapacitor (e.g. if an alert already exist)