Dashboards & Visualizations

How to have one event per XML file and how to read it completely?

praspai
Path Finder

Hi,

We have kept the monitoring on the directory where XML files are placed. We would like to have one event per XML file but its getting split into multiple events. Also only few lines of xml file is getting into splunk.

Can anyone suggest how we can get the complete file in Splunk ?

Thanks,
Prashant

0 Karma

brian_rampley
Path Finder

I would set up your inputs and props with the following configuration (replacing the ## variables with what matches your case):

inputs.conf:

[monitor://#path to your files#]
sourcetype = #your sourcetype#

props.conf:

MAX_TIMESTAMP_LOOKAHEAD = #timestamp character count#
LINE_BREAKER = SaveRetailItemSalesLocation\>([\r\n\s]+)
TIME_FORMAT = #timestamp Format#
TIME_PREFIX = TransactionDate\>
SHOULD_LINEMERGE = false
TRUNCATE = #max size of your events#
KV_MODE = xml

If you put the props.conf on your search heads, indexers, and forwarders, you should get events that use the TransactionDate as their timestamp, with all their fields auto-extracted in spath format. I made assumptions on the timestamp field, which can be adjusted if you need a different field to act as the timestamp.

0 Karma

brian_rampley
Path Finder

Just to clarify: your XML files should be read as a single event per file? Can you post an example of the XML structure?

0 Karma

praspai
Path Finder

yes , single event per file.

<SaveRetailItemSalesLocation>
  <TransationInfo>
    <SenderID>XXX</SenderID>
    <ReceiverID>XXX</ReceiverID>
    <Status>DONE</Status>
    <UserStatus>XXX</UserStatus>
    <TransactionDate>XXX</TransactionDate>
  </TransationInfo>
  <impl:Header>
  </impl:Header>
  <impl:RetailItemList>
    <impl:VoRetailItem>
      <impl:ItemType>XXX</impl:ItemType>
      <impl:ItemNo>XXX</impl:ItemNo>
      <impl:ClassUnitKey>
        <impl:ClassType>XXX</impl:ClassType>
        <impl:ClassUnitType>XXX</impl:ClassUnitType>
        <impl:ClassUnitCode>XXX</impl:ClassUnitCode>
      </impl:ClassUnitKey>
      <impl:RetailItemSalesLocationList>
        <impl:VoRetailItemSalesLocation>
          <impl:SalesLocationId>XXX</impl:SalesLocationId>
          <impl:RecommendationRank>XXX</impl:RecommendationRank>
          <impl:ValidFromDateTime>XXX</impl:ValidFromDateTime>
          <impl:ValidToDateTime>XXX</impl:ValidToDateTime>
          <impl:UpdateDateTime>XXX</impl:UpdateDateTime>
        </impl:VoRetailItemSalesLocation>
      </impl:RetailItemSalesLocationList>
    </impl:VoRetailItem>
  </impl:RetailItemList>
</SaveRetailItemSalesLocation>
0 Karma
Get Updates on the Splunk Community!

Let’s Talk Terraform

If you’re beyond the first-weeks-of-a-startup stage, chances are your application’s architecture is pretty ...

Cloud Platform | Customer Change Announcement: Email Notification is Available For ...

The Notification Team is migrating our email service provider. As the rollout progresses, Splunk has enabled ...

Save the Date: GovSummit Returns Wednesday, December 11th!

Hey there, Splunk Community! Exciting news: Splunk’s GovSummit 2024 is returning to Washington, D.C. on ...