<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to exctract fields from nested named XML elements in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290504#M18436</link>
    <description>&lt;P&gt;Instead of name it will be based on number if you are using spath&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath output=memdaten path="myobjects-sensor-data.sensors.sensor{1}.datagroup.probe.value"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath#6:_Extract_a_subset_of_a_XML_attribute"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath#6:_Extract_a_subset_of_a_XML_attribute&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you have already defined KV_MODE=xml in your sourcetype, you can &lt;STRONG&gt;table&lt;/STRONG&gt; all the required field names as separate columns and then perform search/filter&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2017 13:19:00 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-05-12T13:19:00Z</dc:date>
    <item>
      <title>how to exctract fields from nested named XML elements</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290503#M18435</link>
      <description>&lt;P&gt;hi there, &lt;BR /&gt;
i have xml files which are indexed with KV_MODE=xml. i want to stats on the values on datagroup name="mem-used-percent"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&amp;gt;
&amp;lt;myobjects-sensor-data ms-duration="3244"&amp;gt;
    &amp;lt;ident&amp;gt;0820958kjshf8&amp;lt;/ident&amp;gt;
    &amp;lt;timeTimeDate&amp;gt;2017-04-30 23:55:15&amp;lt;/timeTimeDate&amp;gt;
    &amp;lt;csp&amp;gt;true&amp;lt;/csp&amp;gt;
    &amp;lt;sensors&amp;gt;
        &amp;lt;sensor name="mem-data" status="INFO" duration-ms="2"&amp;gt;
            &amp;lt;sensorData&amp;gt;
                &amp;lt;datagroup name="mem-used-percent"&amp;gt;
                    &amp;lt;probe&amp;gt;
                        &amp;lt;key&amp;gt;value&amp;lt;/key&amp;gt;
                        &amp;lt;value&amp;gt;25.4&amp;lt;/value&amp;gt;
                    &amp;lt;/probe&amp;gt;
                &amp;lt;/datagroup&amp;gt;
            &amp;lt;/sensorData&amp;gt;
        &amp;lt;/sensor&amp;gt;
        &amp;lt;sensor name="anotherone" status="INFO" duration-ms="2"&amp;gt;
            &amp;lt;sensorData&amp;gt;
........
            &amp;lt;/sensorData&amp;gt;
        &amp;lt;/sensor&amp;gt;
    &amp;lt;/sensors&amp;gt;
&amp;lt;/myobjects-sensor-data&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the sensor data gets recognized in preview for example:&lt;BR /&gt;
myobjects-sensor-data.sensors.sensor.sensorData.datagroup.probe.value = 25.4&lt;/P&gt;

&lt;P&gt;but as there are multiple *probe.value i dont know how to exactly adress this value by the name of the "datagroup". &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| spath output=memdaten path="myobjects-sensor-data.sensors.sensor{@name="mem-data"}.datagroup{@name="mem-used-percent"}.probe.value"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;wont work.&lt;/P&gt;

&lt;P&gt;what am i doing wrong?&lt;/P&gt;

&lt;P&gt;thanks&lt;BR /&gt;
swe&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 12:22:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290503#M18435</guid>
      <dc:creator>swe</dc:creator>
      <dc:date>2017-05-12T12:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to exctract fields from nested named XML elements</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290504#M18436</link>
      <description>&lt;P&gt;Instead of name it will be based on number if you are using spath&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath output=memdaten path="myobjects-sensor-data.sensors.sensor{1}.datagroup.probe.value"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath#6:_Extract_a_subset_of_a_XML_attribute"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath#6:_Extract_a_subset_of_a_XML_attribute&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you have already defined KV_MODE=xml in your sourcetype, you can &lt;STRONG&gt;table&lt;/STRONG&gt; all the required field names as separate columns and then perform search/filter&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 13:19:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290504#M18436</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-05-12T13:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to exctract fields from nested named XML elements</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290505#M18437</link>
      <description>&lt;P&gt;HI, &lt;/P&gt;

&lt;P&gt;shouldnt it be possible with xpath? i tried but this did not work. any suggestions?&lt;/P&gt;

&lt;P&gt;xpath "//myobject-sensor-data/sensors/sensor[@name='mem-data']/datagroup[@name='mem-used-percent']/probe/value" outfield=myfield&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 14:16:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290505#M18437</guid>
      <dc:creator>swe</dc:creator>
      <dc:date>2017-05-18T14:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to exctract fields from nested named XML elements</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290506#M18438</link>
      <description>&lt;P&gt;thanks, adressing with a number works but if the structure changes this would not be realy reliable. so i wonder if there is a better solution. &lt;/P&gt;

&lt;P&gt;if using table i get a massive ammount of multivalue fields, in which i cant identifiy to which keys the values belong.. &lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 14:18:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290506#M18438</guid>
      <dc:creator>swe</dc:creator>
      <dc:date>2017-05-18T14:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to exctract fields from nested named XML elements</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290507#M18439</link>
      <description>&lt;P&gt;hi there, &lt;/P&gt;

&lt;P&gt;one possible solution is a combination of KV_MODE=xml, rex and mvzip. for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval sensorstatuses=mvzip('myobject-sensor-data.sensors.sensor{@name}','myobject-sensor-data.sensors.sensor{@status}') 
| rex "&amp;lt;key&amp;gt;gps-latitude&amp;lt;\/key&amp;gt;\s*&amp;lt;value&amp;gt;(?&amp;lt;gps_latitude&amp;gt;.*)&amp;lt;\/value&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;its not nice, but works for now until someone comes up with a better solution&lt;BR /&gt;
thanks&lt;BR /&gt;
swe&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 17:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-to-exctract-fields-from-nested-named-XML-elements/m-p/290507#M18439</guid>
      <dc:creator>swe</dc:creator>
      <dc:date>2017-05-19T17:16:21Z</dc:date>
    </item>
  </channel>
</rss>

