<?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 I extract these fields and corresponding values parsing while JSON data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264807#M79524</link>
    <description>&lt;P&gt;You can create aliases as suggested of you can rename the fields in your search &lt;CODE&gt;rename *.#text AS *&lt;/CODE&gt; will rename all &amp;lt;&amp;gt;.#text to &amp;lt;&amp;gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2016 04:04:41 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-12-07T04:04:41Z</dc:date>
    <item>
      <title>How do I extract these fields and corresponding values parsing while JSON data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264803#M79520</link>
      <description>&lt;P&gt;I have a following JSON input.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
    "StartTime": {
        "@item": "1",
        "#text": "2016/11/21 09:35:25"
    },
    "Encryption": {
        "@item": "1",
        "#text": "None"
    },
    "Duration": {
        "@item": "1",
        "#text": "13"
    },
    "DisplayName": {
        "@item": "1",
        "#text": "80081"
    },
    "device_id": 1
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to extract fields like below and ignore the rest (@item) from JSON.&lt;BR /&gt;
device_id = 1&lt;BR /&gt;
DisplayName=80081&lt;BR /&gt;
Duration=13&lt;BR /&gt;
Encryption=None&lt;BR /&gt;
StartTime="2016/11/21 09:35:25"&lt;/P&gt;

&lt;P&gt;Can it be done writing a single Regex to extract all the fields, or do I need to write separate regex for each field in TRANSFORMS.CONF ?&lt;/P&gt;

&lt;P&gt;Any example will help.&lt;BR /&gt;
/Sarfaraj&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 02:00:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264803#M79520</guid>
      <dc:creator>sarfarajsayyad</dc:creator>
      <dc:date>2016-12-07T02:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields and corresponding values parsing while JSON data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264804#M79521</link>
      <description>&lt;P&gt;If it is valid JSON, add this to your props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ stanza]
KV_MODE = json
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2016 02:31:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264804#M79521</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-12-07T02:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields and corresponding values parsing while JSON data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264805#M79522</link>
      <description>&lt;P&gt;Dear, I have added that already. &lt;BR /&gt;
By default its giving me columns like &lt;STRONG&gt;StartTime.@item&lt;/STRONG&gt; , &lt;STRONG&gt;StartTime.#text&lt;/STRONG&gt;. But i need only &lt;STRONG&gt;StartTime&lt;/STRONG&gt; having value of &lt;STRONG&gt;StartTime.#text&lt;/STRONG&gt;. Something like &lt;STRONG&gt;StartTime&lt;/STRONG&gt;="2016/11/21 09:35:25".&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 03:21:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264805#M79522</guid>
      <dc:creator>sarfarajsayyad</dc:creator>
      <dc:date>2016-12-07T03:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields and corresponding values parsing while JSON data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264806#M79523</link>
      <description>&lt;P&gt;If they're already parsed like that, why not just create a simple alias for them, like they explain in &lt;A href="https://answers.splunk.com/answers/286994/is-there-a-way-to-use-kv-modejson-and-eliminate-on.html"&gt;this answer&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 03:28:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264806#M79523</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-12-07T03:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields and corresponding values parsing while JSON data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264807#M79524</link>
      <description>&lt;P&gt;You can create aliases as suggested of you can rename the fields in your search &lt;CODE&gt;rename *.#text AS *&lt;/CODE&gt; will rename all &amp;lt;&amp;gt;.#text to &amp;lt;&amp;gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 04:04:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264807#M79524</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-12-07T04:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields and corresponding values parsing while JSON data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264808#M79525</link>
      <description>&lt;P&gt;Like @Sundaresh mentions to get them extracted automatically, but here are the ways to do this in search time (brute force) if really required&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Using spath:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
| spath output=device_id path=device_id
| spath output=startTime path=StartTime.#text 
| spath output=encryption path=Encryption.#text 
| spath output=duration path=Duration.#text 
| spath output=displayName path=DisplayName.#text 
| table device_id, startTime, encryption, duration, displayName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Using rex:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
| rex field=_raw max_match=0 "\#text\"\:\s\"(?&amp;lt;jsonFields&amp;gt;[^\"]+)"
| rex field=_raw "device_id\"\:\s*(?&amp;lt;device_id&amp;gt;[\S]+)"
| eval startTime=mvindex(jsonFields, 0)
| eval encryption=mvindex(jsonFields, 1)
| eval duration=mvindex(jsonFields, 2)
| eval displayName=mvindex(jsonFields, 3)
| table startTime, encryption, duration, displayName, device_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2016 04:13:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264808#M79525</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-07T04:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields and corresponding values parsing while JSON data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264809#M79526</link>
      <description>&lt;P&gt;Thank you ! Is there any way to do it in index time ? &lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 08:56:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-and-corresponding-values-parsing/m-p/264809#M79526</guid>
      <dc:creator>sarfarajsayyad</dc:creator>
      <dc:date>2016-12-07T08:56:13Z</dc:date>
    </item>
  </channel>
</rss>

