<?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 expand the values as separate events in my JSON data? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433555#M75778</link>
    <description>&lt;P&gt;@Nadhiyaa what do you mean by dummy data!If that is with respect to my query, you just need to remove first two pipes i.e. &lt;CODE&gt;makeresults&lt;/CODE&gt; and &lt;CODE&gt;eval _raw&lt;/CODE&gt; from the sample query and place your main search instead i.e. &lt;CODE&gt;index=..&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=.....
 | rename results{}.series{}.*{} as *, results{}.series{}.*{}{} as * 
 | eval data=mvzip(columns, values) 
 | mvexpand data 
 | makemv data delim="," 
 | eval columns=mvindex(data,0),values=mvindex(data,1) 
 | fields - data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Aug 2018 10:27:44 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-08-29T10:27:44Z</dc:date>
    <item>
      <title>How to expand the values as separate events in my JSON data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433551#M75774</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "sqlserver_server_properties",
                    "columns": [
                        "time",
                        "last"
                    ],
                    "values": [
                        [
                            "2018-08-07T00:00:00Z",
                            144
                        ]}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is my json data . I extracted the time and last using index=..|spath output=time path=results{}.series{}.values{}{0}|spath output=count1 path=results{}.series{}.values{}{1}&lt;/P&gt;

&lt;P&gt;I want to expand the values as separate events.&lt;/P&gt;

&lt;P&gt;Help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 06:01:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433551#M75774</guid>
      <dc:creator>Nadhiyaa</dc:creator>
      <dc:date>2018-08-29T06:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to expand the values as separate events in my JSON data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433552#M75775</link>
      <description>&lt;P&gt;@Nadhiyaa based on sample JSON data (I have modified a bit to add &lt;CODE&gt;]&lt;/CODE&gt; to format as valid JSON), please try the following run anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| fields - _time 
| eval _raw="{
\"results\": [
{
\"statement_id\": 0,
\"series\": [
{
\"name\": \"sqlserver_server_properties\",
\"columns\": [
\"time\",
\"last\"
    ],
\"values\": [
[
\"2018-08-07T00:00:00Z\",
144
]]}]}]}"
| spath 
| rename results{}.series{}.*{} as *, results{}.series{}.*{}{} as * 
| eval data=mvzip(columns, values) 
| mvexpand data 
| makemv data delim="," 
| eval columns=mvindex(data,0),values=mvindex(data,1) 
| fields - data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: command from &lt;CODE&gt;| makeresults&lt;/CODE&gt; till &lt;CODE&gt;| spath&lt;/CODE&gt; generates dummy data and fields. You should define &lt;CODE&gt;KV_MODE=json&lt;/CODE&gt; in the props.conf to have all the JSON fields automatically extracted during search time.&lt;BR /&gt;
The &lt;CODE&gt;mvzip&lt;/CODE&gt; command is used to bring multivalued fields together (unless there is one to one mapping in the &lt;CODE&gt;columns&lt;/CODE&gt; and &lt;CODE&gt;values&lt;/CODE&gt; fields, this approach will not work and dummy value needs to be inserted at search time or index time (from source if possible). &lt;BR /&gt;
Then &lt;CODE&gt;mvexpand&lt;/CODE&gt; splits them in two rows. Finally, &lt;CODE&gt;makemv&lt;/CODE&gt; and eval with &lt;CODE&gt;mvindex()&lt;/CODE&gt; is used to get the original &lt;CODE&gt;columns&lt;/CODE&gt; and &lt;CODE&gt;values&lt;/CODE&gt; field values back.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 06:33:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433552#M75775</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-29T06:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to expand the values as separate events in my JSON data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433553#M75776</link>
      <description>&lt;P&gt;Hi @niketnilay &lt;/P&gt;

&lt;P&gt;I validated the json and provided kvmode as json.&lt;/P&gt;

&lt;P&gt;got the ouput below using &lt;BR /&gt;
|spath output=time path=results{}.series{}.values{}{0}|spath output=last path=results{}.series{}.values{}{1}&lt;BR /&gt;
|eval time=strptime(time,"%Y-%m-%dT%H:%M:%SZ")|search count1!=null|table &lt;/P&gt;

&lt;P&gt;Its coming as multivalue fields i want to have one to one in the separate rows.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 07:24:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433553#M75776</guid>
      <dc:creator>Nadhiyaa</dc:creator>
      <dc:date>2018-08-29T07:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to expand the values as separate events in my JSON data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433554#M75777</link>
      <description>&lt;P&gt;@niketnilay How to avoid dummy data and fields .however i defined KV_MODE=json in the props.conf.Does this avoid dummy data &lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 09:53:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433554#M75777</guid>
      <dc:creator>Nadhiyaa</dc:creator>
      <dc:date>2018-08-29T09:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to expand the values as separate events in my JSON data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433555#M75778</link>
      <description>&lt;P&gt;@Nadhiyaa what do you mean by dummy data!If that is with respect to my query, you just need to remove first two pipes i.e. &lt;CODE&gt;makeresults&lt;/CODE&gt; and &lt;CODE&gt;eval _raw&lt;/CODE&gt; from the sample query and place your main search instead i.e. &lt;CODE&gt;index=..&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=.....
 | rename results{}.series{}.*{} as *, results{}.series{}.*{}{} as * 
 | eval data=mvzip(columns, values) 
 | mvexpand data 
 | makemv data delim="," 
 | eval columns=mvindex(data,0),values=mvindex(data,1) 
 | fields - data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Aug 2018 10:27:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-expand-the-values-as-separate-events-in-my-JSON-data/m-p/433555#M75778</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-29T10:27:44Z</dc:date>
    </item>
  </channel>
</rss>

