Getting Data In

Parsing XML having seperate date and time tags

vganjare
Builder

HI,

I am having following xml log which has two seperate tags for Date and time. I want to use Date + Time together as timestamp.

<data>
    <detail>
        <date>01-17-2015</date>
        <time>10:35:235</time>
        <country>US</country>
    </detail>
    <detail>
        <date>01-18-2015</date>
        <time>12:21:754</time>
        <country>US</country>
    </detail>
</data>

Here, I want use &ltdate&gt + &lttime&gt as TIME_PREFIX. What value of TIME_PREFIX should be set in props.conf?

Thanks.

Tags (2)

woodcock
Esteemed Legend

Use datetime.xml; to use the first date/time pair, do this:

Inside /opt/splunk/etc/apps/myApp/default/props.conf do this:

[mySourceType]
DATETIME_CONFIG = /etc/apps/myApp/default/datetime.xml

Inside /opt/splunk/etc/apps/myApp/default/datetime.xml do this:

&lt;datetime&gt;
&lt;define name="_myXMLdate" extract="month, day, year"&gt;
&lt;text&gt;&lt;![CDATA[&lt;date&gt;(\d(2)-\d(2)-(\d{4})&lt;\date&gt;]]&gt;&lt;/text&gt;
&lt;/define&gt;
&lt;define name="_myXMLtime" extract="hour, minute"&gt;
&lt;text&gt;&lt;![CDATA[&lt;time&gt;(\d{2}):(\d{2}):\d{3}&lt;/time&gt;]]&gt;&lt;/text&gt;
&lt;/define&gt;
&lt;timePatterns&gt;
&lt;use name="_myXMLtime"/&gt;
&lt;/timePatterns&gt;
&lt;datePatterns&gt;
&lt;use name="_myXMLdate"/&gt;
&lt;/datePatterns&gt;
&lt;/datetime&gt;
0 Karma

vganjare
Builder

Any way to solve this case?

Thanks!!

0 Karma

tom_frotscher
Builder

Hi,
i can not lead you to a complete answer to this, but maybe i can give you an idea or something to search for. It looks like you need a custom datetime.xml for your sourcetype to solve this problem. The bad thing is, that there is only poorly documentation for the datetime.xml 😞

Maybe some examples can help:

http://www.function1.com/2013/01/oh-no-splunking-log-files-with-multiple-formats-no-problem

http://blogs.splunk.com/2009/12/02/configure-splunk-to-pull-a-date-out-of-a-non-standard-filename/

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!

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...

Global Splunk User Group Events: May + June 2026

Your Splunk Community Awaits: Discover Upcoming User Group Events Worldwide    Staying ahead in the fast-paced ...