Alerting

How to create an alert based on first occurrence of a field value

tdavison76
Path Finder

Hello,

My apologies, I hope this makes sense, still learning.  I have events coming in that look like this:

tdavison76_0-1732688155667.png

I need to create an alert for when state = 1 for name = VZEROP002.  But, I can't figure out how to write the query to only look at the state for VZEROP002. 

The query I'm running is:

index=zn | spath "items{1}.state" | search "items{1}.state"=1

 

But, the search results still return events where VZEROP002 has a state of 2, and VZEROP001 has the state of 1.

I hope that makes sense, and thanks in advance for any help with this.

Thanks,

Tom

 

 

0 Karma
1 Solution

PaulPanther
Motivator

Good Morning! Is the order for the name always the same? So that VZEROP002 is always the first entry in the list?

If yes you could try:

index=zn| spath "items{0}.state" | spath "items{0}.name"| search "items{0}.name"=VZEROP002 "items{0}.state"=1

Do you need the list entries in one event for comparison within the event or could you split them in separate events?

 

 

View solution in original post

PaulPanther
Motivator

Good Morning! Is the order for the name always the same? So that VZEROP002 is always the first entry in the list?

If yes you could try:

index=zn| spath "items{0}.state" | spath "items{0}.name"| search "items{0}.name"=VZEROP002 "items{0}.state"=1

Do you need the list entries in one event for comparison within the event or could you split them in separate events?

 

 

tdavison76
Path Finder

Hello,

 

Thank you for your help, that did t he trick.  Unfortunately, the only option I see is to bring them in as a list.  It appears VZEROP002 is always the first on the list.  So this should do the trick.

Thanks again,

Tom

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!

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 ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...