I’m using a windows based Opendistro Kibana installation.
In Kibana, I configured a custom Webhook in order to send email alerts using an SMTP server.
Email alerts are being sent and it’s working perfectly so far.
What I didn’t quite understand (after following the documentation) is how to extract a specific field from a specific index and display the result in the email alert message.
For example,
I’m trying to trigger an alert for a failed VPN login and show the username field in the email alert message.
The index name is: vpn*
The field under “_source” that I need to display it’s result is: user
My trigger message includes:
Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.
Yes,
On the preview pane, I get the following (defaults) with data:
Monitor {{ctx.monitor.name}}
Trigger: {{ctx.trigger.name}}
Severity: {{ctx.trigger.severity}}
Period start: {{ctx.periodStart}}
Period end: {{ctx.periodEnd}}
But once I try to get data out from _source, It’s blank.
I’m not sure if increasing period in the Monitor would help since it’s triggered by a specific action (above 1) but i’m only assuming, I could be wrong
No, right now my fields are blank too: {{_source.ObjectID}} - {{_source.Module}} - {{_source.MessageID}}
But I get it working by changing Monitor - period of the check from ‘-1m’ to ‘-2d’ because the data on which Alert is triggered was 2 days ago.
Variables like {{ctx.monitor.name}} are static - they have already defined values this is why they are shown.
Variables like results of the Monitor data are dynamic - they are got as are result of the defined Monitor. If right now, when you do a preview, your Monitor doesn’t return any hits (data about ‘failed VPN login’) your dynamic variable will be blank.
Change your Monitor and make sure when you press ‘Run’ button you see data in the right pane - Extraction query response and press Update (save Monitor with the new conditions which return the hits)
Under the Trigger, in the Trigger condition response pane you should be able to see the data from the Monitor and you also will be able to see dynamic fields in the Preview.
It depends of the your Monitor settings. We use ‘extraction query’ to monitor the data, like on the screen.
It is a query with specific time-range for verification - we check every minute for the range of the one minute.
But In case I want to trigger an alert in real time of a failed VPN login and display the username who failed to log in, how would I do it?
If the monitor will collect data from the last 1-2 days, the data that will be shown within the email alert will be irrelevant \ inaccurate.
If you want to see at least any data in the Trigger and its preview you should set your Monitor to get at least one result, to be able to create your Mail messages Subject and Body.
When you will finish Trigger configuration, you can return Monitor back to the preferred settings.
Found an interesting information in the forum thread:
You could click the info button near the Trigger condition editor area in Define trigger page. It will show you directly with JSON response of what’s available under the “ctx” variable.
I can see such button only in case of the query, not chart.
I think I kind of did all.
I deleted the old VPN index and created a new index pattern, called “checkpoint*”. (our firewall)
The data get indexed successfully on the “discovery” node, as can be seen here (I filtered the results):
Everything seems to be configured correctly.
Alerts are being sent by email without further issues everytime there’s a failed login (usually on the monitor I’m using 1 minutes and not 1 day as the example above).
The basic CTX commands are working without any issues but when I’m trying to use one of your suggestions above (with or without iteration) nothing seems to be displayed.
I’m not an experienced programmer, am i missing something during the process?