Getting Data In

Parsing XML and props.conf help

jtashker
New Member

Let me first preface this by saying that I am a total Splunk newbie and this is very similar to a lot of XML parsing questions, however I have read through ~20 topics and am still unable to get my XML log to parse properly.

Here is a sample of my XML file:

<?xml version="1.0" encoding="utf-8"?>
<Customers>
    <customer>
        <customerName>SampleCustomer1</customerName>
        <siteName>Main</siteName>
        <lastUpdated>8/10/2015 8:09:51 AM</lastUpdated>
        <alarmedState>False</alarmedState>
        <updateFrequency>45</updateFrequency>
        <pointsNotCommunicating>
            <pointNotCommunicating>SamplePoint1@2015-07-02 17:07:00</pointNotCommunicating>
            <totalNotCommunicating>1</totalNotCommunicating>
        </pointsNotCommunicating>
        <ClientIsUp>true</ClientIsUp>
    </customer>
    <customer>
        <customerName>SampleCustomer2</customerName>
        <siteName>Main</siteName>
        <lastUpdated>8/10/2015 8:27:57 AM</lastUpdated>
        <alarmedState>False</alarmedState>
        <updateFrequency>30</updateFrequency>
        <pointsNotCommunicating>
            <totalNotCommunicating>0</totalNotCommunicating>
        </pointsNotCommunicating>
        <ClientIsUp>true</ClientIsUp>
    </customer>

</Customers>

First: What I did was create a new file called props.conf in my splunk directory under .../etc/system/local because there wasn't a props.conf file there. Here is the entire contents of my props.conf file:

[source::C:\\Program Files (x86)\\SkySparkServer\\serverStatus.xml]
sourcetype: SkySparkLog

[SkySparkLog]
KV_MODE=xml
TIME_PREFIX = <lastUpdated>
TIME_FORMAT = %m\/%d\/%Y %I:%M:%S
SHOULD_LINEMERGE = true
MUST_NOT_BREAK_BEFORE = \</pointsNotCommunicating\>
MUST_BREAK_AFTER = \</customer\>
TRUNCATE = 0

Is this the proper method and if so, am I doing something wrong in my props.conf file?

Thanks for the help.

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

Try this under your sourcetype definition in props.conf on Indexer/Heavy forwarder.

 [SkySparkLog]
KV_MODE=xml
TRUNCATE = 0
TIME_PREFIX = \<lastUpdated\>
SHOULD_LINEMERGE = true
TIME_FORMAT = %m/%d/%Y %I:%M:%S
LINE_BREAKER = (<customer>)
MUST_BREAK_AFTER = \</customer\>
SEDCMD-acrRemover = s/\x0D//g
SEDCMD-blfRemover = s/\x0A//g
SEDCMD-abremoveheader = s/\<\?xml.*\s*\<Customers\>\s*//g
SEDCMD-bremovefooter = s/\<\/Customers\>//
SEDCMD-caddroot = s/(.*)/<customer>\1/

View solution in original post

somesoni2
Revered Legend

Try this under your sourcetype definition in props.conf on Indexer/Heavy forwarder.

 [SkySparkLog]
KV_MODE=xml
TRUNCATE = 0
TIME_PREFIX = \<lastUpdated\>
SHOULD_LINEMERGE = true
TIME_FORMAT = %m/%d/%Y %I:%M:%S
LINE_BREAKER = (<customer>)
MUST_BREAK_AFTER = \</customer\>
SEDCMD-acrRemover = s/\x0D//g
SEDCMD-blfRemover = s/\x0A//g
SEDCMD-abremoveheader = s/\<\?xml.*\s*\<Customers\>\s*//g
SEDCMD-bremovefooter = s/\<\/Customers\>//
SEDCMD-caddroot = s/(.*)/<customer>\1/

jtashker
New Member

This works, thank you. Can you explain what the SEDCMD fields are doing?

0 Karma

somesoni2
Revered Legend

Its just removing the unwanted strings from you xml. Thexml header, the root Customers tag and newline and tabs, so youd get individual customer tag with proper xml syntax.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I believe you should change the following lines.

TIME_FORMAT = %m\/%d\/%Y %I:%M:%S %p
MUST_BREAK_AFTER = \</Customers\>
---
If this reply helps you, Karma would be appreciated.
0 Karma

jtashker
New Member

Rich, thank you for your reply. I will change TIME_FORMAT to match, but I don't think I want to break after /Customers.

I really want each customer to be one entry. Am I thinking about this the wrong way?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I see where breaking where you want makes sense.

---
If this reply helps you, Karma would be appreciated.
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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Kubernetes Alerts That Work Out of the Box with AutoDetect detectors in Splunk ...

A deployment rolls out slowly, one pod sits not ready for a few minutes, and whoever is on call gets an alert ...

Observability at Your Fingertips Directly From Splunk Platform—for Free

At .conf, we announced our roadmap to bring observability foundations to Splunk Platform. Bringing metrics and ...