Alerting

Splunk Subsequent Alert

chintu_jain
Explorer

Hi,

I am running an alert for every 15 mins and looking for a logic to stop subsequent splunk alerts if a field value remains the same during the next run of the alert. The next alert should trigger only if the field value changes

Appreciate if someone can help with the logic.

Tags (2)
0 Karma
1 Solution

cpetterborg
SplunkTrust
SplunkTrust

You can do several things. If you only need to compare two time periods ad see if there is a difference, you can use multisearch. Something like this might work:

| multisearch 
    [ search <your-search-to-get-data> earliest=-30m@m latest=-15m@m
    | eval type=first] 
    [ search <your-search-to-get-data> earliest=-15m@m latest=-0m@m
    | eval type=next]
| stats values(<field-you-want-to-compare>) as val
| eval diff=if(mvindex(val,0)!=mvindex(val,1),1,0)

This can take any time periods that you want, for example, you can set it to the same time on the previous day to be compared with the value today, so it is general in nature. Just set the earliest and latest times appropriately. The stats command makes a multivalue field that can then be used with the eval. The mvindex function let's you grab the two values that you get and set the difference in the field diff. If the value of diff is 1, then they are different, and if 0, then the same. This is a very generalized way to handle doing this. There are many ways to make it more efficient or effective.

You don't really need the eval type="first" or eval type="last". It just makes it possible to see the values separately. Don't worry about getting hung up on what it does, because in this case it doesn't really do anything, but it could be useful in some circumstances.

View solution in original post

0 Karma

cpetterborg
SplunkTrust
SplunkTrust

You can do several things. If you only need to compare two time periods ad see if there is a difference, you can use multisearch. Something like this might work:

| multisearch 
    [ search <your-search-to-get-data> earliest=-30m@m latest=-15m@m
    | eval type=first] 
    [ search <your-search-to-get-data> earliest=-15m@m latest=-0m@m
    | eval type=next]
| stats values(<field-you-want-to-compare>) as val
| eval diff=if(mvindex(val,0)!=mvindex(val,1),1,0)

This can take any time periods that you want, for example, you can set it to the same time on the previous day to be compared with the value today, so it is general in nature. Just set the earliest and latest times appropriately. The stats command makes a multivalue field that can then be used with the eval. The mvindex function let's you grab the two values that you get and set the difference in the field diff. If the value of diff is 1, then they are different, and if 0, then the same. This is a very generalized way to handle doing this. There are many ways to make it more efficient or effective.

You don't really need the eval type="first" or eval type="last". It just makes it possible to see the values separately. Don't worry about getting hung up on what it does, because in this case it doesn't really do anything, but it could be useful in some circumstances.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...