I have deployed a watcher script that triggered for certain search criteria. The action of the watch is to generate a dashboard.pdf and send it through email.
Now the problem is, I'm using two systems for this alert, one is watcher to trigger the alert and another is Kibana Reporting which generates the pdf report. Now for watcher triggering time is stored in {{ctx.trigger.scheduled_time}} variable but in the POST url, we are using "now". Because of this there is a mismatch found between the results of these two systems.
Please see below the watcher snippet.
"filter": {
"range": {
"transaction_datetime": {
"gte": "{{ctx.trigger.scheduled_time}}||-5m",
"lte": "{{ctx.trigger.scheduled_time}}",
"format": "strict_date_optional_time||epoch_millis"
}
and below is the POST url snippet.
time%3A%28from%3Anow-5m%2Cto%3Anow%29
Now I'm trying to embed {{ctx.trigger.scheduled_time}} variable in the POST url so that both the systems will be in sync.
Is there any way by which I can embed the variable value into the POST url?
If you need more details regarding the logic or watcher script, please let me know.
Please help.
Edited:
I have tried to embed the variable in the POST URL as below.
http://XXX.XX.X.XX:5601/s/watcher-alerting/api/reporting/generate/printablePdf?jobParams=(browserTimezone:UTC,layout:(dimensions:(height:1576,width:1287),id:preserve_layout),objectType:dashboard,relativeUrls:!('/s/watcher-alerting/app/dashboards#/view/....c?_g=(filters:!!(),refreshInterval:(pause:!!f,value:60000),time:(from:{{ctx.trigger.scheduled_time}}-5m,to:{{ctx.trigger.scheduled_time}}))&_a=(description:!'For watcher alert!!!'s attachment.!',filters:!!(),fullScreenMode:!!f,options:(hidePanelTitles:!!f,useMargins:!!t),panels:!!((embeddableConfig:(enhancements:()),gridData:(h:56,i:....,w:48,x:0,y:0),id:....,panelIndex:....,type:visualization,version:!'7.11.1!')),query:(language:kuery,query:!'!'),tags:!!(),timeRestore:!!t,title:!'Watcher Dashboard!',viewMode:view)'),title:'PDF Report')
The above is the decoded version of the URL, removed some of the information for security reason.
With this URL, watcher is working but found the same lag of few seconds (4-5 Seconds) between the triggered_time found in watcher output and the "to time" found in the above of the pdf report, which should match to fullfil my objective. I believe I'm making sense, if it is not clear, please let me know.