📟 Get notified when your data meets certain conditions by setting up monitors, alerts, and notifications https://opensearch.org/docs/latest/monitoring-plugins/alerting/index/
  • Kotlin 96.9%
  • Java 3%
Find a file
Darshit Chanpura 1ff575905f
Register the doc-level query and job lock indices as system indices (#2320)
* Register the doc-level query and job lock indices as alerting system indices

Alerting creates and owns .opensearch-alerting-queries* (the default
doc-level query alias and its -000001 and rollover indices) and
.opensearch-alerting-config-lock (the job lock index), but did not
register them, unlike its alert, findings, comments and config indices.
Add both to getSystemIndexDescriptors() from the existing constants.

The query pattern does not cover query indices that a caller names in
a monitor's data sources. Neither pattern overlaps another alerting
pattern or one registered by the other plugins in the distribution.

Add a unit test for the patterns and a secured IT for direct access,
and move the ITs that wrote the lock index or created and closed the
query index directly to the admin certificate client.

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Add a write control to the query and lock index IT

The direct write tests expected a 403 but did not show that the same
user can write elsewhere, so a missing role permission would also pass.
Write the same document to an ordinary index first and expect 201.
Also state precisely which direct operation on the query index the
security plugin refuses in the create monitor clean up test.

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Create the clean up test's query index without the alias, as on main

The create monitor clean up test in SecureMonitorRestApiIT failed on the
secured CI run because monitor creation no longer failed.

On main, the createIndex call created .opensearch-alerting-queries-000001
without the .opensearch-alerting-queries alias: its mapping string closed
the request body before the aliases part, which the server ignored. With
no write index behind the alias, updateQueryIndexMappings fails, so
monitor creation fails and the test checks the clean up.

The admin certificate body added in this PR also created the alias. A
closed index behind the alias does not fail monitor creation: the mapping
update succeeds on a closed index, and the test monitor has no queries to
index. The test fails the same way with or without the new system index
descriptors, so the descriptors do not change this behaviour.

Create the same index, mappings and settings as main did, without the
alias, still with the admin certificate.

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Remove the read role mapping at the end of the clean up test

test create monitor failure clean up with a user without delete monitor
access maps the user to the read-all role and only removed the alerting
role mapping at the end. The next test recreates the same user, so when
the test order put test create monitor with an user without index read
role right after it, that user could read the source index and got 404
instead of 403. Reset the read-all mapping in the finally block, as the
other tests in the class do.

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Read the search hit total as a Number in the query and lock index test

The parser can return the total as a Long, and the cast to Int then throws.
(... as Number).toInt() is the form the rest of the tests in this repo use.

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Close the parser that reads the search response in the new test

The parser holds the response body stream, so read the body inside use().

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Pin what the new tests prove

The secured test compared the two indices against an ordinary index, so a
refusal could also have come from the leading dot rather than from the
registration. Compare against a dot prefixed index that is not registered
instead, and read it as the user as well, so each assertion names the one
difference it is about. Also name the index behind the alias, which is the
case the pattern's trailing wildcard covers, and hold the lock descriptor to
an exact name in the unit test.

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Say what the control index covers, not more

The note claimed every assertion compares against the control index. The two
that read through the admin certificate do not.

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
2026-12-01 17:36:56 -08:00
.github Restore BWC upgrade tests and CI checks (#2305) 2026-10-15 14:41:52 -04:00
alerting Register the doc-level query and job lock indices as system indices (#2320) 2026-12-01 17:36:56 -08:00
build-tools Add ci.opensearch.org/m2/ mirror for plugin marker resolution (alerting) (#2208) 2026-08-03 14:00:34 -04:00
core Give the outer block its own roles back after a nested injected block (#2343) 2026-12-01 17:36:39 -08:00
docs Add Document Level Alerting RFC (#388) 2022-04-13 14:51:48 -07:00
gradle/wrapper Bumped gradle version to 9.4.1. (#2122) 2026-05-05 18:47:59 -07:00
release-notes Add release notes for 3.10.1 (#2348) (#2350) 2026-11-23 22:00:38 -05:00
sample-remote-monitor-plugin Update maven2 mirror repository url order (#2188) 2026-07-07 11:41:12 -07:00
scripts Publish snapshots to Staging (#2005) 2025-12-12 13:32:23 -08:00
spi Update shadow plugin usage (#2022) 2026-02-18 13:20:08 -08:00
worksheets Add worksheets to help with testing (#151) 2021-08-26 13:07:35 -07:00
.codecov.yml Add Codecov configuration to set a coverage threshold to pass the check on a commit (#231) 2020-08-10 16:11:33 -07:00
.editorConfig Initial release for OpenDistro Elasticsearch Alerting 2019-03-04 16:39:57 -08:00
.gitignore Fix snapshot build and increment to 1.1.0. (#142) 2021-08-17 19:25:22 -04:00
.whitesource Add .whitesource configuration file (#270) 2022-01-12 13:33:42 -08:00
build.gradle Increment version to 3.10.0-SNAPSHOT (#2235) 2026-10-08 14:05:03 -07:00
CODE_OF_CONDUCT.md Update documentation to remove more ES references and update licenses 2021-04-16 17:13:31 -07:00
CONTRIBUTING.md Update and add documentation files (#117) 2021-06-24 16:41:21 -07:00
DEVELOPER_GUIDE.md Set alerting plugin 3.0.0 baseline JDK version to JDK-21 (#1695) 2025-01-02 08:53:07 -08:00
gradlew Change gradle wrapper from 9.2.0 to 9.4.0 (#2040) 2026-03-12 17:38:49 -07:00
gradlew.bat Change gradle wrapper from 9.2.0 to 9.4.0 (#2040) 2026-03-12 17:38:49 -07:00
LICENSE.txt Initial release for OpenDistro Elasticsearch Alerting 2019-03-04 16:39:57 -08:00
MAINTAINERS.md Baselines maintainers list. (#2092) 2026-04-17 11:57:14 -07:00
NOTICE.txt Update release note and copy right notice, and add dco workflow (#229) 2021-11-08 17:23:03 -08:00
README.md Replace Forum link in Alerting plugin README.md (#545) 2022-09-08 08:21:15 -07:00
RELEASING.md Update and add documentation files (#117) 2021-06-24 16:41:21 -07:00
SECURITY.md Update and add documentation files (#117) 2021-06-24 16:41:21 -07:00
settings.gradle Add ci.opensearch.org/m2/ mirror for plugin resolution (alerting) (#2204) (#2205) 2026-07-31 17:42:44 -04:00
THIRD-PARTY Update jackson CVE-2020-28491 (#8) 2021-04-23 17:39:32 -07:00

Test Workflow codecov Documentation Chat PRs welcome!

OpenSearch Alerting

The OpenSearch Alerting enables you to monitor your data and send alert notifications automatically to your stakeholders. With an intuitive OpenSearch Dashboards interface and a powerful API, it is easy to set up, manage, and monitor your alerts. Craft highly specific alert conditions using Elasticsearch's full query language and scripting capabilities.

Highlights

Scheduled searches use cron expressions or intervals (e.g. every five minutes) and the Elasticsearch query DSL.

To define trigger conditions, use the Painless scripting language or simple thresholds (e.g. count > 100).

When trigger conditions are met, you can publish messages to the following destinations:

Messages can be static strings, or you can use the Mustache templates to include contextual information.

Documentation

Please see our documentation.

Contributing

See developer guide and how to contribute to this project.

Code of Conduct

This project has adopted the Amazon Open Source Code of Conduct. For more information see the Code of Conduct FAQ, or contact opensource-codeofconduct@amazon.com with any additional questions or comments.

Security

If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our vulnerability reporting page. Please do not create a public GitHub issue.

License

This project is licensed under the Apache v2.0 License.

Copyright OpenSearch Contributors. See NOTICE for details.