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!

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...

Cloud Platform & Enterprise: Classic Dashboard Export Feature Deprecation

As of Splunk Cloud Platform 9.3.2408 and Splunk Enterprise 9.4, classic dashboard export features are now ...