Skip to content

Remove hardcoded trigger limit from Monitor data class and make number of triggers per monitor configurable#913

Merged
toepkerd merged 1 commit intoopensearch-project:mainfrom
manaswini1920:fix/configurable-max-triggers
Mar 13, 2026
Merged

Remove hardcoded trigger limit from Monitor data class and make number of triggers per monitor configurable#913
toepkerd merged 1 commit intoopensearch-project:mainfrom
manaswini1920:fix/configurable-max-triggers

Conversation

@manaswini1920
Copy link
Contributor

@manaswini1920 manaswini1920 commented Mar 11, 2026

Description

Remove the hardcoded trigger count limit (MONITOR_MAX_TRIGGERS = 10) from the Monitor data class init block. Trigger count validation is moved to the alerting plugin, where it can be configured via a dynamic c
luster setting (plugins.alerting.monitor.max_triggers).

Companion alerting PR: opensearch-project/alerting#2036

Resolves opensearch-project/alerting#468

Related Issues

Resolves
opensearch-project/alerting#1828
https://github.com/opensearch-project/alerting#468

Testing

  • Updated existing test to verify Monitor allows >10 triggers at the model level
  • End-to-end tested with alerting plugin changes on a local cluster:
    • Default limit (10): 11 triggers rejected
    • Limit set to 20: 11 triggers accepted
    • Limit set to 5: 6 triggers rejected
Test 1 — Default limit (10), 11 triggers rejected:

# Generate 11 triggers
TRIGGERS=""
for i in $(seq 1 11); do
  if [ -n "$TRIGGERS" ]; then TRIGGERS="$TRIGGERS,"; fi
  TRIGGERS="$TRIGGERS{\"name\":\"trigger-$i\",\"severity\":\"1\",\"condition\":{\"script\":{\"source\":\"return true\",\"lang\":\"painless\"}},\"actions\":[]}"
done

curl -XPOST 'localhost:9200/_plugins/_alerting/monitors' -H 'Content-Type: application/json' -d "{
  \"type\": \"monitor\",
  \"name\": \"test-11-triggers\",
  \"monitor_type\": \"query_level_monitor\",
  \"enabled\": false,
  \"schedule\": {\"period\": {\"interval\": 10, \"unit\": \"MINUTES\"}},
  \"inputs\": [{\"search\": {\"indices\": [\"*\"], \"query\": {\"query\": {\"match_all\": {}}}}}],
  \"triggers\": [$TRIGGERS]
}"

# Response:
# { "error": { "reason": "Monitors can only support up to 10 triggers." }, "status": 400 }

est 2 — Increase limit to 20, 11 triggers accepted:

# Update setting
curl -XPUT 'localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d '{
  "persistent": {"plugins.alerting.monitor.max_triggers": 20}
}'
# Response: { "acknowledged": true }

# Same 11 triggers payload as above
# Response: 200 OK — monitor created

# Verify triggers stored
curl -s 'localhost:9200/_plugins/_alerting/monitors/<monitor_id>' | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'Trigger count: {len(d[\"monitor\"][\"triggers\"])}')"
# Output: Trigger count: 11

Test 3 — Decrease limit to 5, 6 triggers rejected:

# Update setting
curl -XPUT 'localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d '{
  "persistent": {"plugins.alerting.monitor.max_triggers": 5}
}'
# Response: { "acknowledged": true }

# Generate 6 triggers
TRIGGERS=""
for i in $(seq 1 6); do
  if [ -n "$TRIGGERS" ]; then TRIGGERS="$TRIGGERS,"; fi
  TRIGGERS="$TRIGGERS{\"name\":\"trigger-$i\",\"severity\":\"1\",\"condition\":{\"script\":{\"source\":\"return true\",\"lang\":\"painless\"}},\"actions\":[]}"
done

curl -XPOST 'localhost:9200/_plugins/_alerting/monitors' -H 'Content-Type: application/json' -d "{
  \"type\": \"monitor\",
  \"name\": \"test-6-triggers\",
  \"monitor_type\": \"query_level_monitor\",
  \"enabled\": false,
  \"schedule\": {\"period\": {\"interval\": 10, \"unit\": \"MINUTES\"}},
  \"inputs\": [{\"search\": {\"indices\": [\"*\"], \"query\": {\"query\": {\"match_all\": {}}}}}],
  \"triggers\": [$TRIGGERS]
}"

# Response:
# { "error": { "reason": "Monitors can only support up to 5 triggers." }, "status": 400 }

Check List

  • [ X] New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • [ X] Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

@manaswini1920 manaswini1920 force-pushed the fix/configurable-max-triggers branch from dc9bf2f to b7a560c Compare March 11, 2026 21:48
toepkerd
toepkerd previously approved these changes Mar 11, 2026
Move trigger count validation to the alerting plugin to allow
configuration via a dynamic cluster setting.

Signed-off-by: Manaswini Ragamouni <ragamanu@amazon.com>

Resolves opensearch-project/alerting#468

Signed-off-by: Manaswini Ragamouni <ragamanu@amazon.com>
@manaswini1920 manaswini1920 force-pushed the fix/configurable-max-triggers branch from ad8316f to 179150b Compare March 12, 2026 22:57
@toepkerd toepkerd merged commit f659433 into opensearch-project:main Mar 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make number of triggers per monitor configurable

3 participants