Please tell me which type of OpenSearch Alerting monitor to choose: “Per query monitor”, “Per bucket monitor”, “Per document monitor”, that will send alerts under the following condition:
A document is critical if the message field contains at least one of the words: error, warning, alert, failed, unavailable, lost, wrong, unable, invalid, failure.
BUT the document should not be considered critical if message contains at least one of the following strings: disabling inotify, user config - ignore, _put_session, PVE ticket, guest-ping, Cyberprotect. And the document should not be considered critical if the message came from the sshd-session service.
I’d use a per query monitor here. All three of your conditions fit in one bool query, and you get one alert per run instead of one per matching line. A per document monitor works too, but it fires per document and its queries are written in query_string syntax, which gets awkward with a long exclusion list.
Two things to check against your mapping. If service is mapped as keyword rather than text, use “service” instead of “service.keyword”. And match on the standard analyzer does not stem, so “fail” or “errors” will not match unless you list them too. Keep the range window equal to the monitor interval so lines aren’t skipped or counted twice.
I read the documentation, but unfortunately it did not clarify my issue. I created a new thread because I changed the monitor condition and updated the OpenSearch version.
For generating a separate alert for each matching document, a Per document monitor would be the appropriate monitor type. I tested this on OpenSearch 3.8.0 and confirmed that three matching documents in a fixed index generated three separate alerts.
However, Per document monitors do not support wildcard index patterns in OpenSearch 3.8.0. When I tried creating a monitor using a wildcard pattern, I received the following error: Validation Failed: 1: Index patterns are not supported for doc level monitors.
I also tested using an index alias as an alternative. It worked with a single index, but with multiple indices, it detected new documents in the write index but not in the non-write index. After rollover, the existing monitor did not detect matching documents in the new write index. These were the results observed in my OpenSearch 3.8.0 tests.