Getting Data In

route data to indexes based on fields

kittu26
New Member

I have xml data which I want to route to different indexes based on the value of "Department" field.
Pasted below is the sample file and configurations that I am using..

Despite the configs, data keeps going to main index.
First I index field Department and then route data to indexes based on this field

Sample file:

<?xml version="1.0" encoding="UTF-8"?>
<addresses>

  <address>
  <LogTime>02/22/2014 07:15:49 AM</LogTime>
<EventType>TRACE</EventType>
<Department>Department1</Department>
    <name>Joe Tester</name>
    <street>Baker street 5</street>
  </address>
   <address>
  <LogTime>02/22/2014 08:15:49 AM</LogTime>
<EventType>TRACE</EventType>
<Department>Department2</Department>
    <name>Joe Tester</name>
    <street>Baker street 5</street>
       </address> 
   <address>
  <LogTime>02/22/2014 09:15:49 AM</LogTime>
<EventType>TRACE</EventType>
<Department>Department3</Department>
    <name>Joe Tester</name>
    <street>Baker street 5</street>
      </address>
</addresses>

props.conf

[abc]
BREAK_ONLY_BEFORE = <address>
KV_MODE=XML
SHOULD_LINEMERGE = true
TRANSFROMS-identifyfields = Department
TRANSFORMS-route = Department1,Department2,Department3
pulldown_type = 1

transfroms.conf

[Department]
REGEX = (Department>(?<Department>)<.Department>)
WRITE_META = true
FORMAT = Department:$1

[Department1]
SOURCE_KEY = field:Department
DEST_KEY   = _MetaData:Index
REGEX      = Department1
FORMAT     = Department1

[Department2]
DEST_KEY   = MetaData:Index
REGEX      = (Department>(?<Department>)<.Department>)
FORMAT     = index:$1

[Department3]
SOURCE_KEY = field:Department
DEST_KEY   = MetaData:Index
REGEX      = Department3
FORMAT     = Department3

fields.conf

[Department]
INDEXED = True
INDEXED_VALUE = False

Please help

Tags (2)
0 Karma
1 Solution

lguinn2
Legend

First and most important - Department should not be an indexed field. Remove the entry from fields.conf

Second, you need to be very careful with your spelling. I notice that you have misstyped TRANSFORMS in several places.

Finally, try replacing your transforms.conf with this:

[Department]
SOURCE_KEY = _raw
DEST_KEY   = _MetaData:Index
REGEX      = (?m)\<Department\>(Department1|Department2|Department3)\</Department\>
FORMAT     = $1

And your props.conf would have

[abc]
BREAK_ONLY_BEFORE = \<address>
KV_MODE=XML
SHOULD_LINEMERGE = true
TRANSFORMS-route = Department
pulldown_type = 1

Note that this will only work if the name of the department is the name of the index, as you showed in your example.
If the name of the index is not the same, then you would once again have to have 3 TRANSFORMS stanzas - the difference would be in the FORMAT.

HTH!

View solution in original post

lguinn2
Legend

First and most important - Department should not be an indexed field. Remove the entry from fields.conf

Second, you need to be very careful with your spelling. I notice that you have misstyped TRANSFORMS in several places.

Finally, try replacing your transforms.conf with this:

[Department]
SOURCE_KEY = _raw
DEST_KEY   = _MetaData:Index
REGEX      = (?m)\<Department\>(Department1|Department2|Department3)\</Department\>
FORMAT     = $1

And your props.conf would have

[abc]
BREAK_ONLY_BEFORE = \<address>
KV_MODE=XML
SHOULD_LINEMERGE = true
TRANSFORMS-route = Department
pulldown_type = 1

Note that this will only work if the name of the department is the name of the index, as you showed in your example.
If the name of the index is not the same, then you would once again have to have 3 TRANSFORMS stanzas - the difference would be in the FORMAT.

HTH!

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!

Quantify Your Splunk Investment Impact: Introducing Savings Metrics to Value Insights

Building on the foundation established in our initial Value Insights releases, we are introducing the Savings ...

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...