<?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: JSON Data Query in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359500#M65594</link>
    <description>&lt;P&gt;@cblanton - We did not pursue the props.conf/transforms.conf referenced below. To be brutally honest, I had completely forgotten about this query. Either the need/requirement for it was re-stated or it was no longer relevant.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 15:09:30 GMT</pubDate>
    <dc:creator>kenmcgarrahan</dc:creator>
    <dc:date>2020-04-07T15:09:30Z</dc:date>
    <item>
      <title>JSON Data Query</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359495#M65589</link>
      <description>&lt;P&gt;We are ingesting JSON data similar to the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
   "Id":"987654321",
   "data":[
      {
         "answer":"12345",
         "label":"Work Order"
      },
      {
         "answer":"04/01/2018",
         "label":"Work Order Date"
      },
      {
         "answer":"15:17:00",
         "label":"Order Time"
      },
      .
      .    (more answer/label elements)
      .
   ],
   "username":"some.user"
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Entirely possible we're missing it in the spath and related JSON processing documentation, but we're unable to determine how to format a search query which allows use of the "label" value as the left-hand side and the "answer" value as the right-hand side of a query (e.g., "Work Order Date"="04/01/2018").&lt;/P&gt;

&lt;P&gt;The JSON array contains additional answer/label pairs with other date values, so specifying something like 'data{}.answer="04/01/2018"' is insufficient, as it matches any event where that date appears as any 'answer' value.&lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 19:58:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359495#M65589</guid>
      <dc:creator>kenmcgarrahan</dc:creator>
      <dc:date>2018-04-24T19:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Data Query</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359496#M65590</link>
      <description>&lt;P&gt;What is the desired outcome?  Are you trying to split the data array into individual events?  Technically, for the example you gave, you could do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base_search data{}.label="Work Order Date" data{}.answer="04/01/2018"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But, that still just returns the entire event.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 21:00:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359496#M65590</guid>
      <dc:creator>jconger</dc:creator>
      <dc:date>2018-04-24T21:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Data Query</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359497#M65591</link>
      <description>&lt;P&gt;Splunk isn't going to inherently know that you want the label field to equal the answer field....but you can tell it.   On your search head, configure props/transforms to extract those fields.&lt;/P&gt;

&lt;P&gt;i didn't test it, but something like this.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
REPORT-labels_answers = extract_labels_answers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_labels_answers]
REGEX = "answer":"([^"]+)",[^"]+"label":"([^"]+)
FORMAT = $2::$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should extract each answer/label pair and then a create a field for the value of label and set it to the value of answer.  At that point, you should be able to filter the way you'd like.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 21:43:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359497#M65591</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2018-04-24T21:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Data Query</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359498#M65592</link>
      <description>&lt;P&gt;Ideally, we'd end up with a table where each event was a row, with each 'label' value a named column whose value is the 'answer' value. With apologies for the formatting, something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Id                      username     Work Order     Work Order Date     Order Time     Completion Date
987654321     some.user     12345               04/01/2018               15:17:00           04/01/2018
987654322     other.user     12346               04/01/2018               16:00:00           04/03/2018
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The JSON 'data' array is a list of attributes which varies in content across events. Being able to report and filter results off those attributes is the target.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 15:25:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359498#M65592</guid>
      <dc:creator>kenmcgarrahan</dc:creator>
      <dc:date>2018-04-25T15:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Data Query</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359499#M65593</link>
      <description>&lt;P&gt;@kenmcgarrahan did you ever come up with a better solution than the configurations below? I have the same issue.&lt;/P&gt;

&lt;P&gt;I see this post from 2016 describes the same. &lt;A href="https://www.splunk.com/en_us/blog/tips-and-tricks/eureka-extracting-key-value-pairs-from-json-fields.html"&gt;https://www.splunk.com/en_us/blog/tips-and-tricks/eureka-extracting-key-value-pairs-from-json-fields.html&lt;/A&gt; @LCM any chance you know if the native capability mentioned, ever materialized?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 19:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359499#M65593</guid>
      <dc:creator>cblanton</dc:creator>
      <dc:date>2020-04-03T19:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Data Query</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359500#M65594</link>
      <description>&lt;P&gt;@cblanton - We did not pursue the props.conf/transforms.conf referenced below. To be brutally honest, I had completely forgotten about this query. Either the need/requirement for it was re-stated or it was no longer relevant.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 15:09:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/JSON-Data-Query/m-p/359500#M65594</guid>
      <dc:creator>kenmcgarrahan</dc:creator>
      <dc:date>2020-04-07T15:09:30Z</dc:date>
    </item>
  </channel>
</rss>

