Splunk Search
Highlighted

Comparing one value of a field from a search with all the values of a field in other search.

Path Finder

Hi,

I have come across a situation where I have to compare a set of values for a field with one value for another field (Both represent time), and display Yes/No as values for a new field.

Search one should give me a field "LatestTime" with only one value and it should be compared with other field "GenTime" in other search and create a new field "Checked" with possible values "Yes/No" if the "LatestTime" is less than "GenTime" the value for "Checked" is "Yes" else "No".

Please help.

Tags (3)
0 Karma
Highlighted

Re: Comparing one value of a field from a search with all the values of a field in other search.

SplunkTrust
SplunkTrust

Do post some sample events.

0 Karma
Highlighted

Re: Comparing one value of a field from a search with all the values of a field in other search.

Path Finder

2014-04-21 06:39:38 Message="Error Server connection failed on 8346 port.
2014-04-21 06:41:59 Port opened, connection successful
2014-04-21 07:22:34 Message="Error Server connection failed on 8346 port.
2014-04-21 07:25:32 Port opened, connection successful.
I have two types of events, I have rexed and extracted the fields, ErrorMessage & SuccessMessage. So now i have to find the latest time where "Port opened, connection successful" and check with the all the Errormessages.
If latest success message is after error message, action taken is "Yes".
Table Time, Error
Message action_taken

0 Karma
Highlighted

Re: Comparing one value of a field from a search with all the values of a field in other search.

SplunkTrust
SplunkTrust

Okay... something like this?

index=foo sourcetype=bar (Error_Message=* OR Success_Message=*) | eval message_type = if(isnotnull(Error_Message), "error", "success") | eval dummy = "dummy" | chart latest(_time) over dummy by message_type | eval checked = if(success > error, "Yes", "No") | fields checked

View solution in original post

0 Karma
Highlighted

Re: Comparing one value of a field from a search with all the values of a field in other search.

Path Finder

It was really helpful.

0 Karma