Splunk Search

Help needed in the extraction

theouhuios
Motivator

Hello

I have a data which has multiple rows under a single event. I want to extract all of them on their "name" along with value. KV_MODE = xml doesn't work on this as the format is a bit different . So I am using transform.conf file to be able to extract this. I have also listed the transforms which I am trying. Any ideas if this is the right way or if there is any better way to do this?

Data:

<ResultSetData>
      <Row>
        <Column name="HOST_NAME">hostname234</Column>
        <Column name="INSTANCE_NAME">xxxxxx/Column>
        <Column name="USERNAME">abc</Column>
        <Column name="ACCOUNT_STATUS">OPEN</Column>
        <Column name="CREATED">12/09/2013 15:01:31</Column>
        <Column name="EXPIRY_DATE">06/07/2014 15:01:31</Column>
        <Column name="DEFAULT_TABLESPACE">zzzzz</Column>
        <Column name="DEFAULT_PROFILE">NO</Column>
      </Row>
    <Row>
    <Column name="HOST_NAME">hostname123</Column>
    <Column name="INSTANCE_NAME">xxxxxx</Column>
    <Column name="USERNAME">abc123</Column>
    <Column name="ACCOUNT_STATUS">OPEN</Column>
    <Column name="CREATED">10/17/2012 08:04:56</Column>
    <Column name="EXPIRY_DATE">01/19/2013 15:44:13</Column>
    <Column name="DEFAULT_TABLESPACE">zzzzz</Column>
    <Column name="DEFAULT_PROFILE">NO</Column>
  </Row>
</ResultSetData>

transforms.conf

[xml-extr]
REGEX = name=\"(\S+)?\"\>(\S+)?\<
FORMAT = $1::$2
REPEAT_MATCH = true
Tags (1)
0 Karma

somesoni2
Revered Legend

Use this:

transforms.conf

[xml-extr]
REGEX = name=\"(\w+)?\"\>([a-zA-Z0-9:// ]*)?\<
FORMAT = $1::$2
REPEAT_MATCH = true
0 Karma

rakesh_498115
Motivator

Hi theouhuios ,

You can use the following in ur transforms.conf .

[xml-extr]
REGEX=name=\"HOST_NAME\">(?[^<]*)<
MV_ADD = true

Hope this helps !

0 Karma

theouhuios
Motivator

That will extract just the hostname. I want to avoid writing multiple regexes for each column field. I am trying for a way to capture anything in the name part as a field which a user can search on with corresponding values for it in multiple lines.

0 Karma

lcrielaa
Communicator

Assuming that your example is 1 full event, it's not pure XML. You're lacking a closing for instance, but maybe

<your search> | spath

Can help you extract the fields that you want. A quick test gives me the fields Column{@name} and Column that might contain the information you want.

0 Karma

theouhuios
Motivator

I have tried that, but thats not the way I want it. I want it as HOST_NAME as a field with values of hostname234 and hostname 123.So It has to be made to a key=value pair as many users of this data are not technical people.

0 Karma
Get Updates on the Splunk Community!

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...