Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions worksheets/bucket_level_monitor_test.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
POST localhost:9200/opensearch_dashboards_sample_data_ecommerce/_search
Content-Type: application/json

{
"size": 0,
"aggregations": {
"composite_agg": {
"composite": {
"sources": [
{ "category": { "terms": { "field": "category.keyword" } } }
]
},
"aggs": {
"avg_total_price": {
"avg": { "field": "taxful_total_price" }
}
}
}
}
}
###
POST localhost:9200/_opendistro/_alerting/monitors
Content-Type: application/json

{
"type": "monitor",
"monitor_type": "bucket_level_monitor",
"name": "test-monitor",
"enabled": false,
"schedule": {
"period": {
"interval": 1,
"unit": "MINUTES"
}
},
"inputs": [{
"search": {
"indices": ["opensearch_dashboards_sample_data_ecommerce"],
"query": {
"size": 0,
"query": {
"bool": {
"filter": {
"range": {
"order_date": {
"gte": "now-1d/d",
"lte": "now",
"format": "epoch_millis"
}
}
}
}
},
"aggregations": {
"composite_agg": {
"composite": {
"sources": [
{ "category": { "terms": { "field": "category.keyword" } } }
]
},
"aggs": {
"avg_total_price": {
"avg": { "field": "taxful_total_price" }
}
}
}
}
}
}
}],
"triggers": [{
"aggregation_trigger": {
"name": "test-trigger",
"severity": "1",
"condition": {
"parent_bucket_path": "composite_agg",
"buckets_path": {
"avg_price": "avg_total_price"
},
"script": {
"source": "params.avg_price >= 80"
}
},
"actions": [{
"name": "test-action",
"destination_id": "ld7912sBlQ5JUWWFThoW",
"subject_template": {
"source": "TheSubject"
},
"message_template": {
"source" : "Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.\n- Trigger: {{ctx.trigger.name}}\n- Severity: {{ctx.trigger.severity}}\n- Period start: {{ctx.periodStart}}\n- Period end: {{ctx.periodEnd}}\n- Deduped Alerts: \n{{#ctx.dedupedAlerts}}\n * {{id}} : {{bucket_keys}}\n{{/ctx.dedupedAlerts}}\n- New Alerts:\n{{#ctx.newAlerts}}\n * {{id}} : {{bucket_keys}}\n{{/ctx.newAlerts}}\n- Completed Alerts:\n{{#ctx.completedAlerts}}\n * {{id}} : {{bucket_keys}}\n{{/ctx.completedAlerts}}",
"lang" : "mustache"
},
"throttle_enabled": true,
"throttle": {
"value": 5,
"unit": "MINUTES"
}
}]
}
}]
}
###
POST localhost:9200/_plugins/_alerting/monitors/<monitor_id>/_execute
9 changes: 9 additions & 0 deletions worksheets/opensearch_dashboards_sample_data.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This will ingest the opensearch dashboards sample ecommerce data into the cluster iff opensearch dashboards
# is running on 5601. If using local dev opensearch dashboards make sure to pass yarn start --no-base-path
POST localhost:5601/api/sample_data/ecommerce
Connection: keep-alive
Accept: */*
osd-xsrf: opensearch-dashboards
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
Content-Type: application/json
###