<?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 Parsing JSON fields from log files and create dashboard charts in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238602#M45086</link>
    <description>&lt;P&gt;I have following file containing JSON :&lt;BR /&gt;
Aug 22 13:50:15 192.168.10.100        {"NETFLOW" : [{"IPSA":"00000000","IPDA":"00000000","L4SP":"0000","L4DP":"0000","PROT":"17","MPLS":"00000","PKTS":"00000001","BYTS":"00000042"},{"IPSA":"ce8f722f","IPDA":"b5da2748","L4SP":"d52a","L4DP":"d52a","PROT":"6","MPLS":"00000","PKTS":"00000003","BYTS":"00000116"}]}&lt;/P&gt;

&lt;P&gt;The JSON contains array of netflows.&lt;/P&gt;

&lt;P&gt;Every line of JSON is preceded by timestamp and IP address from which the record originated.&lt;/P&gt;

&lt;P&gt;I want to create a PIE chart containing count of different values of protocols (field : PROT in JSON).  (e.g. In above PROT:17 is one netflow record and PROT:6 is another).  The JSON itself is array of such elements and we would have the JSON line logged every second.&lt;/P&gt;

&lt;P&gt;I am completely new to Splunk (Using Splunk Enterprise)and from my initial reading looks like I can do it by defining field extraction.  But I am completely confused on how to use it.    Also the IPSA field is HEX and I would want to convert it into DECIMAL and I do not know how to do it in splunk.&lt;/P&gt;

&lt;P&gt;Can somebody help me in directing how basically the JSON field extraction can be achieved such that I can create PIVOT and use it to create charts.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Sep 2015 05:34:00 GMT</pubDate>
    <dc:creator>girishkhadke</dc:creator>
    <dc:date>2015-09-24T05:34:00Z</dc:date>
    <item>
      <title>Parsing JSON fields from log files and create dashboard charts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238602#M45086</link>
      <description>&lt;P&gt;I have following file containing JSON :&lt;BR /&gt;
Aug 22 13:50:15 192.168.10.100        {"NETFLOW" : [{"IPSA":"00000000","IPDA":"00000000","L4SP":"0000","L4DP":"0000","PROT":"17","MPLS":"00000","PKTS":"00000001","BYTS":"00000042"},{"IPSA":"ce8f722f","IPDA":"b5da2748","L4SP":"d52a","L4DP":"d52a","PROT":"6","MPLS":"00000","PKTS":"00000003","BYTS":"00000116"}]}&lt;/P&gt;

&lt;P&gt;The JSON contains array of netflows.&lt;/P&gt;

&lt;P&gt;Every line of JSON is preceded by timestamp and IP address from which the record originated.&lt;/P&gt;

&lt;P&gt;I want to create a PIE chart containing count of different values of protocols (field : PROT in JSON).  (e.g. In above PROT:17 is one netflow record and PROT:6 is another).  The JSON itself is array of such elements and we would have the JSON line logged every second.&lt;/P&gt;

&lt;P&gt;I am completely new to Splunk (Using Splunk Enterprise)and from my initial reading looks like I can do it by defining field extraction.  But I am completely confused on how to use it.    Also the IPSA field is HEX and I would want to convert it into DECIMAL and I do not know how to do it in splunk.&lt;/P&gt;

&lt;P&gt;Can somebody help me in directing how basically the JSON field extraction can be achieved such that I can create PIVOT and use it to create charts.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 05:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238602#M45086</guid>
      <dc:creator>girishkhadke</dc:creator>
      <dc:date>2015-09-24T05:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing JSON fields from log files and create dashboard charts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238603#M45087</link>
      <description>&lt;P&gt;I am using Splunk 6.2.5&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 05:37:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238603#M45087</guid>
      <dc:creator>girishkhadke</dc:creator>
      <dc:date>2015-09-24T05:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing JSON fields from log files and create dashboard charts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238604#M45088</link>
      <description>&lt;P&gt;Is there anybody that can answer this question?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Sep 2015 20:21:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238604#M45088</guid>
      <dc:creator>girishkhadke</dc:creator>
      <dc:date>2015-09-27T20:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing JSON fields from log files and create dashboard charts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238605#M45089</link>
      <description>&lt;P&gt;For the JSON field extractions, I think INDEXED_EXTRACTIONS configuration in props.conf might lead you in the right path. The spec for props has more info here : &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;To convert from hex to decimal, you can use the tonumber eval function described here : &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 01:20:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238605#M45089</guid>
      <dc:creator>muebel</dc:creator>
      <dc:date>2015-09-28T01:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing JSON fields from log files and create dashboard charts</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238606#M45090</link>
      <description>&lt;P&gt;@girishkhadke &lt;/P&gt;

&lt;P&gt;I worked upon a similar json data format except for the HEX to Number conversion, &lt;BR /&gt;
I took the following steps to obtain pie-charts , &lt;STRONG&gt;I guess you can make a similar attempt too&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;My JSon format :---- P.S. The original format is huge, so i kept this short, you may find field names missing with the query associated below.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;{&lt;BR /&gt;
     "thread": "7", &lt;BR /&gt;
     "level": "INFO" , &lt;BR /&gt;
     "eventTime": "2015-08-13 15:05:51.1162752", &lt;BR /&gt;
     "message": &lt;BR /&gt;
                {&lt;BR /&gt;
                    "date": "Thu Aug 13 2015 15:05:50 GMT-0500 (Central Daylight Time)",&lt;BR /&gt;
                    "id": "btnvoe",&lt;BR /&gt;
                    "outerText": "EMPLOYMENT",&lt;BR /&gt;
                    "eventType": "click",&lt;BR /&gt;
                    "transactionId": "9c9a713a-ae01-4299-8577-ee9293730f0c",&lt;BR /&gt;
                    "browserName": "Chrome",&lt;BR /&gt;
                    "browserVersion": "44",&lt;BR /&gt;
                    "pageName": "Verification",&lt;BR /&gt;
                    "oSNameVersion": "Windows 7",&lt;BR /&gt;
                } &lt;BR /&gt;
}&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I guess you don't need to go for separate field extractions which usually results into regex patterns.&lt;BR /&gt;
You can try SPATH command , basically it works like pulling out fields in the form of Object DOT attribute name.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Here's my query.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;index=csfindex_apilogger message.pageName=Instant OR message.pageName=InstantIncome message.id=btnNext message.appName=CSF-Poc&lt;BR /&gt;
|table _time,message.sessionId,message.userName,message.id,message.pageName &lt;BR /&gt;
|spath&lt;BR /&gt;&lt;BR /&gt;
|rename message.sessionId as sessionId,message.userName as userName,message.id as id&lt;BR /&gt;
|where len(sessionId)&amp;gt;0 &lt;BR /&gt;
|eval userName= if(len(userName)=0 or isnull(userName),"Unknown user",userName)&lt;BR /&gt;
|dedup sessionId,userName&lt;BR /&gt;
|chart count(sessionId) as TotalSessions over userName &lt;BR /&gt;
|sort-TotalSessions&lt;BR /&gt;&lt;BR /&gt;
|streamstats count as rank &lt;BR /&gt;
|search rank&amp;gt;=1 rank&amp;lt;=4&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;after using spath just pullout whatever json fields you need and table them for further operations.&lt;BR /&gt;
Here you can also declare an eval command to switch the HEX to number , refer their documentation for the appropriate command set.&lt;/P&gt;

&lt;P&gt;And for creating pies , one must have 1 count field against a group by &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 09:54:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Parsing-JSON-fields-from-log-files-and-create-dashboard-charts/m-p/238606#M45090</guid>
      <dc:creator>Suryadeep</dc:creator>
      <dc:date>2015-09-28T09:54:15Z</dc:date>
    </item>
  </channel>
</rss>

