<?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: Using spath with Sequentially Numbered JSON Keys in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549299#M155848</link>
    <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233816"&gt;@cw&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Just try with spath and assign output field values to new fields.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{
  \"trap_destination_ip\": \"1.2.3.4\",
  \"trap_recieved_epoch\": \"1234567890\",
  \"trap_recieved_ts\": \"2021-04-08 14:17:32\",
  \"trap_source_ip\": \"1.2.3.4\",
  \"traps\": [
    {
      \"DISMAN-EVENT-MIB::sysUpTimeInstance\": \"2:2:49:18.49\",
      \"ETV-Agent-MIB::cctConfigChangeTrapSequenceNumber.17\": \"Wrong Type (should be Counter32): 17\",
      \"ETV-Agent-MIB::cctConfigChangeType.17\": \"Switchover\",
      \"ETV-Agent-MIB::cctDeviceLabel.17\": \"HOSTNAME\",
      \"SNMP-COMMUNITY-MIB::snmpTrapAddress.0\": \"1.2.3.4\",
      \"SNMP-COMMUNITY-MIB::snmpTrapCommunity.0\": \"public\",
      \"SNMPv2-MIB::snmpTrapEnterprise.0\": \"ETV-Agent-MIB::cctConfigChangeTrapTable\",
      \"SNMPv2-MIB::snmpTrapOID.0\": \"ETV-Agent-MIB::cctSingleConfigChangeTrap\"
            }
  ]
}" 
| spath 
| eval time=trap_recieved_ts, device='traps{}.ETV-Agent-MIB::cctDeviceLabel.17', alert='traps{}.ETV-Agent-MIB::cctConfigChangeType.17' 
| table time alert device&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, a like would be appreciated.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Apr 2021 04:21:40 GMT</pubDate>
    <dc:creator>manjunathmeti</dc:creator>
    <dc:date>2021-04-26T04:21:40Z</dc:date>
    <item>
      <title>Using spath with Sequentially Numbered JSON Keys</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549291#M155847</link>
      <description>&lt;P&gt;I'm trying to create a simple table from the following JSON data, and I only care about extracting three particular values:&amp;nbsp;&lt;SPAN&gt;trap_recieved_ts,&amp;nbsp;cctConfigChangeType, and&amp;nbsp;cctDeviceLabel&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{&lt;BR /&gt;&amp;nbsp; "trap_destination_ip": "1.2.3.4",&lt;BR /&gt;&amp;nbsp; "trap_recieved_epoch": "1234567890",&lt;BR /&gt;&amp;nbsp; "trap_recieved_ts": "2021-04-08 14:17:32",&lt;BR /&gt;&amp;nbsp; "trap_source_ip": "1.2.3.4",&lt;BR /&gt;&amp;nbsp; "traps": [&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "DISMAN-EVENT-MIB::sysUpTimeInstance": "2:2:49:18.49",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "ETV-Agent-MIB::cctConfigChangeTrapSequenceNumber.17": "Wrong Type (should be Counter32): 17",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "ETV-Agent-MIB::cctConfigChangeType.17": "Switchover",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "ETV-Agent-MIB::cctDeviceLabel.17": "HOSTNAME",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "SNMP-COMMUNITY-MIB::snmpTrapAddress.0": "1.2.3.4",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "SNMP-COMMUNITY-MIB::snmpTrapCommunity.0": "public",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "SNMPv2-MIB::snmpTrapEnterprise.0": "ETV-Agent-MIB::cctConfigChangeTrapTable",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; "SNMPv2-MIB::snmpTrapOID.0": "ETV-Agent-MIB::cctSingleConfigChangeTrap"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; ]&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The first issue I'm running into is with the .17, which increments with every new data point. The dot forces Splunk to treat the 17 as a new object in the path, and the fact that it increments prevents be from statically defining the key in my search string.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=index&lt;BR /&gt;| spath output=time path=trap_recieved_ts&lt;BR /&gt;| spath output=alert path=traps.ETV-Agent-MIB::cctConfigChangeType.17&lt;BR /&gt;| spath output=device path=traps.ETV-Agent-MIB::cctDeviceLabel.17&lt;BR /&gt;| table time alert device&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've read that I should be able to do the following in order to identify the two problematic keys I'm interested in, but Splunk seems to just disregard the {}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=index&lt;BR /&gt;| spath output=time path=trap_recieved_ts&lt;BR /&gt;| spath output=alert path=traps{2}&lt;BR /&gt;| spath output=device path=traps{3}&lt;BR /&gt;| table time alert device&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any suggestions?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 02:40:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549291#M155847</guid>
      <dc:creator>cw</dc:creator>
      <dc:date>2021-04-26T02:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using spath with Sequentially Numbered JSON Keys</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549299#M155848</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233816"&gt;@cw&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Just try with spath and assign output field values to new fields.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{
  \"trap_destination_ip\": \"1.2.3.4\",
  \"trap_recieved_epoch\": \"1234567890\",
  \"trap_recieved_ts\": \"2021-04-08 14:17:32\",
  \"trap_source_ip\": \"1.2.3.4\",
  \"traps\": [
    {
      \"DISMAN-EVENT-MIB::sysUpTimeInstance\": \"2:2:49:18.49\",
      \"ETV-Agent-MIB::cctConfigChangeTrapSequenceNumber.17\": \"Wrong Type (should be Counter32): 17\",
      \"ETV-Agent-MIB::cctConfigChangeType.17\": \"Switchover\",
      \"ETV-Agent-MIB::cctDeviceLabel.17\": \"HOSTNAME\",
      \"SNMP-COMMUNITY-MIB::snmpTrapAddress.0\": \"1.2.3.4\",
      \"SNMP-COMMUNITY-MIB::snmpTrapCommunity.0\": \"public\",
      \"SNMPv2-MIB::snmpTrapEnterprise.0\": \"ETV-Agent-MIB::cctConfigChangeTrapTable\",
      \"SNMPv2-MIB::snmpTrapOID.0\": \"ETV-Agent-MIB::cctSingleConfigChangeTrap\"
            }
  ]
}" 
| spath 
| eval time=trap_recieved_ts, device='traps{}.ETV-Agent-MIB::cctDeviceLabel.17', alert='traps{}.ETV-Agent-MIB::cctConfigChangeType.17' 
| table time alert device&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, a like would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 04:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549299#M155848</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-04-26T04:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using spath with Sequentially Numbered JSON Keys</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549312#M155852</link>
      <description>&lt;P&gt;Remove the numbering before the spath (and take into account the traps is a collection)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex mode=sed "s/(:cctConfigChangeTrapSequenceNumber)\.\d+/\1/g"
| rex mode=sed "s/(:cctConfigChangeType)\.\d+/\1/g"
| rex mode=sed "s/(:cctDeviceLabel)\.\d+/\1/g"
| spath output=time path=trap_recieved_ts
| spath output=alert path=traps{}.ETV-Agent-MIB::cctConfigChangeType
| spath output=device path=traps{}.ETV-Agent-MIB::cctDeviceLabel
| table time alert device&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 26 Apr 2021 08:42:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549312#M155852</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-26T08:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using spath with Sequentially Numbered JSON Keys</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549401#M155881</link>
      <description>&lt;P&gt;This worked perfectly. Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 03:10:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-spath-with-Sequentially-Numbered-JSON-Keys/m-p/549401#M155881</guid>
      <dc:creator>cw</dc:creator>
      <dc:date>2021-04-27T03:10:04Z</dc:date>
    </item>
  </channel>
</rss>

