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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...