<?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 extract JSON data format using extract field in Splunk? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495299#M141122</link>
    <description>&lt;P&gt;Another way.&lt;/P&gt;

&lt;P&gt;How to add a column to the results table based on an existing field above like loction, siteid and etc...?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Mar 2020 21:49:07 GMT</pubDate>
    <dc:creator>matoulas</dc:creator>
    <dc:date>2020-03-12T21:49:07Z</dc:date>
    <item>
      <title>How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495294#M141117</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have JSON data format that send to Splunk as below:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
"timestamp": "2020-03-12T18:18:48+00:00",
"siteid": "CPM-1600-2-EC-158",
"location": "LABRACK1",
"powerunit": "1",
"outletmetering": "1",
"ats": "0",
"branchcount": "4",
"plugcount": "16",
"powerfactor": "100",
"powereff": "100",
"powerdatacount": "1",
"powerdata": [{
"timestamp": "2020-03-12T18:18:48+00:00",
"plug1": [{
"plugname": "PaloAlto5220",
"voltage": "125.00",
"current": "6.00",
"branch": "1"
}],
"plug2": [{
"plugname": "Cisco5220Meraki",
"voltage": "125.00",
"current": "6.00",
"branch": "1"
}],
"plug3": [{
"plugname": "Outlet_A3",
"voltage": "125.00",
"current": "1.40",
"branch": "2"

    }]
}]
}&lt;/LI-CODE&gt;
&lt;P&gt;How do I extract JSON data format using the extract field in Splunk? I want to group the data like these. Can someone please point me to the right way of how to do it.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8548i3A163FDAD3AFBFF1/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 01:06:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495294#M141117</guid>
      <dc:creator>matoulas</dc:creator>
      <dc:date>2020-06-19T01:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495295#M141118</link>
      <description>&lt;P&gt;hi @matoulas,&lt;/P&gt;

&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{
 \"timestamp\": \"2020-03-12T18:18:48+00:00\",
 \"siteid\": \"CPM-1600-2-EC-158\",
 \"location\": \"LABRACK1\",
 \"powerunit\": \"1\",
 \"outletmetering\": \"1\",
 \"ats\": \"0\",
 \"branchcount\": \"4\",
 \"plugcount\": \"16\",
 \"powerfactor\": \"100\",
 \"powereff\": \"100\",
 \"powerdatacount\": \"1\",
 \"powerdata\": [{
 \"timestamp\": \"2020-03-12T18:18:48+00:00\",
 \"plug1\": [{
 \"plugname\": \"PaloAlto5220\",
 \"voltage\": \"125.00\",
 \"current\": \"6.00\",
 \"branch\": \"1\"
    }],
 \"plug2\": [{
 \"plugname\": \"Cisco5220Meraki\",
 \"voltage\": \"125.00\",
 \"current\": \"6.00\",
 \"branch\": \"1\"
    }],
 \"plug3\": [{
 \"plugname\": \"Outlet_A3\",
 \"voltage\": \"125.00\",
 \"current\": \"1.40\",
 \"branch\": \"2\"
    }]
 }]
 }" 
| spath 
| spath path=powerdata{} output=powerdata 
| eval powerdata=split(powerdata, "}],") 
| mvexpand powerdata 
| rex field=powerdata "\"(?&amp;lt;plug&amp;gt;plug\d+)\"[^\w]+\"plugname\":\s\"(?&amp;lt;plugname&amp;gt;[\w]+)[^\w]+voltage\":\s\"(?&amp;lt;voltage&amp;gt;[\d\.]+)[^\w]+current.*(?&amp;lt;current&amp;gt;[\d\.]+)[^\w]+branch\":\s\"(?&amp;lt;branch&amp;gt;[\d]+)\""
| table plug, plugname, voltage, current, branch, timestamp, siteid, location, powerunit, outletmetering, ats, branchcount, plugcount, powerfactor, powereff, powerdatacount, powerdata{}.timestamp 
| rename powerdata{}.timestamp as powerdata_timestamp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Mar 2020 20:39:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495295#M141118</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-12T20:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495296#M141119</link>
      <description>&lt;P&gt;Awesome It worked! Thank you so much&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 20:55:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495296#M141119</guid>
      <dc:creator>matoulas</dc:creator>
      <dc:date>2020-03-12T20:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495297#M141120</link>
      <description>&lt;P&gt;You're welcome!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 20:59:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495297#M141120</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-12T20:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495298#M141121</link>
      <description>&lt;P&gt;How to display or add location, siteid append to the column. &lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 21:20:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495298#M141121</guid>
      <dc:creator>matoulas</dc:creator>
      <dc:date>2020-03-12T21:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495299#M141122</link>
      <description>&lt;P&gt;Another way.&lt;/P&gt;

&lt;P&gt;How to add a column to the results table based on an existing field above like loction, siteid and etc...?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 21:49:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495299#M141122</guid>
      <dc:creator>matoulas</dc:creator>
      <dc:date>2020-03-12T21:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495300#M141123</link>
      <description>&lt;P&gt;Then it's better to use regex to extract fields and values. I updated answer. Try that.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 06:06:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495300#M141123</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-13T06:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495301#M141124</link>
      <description>&lt;P&gt;It worked! Thanks again for all your help!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 17:57:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495301#M141124</guid>
      <dc:creator>matoulas</dc:creator>
      <dc:date>2020-03-13T17:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495302#M141125</link>
      <description>&lt;P&gt;You're welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 18:41:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495302#M141125</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-13T18:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract JSON data format using extract field in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495303#M141126</link>
      <description>&lt;P&gt;One last question? All the column table that were append to it like location, siteid and etc. The result show two data entry for every row. How to make it to not duplicate the data.  Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 20:03:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-data-format-using-extract-field-in-Splunk/m-p/495303#M141126</guid>
      <dc:creator>matoulas</dc:creator>
      <dc:date>2020-03-13T20:03:52Z</dc:date>
    </item>
  </channel>
</rss>

