opensearch-project / alerting

📟 Get notified when your data meets certain conditions by setting up monitors, alerts, and notifications
https://opensearch.org/docs/latest/monitoring-plugins/alerting/index/
Apache License 2.0
60 stars 102 forks source link

initial commit for remote monitor support #1547

Closed sbcd90 closed 4 months ago

sbcd90 commented 4 months ago

Issue #, if available:

1546

Description of changes:

CheckList:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

sbcd90 commented 4 months ago

Can we plz add the skeleton for a fan-out and monitor metadata capabilities of doc level monitor also how to define new triggers? triggers seem tightly coupled with the existing defintions.

added in latest changes.

Monitor metadata support https://github.com/opensearch-project/alerting/blob/0181b855a8c1e4badc8f2d00cad17fc068bcf879/alerting/src/main/kotlin/org/opensearch/alerting/remote/monitors/RemoteDocumentLevelMonitorRunner.kt Fan-out support https://github.com/opensearch-project/alerting/blob/0181b855a8c1e4badc8f2d00cad17fc068bcf879/spi/src/main/kotlin/org/opensearch/alerting/spi/RemoteMonitorRunner.kt#L45

Now, Remote Doc-Level monitors just need to implement `fan out transport actions. https://github.com/opensearch-project/alerting/blob/0181b855a8c1e4badc8f2d00cad17fc068bcf879/sample-remote-monitor-plugin/src/main/java/org/opensearch/alerting/monitor/runners/SampleRemoteDocLevelMonitorRunner.java https://github.com/opensearch-project/alerting/blob/0181b855a8c1e4badc8f2d00cad17fc068bcf879/sample-remote-monitor-plugin/src/main/java/org/opensearch/alerting/monitor/fanouts/TransportRemoteDocLevelMonitorFanOutAction.java

Remote Doc-level monitors can be created in same way like regular doc-level monitors. https://github.com/opensearch-project/alerting/blob/0181b855a8c1e4badc8f2d00cad17fc068bcf879/sample-remote-monitor-plugin/src/main/java/org/opensearch/alerting/SampleRemoteMonitorRestHandler.java#L178-%23L203

eirsep commented 4 months ago

how will index validate mapping of the custom trigger and custom input

eirsep commented 4 months ago

how will serialization work for custom trigger and custom input

https://github.com/opensearch-project/common-utils/blob/main/src/main/kotlin/org/opensearch/commons/alerting/model/Trigger.kt#L50-L63

sbcd90 commented 4 months ago

how will serialization work for custom trigger and custom input

https://github.com/opensearch-project/common-utils/blob/main/src/main/kotlin/org/opensearch/commons/alerting/model/Trigger.kt#L50-L63

here is an example how to define our own inputs & triggers in remote monitors. custom input - https://github.com/opensearch-project/alerting/pull/1547/files#diff-80a0de70d190d8c5ba474303bbbdc9782a65c6173e3f6722bc3fb350c745bc83 custom trigger - https://github.com/opensearch-project/alerting/pull/1547/files#diff-04bd41521bcc623cf8018e11ed9ceefb09e59a76ce204a191795e85d4ccabca1 defining a monitor using them - https://github.com/opensearch-project/alerting/blob/629a0c30a1a867129df99b1fb4821cdc4fdcfd0d/sample-remote-monitor-plugin/src/main/java/org/opensearch/alerting/SampleRemoteMonitorRestHandler.java#L67-%23L96 accessing them in custom monitor runner - custom input - https://github.com/opensearch-project/alerting/blob/629a0c30a1a867129df99b1fb4821cdc4fdcfd0d/sample-remote-monitor-plugin/src/main/java/org/opensearch/alerting/monitor/runners/SampleRemoteMonitorRunner1.java#L69-%23L75 custom trigger - https://github.com/opensearch-project/alerting/blob/629a0c30a1a867129df99b1fb4821cdc4fdcfd0d/sample-remote-monitor-plugin/src/main/java/org/opensearch/alerting/monitor/runners/SampleRemoteMonitorRunner1.java#L77-%23L83

there are more complex examples in the sample plugin e.g. using nested objects.

sbcd90 commented 4 months ago

can you check xcontent registry

responded here. https://github.com/opensearch-project/alerting/pull/1547#discussion_r1621903429

sbcd90 commented 4 months ago

all builds pass. merging pr.