Splunk Dev

how to extract xml tag fileds

mintucs
New Member

after iindesing the xml tags i am getting the as show below
i am getting trouble how extract the data from it

  <IDX_BASE>B1102</IDX_BASE>
  <NOM_BASE>LANDES DE COUESME</NOM_BASE>
  <IDX_EQUIPEMENT>501</IDX_EQUIPEMENT>
  <NOM_EQUIPEMENT>E3</NOM_EQUIPEMENT>
  <DH_CONTROLE>2/6/2018 16:6:4</DH_CONTROLE>
  <ETAT_ALARME>ALM</ETAT_ALARME>
  <AVIS_EXPERT>ACCEPTABLE</AVIS_EXPERT>
  <RESUME_DIAG>MB: chocs \xE9pisodiques</RESUME_DIAG>
  <DETAILS_DIAG>
Tags (1)
0 Karma

TISKAR
Builder

Hello can you try this please:

in the props.conf

[xml2]
DATETIME_CONFIG = 
NO_BINARY_CHECK = 1
category = Structured
pulldown_type = 1
SHOULD_LINEMERGE = true
REPORT-xmlkv = xml_trans2
disabled = false

in your transforms.conf add :

[xml_trans2]
REGEX=<([^>]+)>([^<]+)<\/\1>
FORMAT=$1::$2
MV_ADD = true
0 Karma

niketn
Legend

@mintucs, your XML Data schema seems incorrect. There should be a root node under which above xml child nodes should be present. If you have xml data in raw events, you can enable KV_MODE=xml in props.conf to have Splunk automatically extract the fields from XML data during search time field discovery.

On similar lines please try the following run anywhere example where | makeresults and | eval _raw pipes generate dummy data as per the question. (PS: I have added <SOMENODE> as root node for the xml to become a valid xml so that spath can work):

| makeresults 
| eval _raw="<SOMENODE>
   <IDX_BASE>B1102</IDX_BASE>
   <NOM_BASE>LANDES DE COUESME</NOM_BASE>
   <IDX_EQUIPEMENT>501</IDX_EQUIPEMENT>
   <NOM_EQUIPEMENT>E3</NOM_EQUIPEMENT>
   <DH_CONTROLE>2/6/2018 16:6:4</DH_CONTROLE>
   <ETAT_ALARME>ALM</ETAT_ALARME>
   <AVIS_EXPERT>ACCEPTABLE</AVIS_EXPERT>
   <RESUME_DIAG>MB: chocs \xE9pisodiques</RESUME_DIAG>
   </SOMENODE>" 
| spath
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...