Splunk Search

How to extract data?

tpaulsen
Contributor

Hello,

i am trying to extract from a search some data, and split the data into two fields with values.

So far i only managed to extract one field. How can i extract also the other?

Data Sample:

2010-01-20  16:55:45    0.0000  50.10.12.16 GP  GP_FOO  -   35  ja  -   19.1    AB  -   TST-00000   12355678    S12345678   FOOKey=5;FOOKeyM=0;

2010-01-20  16:56:45    0.0000  15.28.12.19 GP  GP_FOO  -   35  ja  -   49.1    AB  -   TST-00000   12345678    S12545678   FOOKey=10;FOOKeyM=3;

Here´s the search i am using so far:

index=idx_FOO myvariable="GP_FOO" | extract pairdelim=";", kvdelim="=;", auto=f

It delivers me the field "FOOKeyM"+value. But i also want "FOOKey" to get extracted. I don´t know any further. How can i achieve this?

Thomas

p.s. I don´t want to extract the fields in props or transform.conf. It´s only for a one time report.

Tags (1)
1 Solution

sideview
SplunkTrust
SplunkTrust

1) Are you sure Splunk wasnt extracting it automatically even without the extract command? I ask because Splunk always does foo=bar extraction automatically when it sees equal signs.

Although perhaps it was thrown off by the semicolon im not sure. Worth double checking cause if so, less is more.

2) If it really is just these fields it might be better to go with a standard rex command rather than trying to use extract. rex is a better tool across a wider range of situations, and the process of turning rex into a proper extraction is just a copy paste..

| rex "FOOkey=(?<FOOkey>.+);FooKeyM=(?<FOOkeyM>.+)"

View solution in original post

sideview
SplunkTrust
SplunkTrust

1) Are you sure Splunk wasnt extracting it automatically even without the extract command? I ask because Splunk always does foo=bar extraction automatically when it sees equal signs.

Although perhaps it was thrown off by the semicolon im not sure. Worth double checking cause if so, less is more.

2) If it really is just these fields it might be better to go with a standard rex command rather than trying to use extract. rex is a better tool across a wider range of situations, and the process of turning rex into a proper extraction is just a copy paste..

| rex "FOOkey=(?<FOOkey>.+);FooKeyM=(?<FOOkeyM>.+)"

sideview
SplunkTrust
SplunkTrust

yea, i figured. (but for any other readers reading this thread note that in most cases 'foo=12 bar=21' will get autoextracted with no need for either rex nor extract. Here something throws it off, possibly the semicolon)

0 Karma

tpaulsen
Contributor

p.s. No it doesn´t extract the data automatically. I was just using foo for the example here. Security, you know...;

0 Karma

tpaulsen
Contributor

Ah, that works like a charm!
I was previously trying this:

| rex "(?i)^(?:[^\-]*\-){6}\d+\t\d+\t\w+\t(?P.+)"

But that only selects the whole FOOkey Terms.

Thank you Nick!

0 Karma

Lamar
Splunk Employee
Splunk Employee

I don't think you should have a ; in your kvdelim just an "=", as such:

index=idx_FOO myvariable="GP_FOO" | extract pairdelim=";", kvdelim="=", auto=f

That should put you where you want to be.

tpaulsen
Contributor

Sorry, that selects only the "FOOkeyM" part. i think Nick is right, and the best approach in this case is a regular expression.
But thank you.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...