Splunk Search

How to extract fields from two separate events into two separate fields, not one single field?

email2vamsi
Explorer

The following block shows two events with their headers.
The first event has four fields. The second event has five fields.
When I am doing the field extraction using the Field Extractor, Script field in event one and Script_1 field in event two are getting extracted into the same field. I am doing it on comma delimiter basis. This is happening because both Script and Script_1 fields are have 4th place in the order of events.

I do not want both these fields to be in one field. I want them as Script="Script /test.sh ran" and Script_1="Test Script".

EventID, Date_Time , Server , Script
15391 , Dec 06 15:46:22 , TestServer , Script /test.sh ran

EventID, Date_Time_1 , Server_1 , Script_1 , Status_1
15391 , Dec 06 15:47:12 , TestServer , Test Script, State : failed.

0 Karma
1 Solution

sundareshr
Legend

You should be able to create a calculated field with the following eval

eval script_1=if(isnotnull(status_1), script, null())

http://docs.splunk.com/Documentation/Splunk/6.5.0/Knowledge/definecalcfields

View solution in original post

0 Karma

sundareshr
Legend

You should be able to create a calculated field with the following eval

eval script_1=if(isnotnull(status_1), script, null())

http://docs.splunk.com/Documentation/Splunk/6.5.0/Knowledge/definecalcfields

0 Karma

email2vamsi
Explorer

Thank you.I could not relate from your given eval.
I would like to explain the problem again.

When i make the FX for first event using the fields mentioned in the header, the second event is getting extracted as well. Now Script field has both the values "Test Script" and "Script /test.sh ran"
I want Script="Test Script" and Script_1="Script /test.sh ran".

EventID, Date_Time , Server , Script , Status
15391 , Dec 06 15:47:12 , TestServer , Test Script , State : failed.
15391 , Dec 06 15:46:22 , TestServer , Script /test.sh ran

0 Karma

sundareshr
Legend

Did this work> If not, can you share the results you're getting

0 Karma

jmallorquin
Builder

Hi,

You should use different sourcetypes for each output of the scripts, in that way you will be able to address what you want.

Hope i help you

0 Karma

email2vamsi
Explorer

Thank you.
But both the events are coming from the same log file. Is there a way to divide them into two sourcetypes?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...