<?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 do you solve a problem like Json in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423459#M74353</link>
    <description>&lt;P&gt;This does exactly as expected!&lt;BR /&gt;
Thank you so much.&lt;BR /&gt;
I'm starting to get a better appreciation for json now, just wish it were easier to search on in splunk&lt;/P&gt;</description>
    <pubDate>Fri, 15 Feb 2019 17:23:37 GMT</pubDate>
    <dc:creator>Lazarix</dc:creator>
    <dc:date>2019-02-15T17:23:37Z</dc:date>
    <item>
      <title>How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423448#M74342</link>
      <description>&lt;P&gt;I'm having serious issues in Splunk related to searching Json structures.&lt;BR /&gt;
I really don't understand why Json isn't easier to search, considering that Splunk recognises the structure and allows you to expand it in syntax highlighted mode.&lt;/P&gt;

&lt;P&gt;The issue that i'm having is that it appears to be impossible to search for a simple table of &lt;BR /&gt;
&lt;CODE&gt;value.data.timestamp value.name.localizedValue value.data.count&lt;/CODE&gt;&lt;BR /&gt;
ultimately across multiple value.name.localizedValue entries, in order to try and do a timechart that shows metrics over time, or to be able to use this data inside ITSI as metrics for KPIs.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://i.imgur.com/Alm6itp.png" alt="alt text" /&gt;&lt;BR /&gt;
Above is one expanded &lt;CODE&gt;data&lt;/CODE&gt; node, of which inside this &lt;CODE&gt;value&lt;/CODE&gt; node, there are multiple &lt;CODE&gt;data&lt;/CODE&gt; nodes each with this structure. Each &lt;CODE&gt;data&lt;/CODE&gt;node contains one type of &lt;CODE&gt;name.localizedValue&lt;/CODE&gt; (effectively the metric name).&lt;BR /&gt;
I have tried, unsuccessfully, to use spath and mvexpand (admittantly, i don't fully understand these commands, and how they are used to their best effect) and I can't get them to format the data in the way i want to display it. But at the same time, why should we have to put over 500 characters into a search bar in order to search this type of structured data?&lt;BR /&gt;
If the solution is ultimately to flatten the data so that you can search it, why have json at all?&lt;/P&gt;

&lt;P&gt;The way i'd expect to see the data is like:&lt;BR /&gt;
Table:&lt;BR /&gt;
| value.data.timestamp | value.name.localizedValue | value.data.count &lt;BR /&gt;
| 2019-01-23T13:10:00Z | CPU Time | 15&lt;BR /&gt;
| 2019-01-23T13:11:00Z | CPU Time | 16&lt;/P&gt;

&lt;P&gt;As an aside, is there any way to make this process easier?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 09:57:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423448#M74342</guid>
      <dc:creator>Lazarix</dc:creator>
      <dc:date>2019-01-24T09:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423449#M74343</link>
      <description>&lt;P&gt;did you try using &lt;CODE&gt;spath&lt;/CODE&gt; command? &lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/7.2.3/SearchReference/Spath"&gt;https://docs.splunk.com/Documentation/SplunkCloud/7.2.3/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 10:01:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423449#M74343</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-01-24T10:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423450#M74344</link>
      <description>&lt;P&gt;@Lazarix&lt;/P&gt;

&lt;P&gt;Can you please share sample JSON event? So we can help you.  &lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 10:03:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423450#M74344</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-01-24T10:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423451#M74345</link>
      <description>&lt;P&gt;Generically, Splunk works best with more atomic events so to say. So events with a single timestamp and then some fields with values. Formatting that as json works fine.&lt;/P&gt;

&lt;P&gt;Splunk doesn't work as easily when you have events like this, that actually contain multiple events (or data points) in one. You'll then need to do some processing to split that out. Not impossible, but not always very straightforward if you're not too experienced with it.&lt;/P&gt;

&lt;P&gt;It would help if you could share a sample raw json event, so we can play a bit with that and give you some suggestions on how to best split it into the individual data points.&lt;/P&gt;

&lt;P&gt;On a high level, what I would try is to extract the entire data points into a multi valued field 'data', then mvexpand on that field, then parse out the individual fields of the data point (time, count), parse the timestamp and assign it to _time. Then you should be able to apply the timechart command.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 10:12:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423451#M74345</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-01-24T10:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423452#M74346</link>
      <description>&lt;P&gt;&lt;A href="https://gist.github.com/IanMoroney/34369128701f67ce0a1b159332356665"&gt;https://gist.github.com/IanMoroney/34369128701f67ce0a1b159332356665&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 10:48:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423452#M74346</guid>
      <dc:creator>Lazarix</dc:creator>
      <dc:date>2019-01-24T10:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423453#M74347</link>
      <description>&lt;P&gt;As mentioned in the question, yes i did and I also tried combinations of spath and mvexpand.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 10:49:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423453#M74347</guid>
      <dc:creator>Lazarix</dc:creator>
      <dc:date>2019-01-24T10:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423454#M74348</link>
      <description>&lt;P&gt;Thanks for the information Frank.&lt;BR /&gt;
I've uploaded an example of the json here:&lt;BR /&gt;
&lt;A href="https://gist.github.com/IanMoroney/34369128701f67ce0a1b159332356665"&gt;https://gist.github.com/IanMoroney/34369128701f67ce0a1b159332356665&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I understand the approach around atomic data points, and I agree that splunk is more suited to that. I suppose i wouldn't expect to be forced to flatten a structured relational data source in order to read it, as the associations are contained within the structure.&lt;BR /&gt;
but, you live and learn!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 10:53:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423454#M74348</guid>
      <dc:creator>Lazarix</dc:creator>
      <dc:date>2019-01-24T10:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423455#M74349</link>
      <description>&lt;P&gt;@Lazarix &lt;/P&gt;

&lt;P&gt;Can you please try below search??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | spath path=value{} output=data | mvexpand data | eval _raw= data | kv | spath path=data{} output=data | mvexpand data | eval _raw=data | kv | table id "name.localizedValue" "name.value" type unit data timeStamp count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;My Sample Search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="{\"value\": [{\"data\": [{\"timeStamp\": \"2019-01-23T13:10:00Z\",\"count\": 15.0},{\"timeStamp\": \"2019-01-23T13:11:00Z\",\"count\": 16.0},{\"timeStamp\": \"2019-01-23T13:12:00Z\",\"count\": 15.0},{\"timeStamp\": \"2019-01-23T13:13:00Z\",\"count\": 12.0},{\"timeStamp\": \"2019-01-23T13:14:00Z\",\"count\": 13.0}],\"id\": \"1\",\"name\": {\"value\": \"CpuTime\",\"localizedValue\": \"CPU Time\"},\"type\": \"Microsoft.Insights/metrics\",\"unit\": \"Seconds\"},{\"data\": [{\"timeStamp\": \"2019-01-23T13:10:00Z\",\"count\": 2.0},{\"timeStamp\": \"2019-01-23T13:11:00Z\",\"count\": 3.0},{\"timeStamp\": \"2019-01-23T13:12:00Z\",\"count\": 2.0},{\"timeStamp\": \"2019-01-23T13:13:00Z\",\"count\": 2.0},{\"timeStamp\": \"2019-01-23T13:14:00Z\",\"count\": 2.0}],\"id\": \"2\",\"name\": {\"value\": \"Requests\",\"localizedValue\": \"Requests\"},\"type\": \"Microsoft.Insights/metrics\",\"unit\": \"Count\"},{\"data\": [{\"timeStamp\": \"2019-01-23T13:10:00Z\",\"count\": 12.0},{\"timeStamp\": \"2019-01-23T13:11:00Z\",\"count\": 12.0},{\"timeStamp\": \"2019-01-23T13:12:00Z\",\"count\": 12.0},{\"timeStamp\": \"2019-01-23T13:13:00Z\",\"count\": 12.0},{\"timeStamp\": \"2019-01-23T13:14:00Z\",\"count\": 12.0}],\"id\": \"3\",\"name\": {\"value\": \"AppConnections\",\"localizedValue\": \"Connections\"},\"type\": \"Microsoft.Insights/metrics\",\"unit\": \"Count\"},{\"data\": [{\"timeStamp\": \"2019-01-23T13:10:00Z\",\"count\": 0.0},{\"timeStamp\": \"2019-01-23T13:11:00Z\",\"count\": 0.0},{\"timeStamp\": \"2019-01-23T13:12:00Z\",\"count\": 0.0},{\"timeStamp\": \"2019-01-23T13:13:00Z\",\"count\": 0.0},{\"timeStamp\": \"2019-01-23T13:14:00Z\",\"count\": 0.0}],\"id\": \"4\",\"name\": {\"value\": \"Http4xx\",\"localizedValue\": \"Http 4xx\"},\"type\": \"Microsoft.Insights/metrics\",\"unit\": \"Count\"},{\"data\": [{\"timeStamp\": \"2019-01-23T13:10:00Z\",\"count\": 0.0},{\"timeStamp\": \"2019-01-23T13:11:00Z\",\"count\": 0.0},{\"timeStamp\": \"2019-01-23T13:12:00Z\",\"count\": 0.0},{\"timeStamp\": \"2019-01-23T13:13:00Z\",\"count\": 0.0},{\"timeStamp\": \"2019-01-23T13:14:00Z\",\"count\": 0.0}],\"id\": \"5\",\"name\": {\"value\": \"Http5xx\",\"localizedValue\": \"Http Server Errors\"},\"type\": \"Microsoft.Insights/metrics\",\"unit\": \"Count\"},{\"data\": [{\"timeStamp\": \"2019-01-23T13:10:00Z\",\"count\": 17.0},{\"timeStamp\": \"2019-01-23T13:11:00Z\",\"count\": 17.0},{\"timeStamp\": \"2019-01-23T13:12:00Z\",\"count\": 18.0},{\"timeStamp\": \"2019-01-23T13:13:00Z\",\"count\": 13.0},{\"timeStamp\": \"2019-01-23T13:14:00Z\",\"count\": 17.0}],\"id\": \"6\",\"name\": {\"value\": \"MemoryWorkingSet\",\"localizedValue\": \"Memory working set\"},\"type\": \"Microsoft.Insights/metrics\",\"unit\": \"Bytes\"},{\"data\": [{\"timeStamp\": \"2019-01-23T13:10:00Z\",\"count\": 2.0},{\"timeStamp\": \"2019-01-23T13:11:00Z\",\"count\": 3.0},{\"timeStamp\": \"2019-01-23T13:12:00Z\",\"count\": 2.0},{\"timeStamp\": \"2019-01-23T13:13:00Z\",\"count\": 2.0},{\"timeStamp\": \"2019-01-23T13:14:00Z\",\"count\": 2.0}],\"id\": \"7\",\"name\": {\"value\": \"AverageResponseTime\",\"localizedValue\": \"Average Response Time\"},\"type\": \"Microsoft.Insights/metrics\",\"unit\": \"Seconds\"}]}" | spath path=value{} output=data | mvexpand data | eval _raw= data | kv | spath path=data{} output=data | mvexpand data | eval _raw=data | kv | table id "name.localizedValue" "name.value" type unit data timeStamp count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 11:32:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423455#M74349</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-01-24T11:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423456#M74350</link>
      <description>&lt;P&gt;Ok, so there is even different measurements in the same event.&lt;/P&gt;

&lt;P&gt;So:&lt;BR /&gt;
step 1: split out the different measurements (value{})&lt;BR /&gt;
step 2: extract the name of each measurement (name.value) and split out the datapoints (data{})&lt;BR /&gt;
step 3: extract the timestamp and count of each data point&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...your search to get to this data...
| spath output=value path=value{} 
| table value 
| mvexpand value 
| spath input=value path=name.value output=name 
| spath input=value path=data{} output=data 
| table data,name 
| mvexpand data 
| spath input=data 
| fields - data 
| eval _time = strptime(timeStamp,"%Y-%m-%dT%H:%M:%S%Z")
| table _time,name,count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Jan 2019 11:46:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423456#M74350</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-01-24T11:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423457#M74351</link>
      <description>&lt;P&gt;Took this as an exercise in my spare time, but to be honest, I'm sceptical how well this scales.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your search for events...
| fields _time _raw
| spath path="value{}" 
| mvexpand value{} 
| streamstats count AS level1 
| eval _raw='value{}' 
| spath 
| fields - _raw 
| mvexpand data{}.timeStamp 
| streamstats count AS level2 BY level1 
| eval value=mvindex('data{}.count',level2-1) 
| eval _time=strptime(('data{}.timeStamp'),"%Y-%m-%dT%H:%M:%S%Z") 
| fields _time value name.* type unit 
| table *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Feb 2019 18:50:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423457#M74351</guid>
      <dc:creator>mhoogcarspel_sp</dc:creator>
      <dc:date>2019-02-02T18:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423458#M74352</link>
      <description>&lt;P&gt;Field aliases helped us a lot. Something like - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FIELDALIAS-alias01 = "apiRequest.reqInfo.clientID" AS clientID
FIELDALIAS-alias02 = "apiResponse.apiResponse.services{}.servHttpStatus" AS servHttpStatus
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Feb 2019 21:07:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423458#M74352</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2019-02-02T21:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do you solve a problem like Json</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423459#M74353</link>
      <description>&lt;P&gt;This does exactly as expected!&lt;BR /&gt;
Thank you so much.&lt;BR /&gt;
I'm starting to get a better appreciation for json now, just wish it were easier to search on in splunk&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:23:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-solve-a-problem-like-Json/m-p/423459#M74353</guid>
      <dc:creator>Lazarix</dc:creator>
      <dc:date>2019-02-15T17:23:37Z</dc:date>
    </item>
  </channel>
</rss>

