Comments (7)
Hi @ammardodin,
It's just left out of the documentation. You have access to the id as {{ctx.monitor.id}}, when testing with the preview in Kibana or "Send test message" it appears this is empty, but during actual execution it will be correctly supplied.
It does look like we have inconsistent values being passed in Kibana UI and Elasticsearch though when comparing the actual context values with what's listed on the documentation:
https://github.com/opendistro-for-elasticsearch/alerting/blob/master/alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/Monitor.kt#L79
from alerting.
This is a bug / discrepancy between the UI and backend documentation. Kibana is using the execute API which is providing different context variables than during actual monitor execution.
from alerting.
Unfortunately, it seems that {{ctx.monitor.id}}
is rendered as an empty string. Same is true for {{ctx.alert.id}}
, which is extremely problematic.
from alerting.
@ammardodin
The UI is rendering it as an empty string, but it should actually be provided in the message being sent. This is a discrepancy between Kibana plugin and Elasticsearch plugin providing different context values for the message preview. You should be able to see the actual value from your destination when clicking "send test message". If you still do not see it let me know from your destination and I can look into it more.
Edit: Looked into it a bit more. The Kibana UI is calling the Execute API with dryrun=false and no MonitorID. This is because our current logic only sends out notifications when dryrun=false, but will also save an alert if dryrun=false AND MonitorID exists. Because of this we do not have a MonitorID while in the Execute API. So when providing the monitor to the context variable, it has no MonitorID to access during the "send test message". That being said, you will have the monitor ID during an actual alert.
from alerting.
@dbbaughe to clarify, I am not using Kibana. I am using the API to create my monitors. It seems that I can access the monitor id via {{ctx.monitor._id}}
not {{ctx.monitor.id}}
.
As for the alert id, I still can't access it via {{ctx.alert.id}}
, as that is being returned as an empty string, even though that I definitely see an active alert for the monitor in question in the .opendistro-alerting-alerts
index.
To reproduce on 0.7.1
using the API:
- Create a Slack destination.
- Create a monitor with a truthy trigger, i.e.
return true;
. - Point monitor action to destination id from 1, and use
{{ctx.alert.id}}
as the action message.
from alerting.
This is what's currently provided on the monitor on the ctx variable during trigger execution and action execution. The documentation should be updated to reflect this (and this should probably provide more than just this information).
This is what's currently provided on the alert on the ctx variable. This was updated in v0.9.0 which included this PR.
The thing to be aware of though is that this is referring to the current existing alert (if one exists) during this execution. So for your very first alert there would be no alert.id because no alert exists. And the next alert would contain an alert.id of the existing alert (again, only if one exists).
from alerting.
Closing based on last comment. Feel free to reopen, if this is still an issue.
from alerting.
Related Issues (20)
- [BUG] Cannot send message to Azure service bus topic with shared sas key HOT 1
- [BUG]"Propagate exception from publishing Email notifications to Action run result" HOT 1
- Slack ACK url HOT 1
- Create Monitors using PPL, similar to use of query DSL HOT 2
- [BUG] Can not see monitors, destinations, email groups etc in GUI after installing through API HOT 1
- Support K8s service name as a valid web-hook destination URL HOT 1
- ctx.alert.isAcknowledged not accessible with trigger HOT 1
- UI notification for failed test of alert and destinations HOT 1
- Alerting with email as a destination not working in version 13.1.0.1. HOT 1
- Joining two queries
- [BUG] Alerting Webhooks incorrectly rejecting URL's HOT 2
- [BUG] Can not create monitor in the coordinating cluster when it involves remote indices HOT 1
- [BUG] No setting available for Monitor max triggers HOT 1
- Point people to OpenSearch
- [BUG] {{period_start}} and {{period_end}} seems not respected HOT 1
- Configuring cross-cluster domain across 2 OpenSearch 1.0 cluster throws TCP connection error HOT 2
- contents of fields of query resulting dataset from monitor
- Facing an issue in elasticsearch container logs for alerting is Could not convert socket to TLS, statuscode: 1 HOT 1
- Custom Alert Configure
- [BUG] Kibana alerting not working properly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alerting.