<?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 convert an event INTO JSON in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288300#M55097</link>
    <description>&lt;P&gt;Hello @kcepull2 - Thank you for sharing this question and providing a solution. Do you think you can put the solution as an answer below so it can be Accepted? That way this question doesn't look like its unanswered forever? Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Thu, 11 May 2017 16:41:24 GMT</pubDate>
    <dc:creator>aaraneta_splunk</dc:creator>
    <dc:date>2017-05-11T16:41:24Z</dc:date>
    <item>
      <title>How to convert an event into JSON?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288299#M55096</link>
      <description>&lt;P&gt;[Not really a question, but wanted to document and share with the community...]&lt;/P&gt;
&lt;P&gt;So, I had a customer that liked how JSON events showed up in the Events tab on the Search screen (e.g. colored format, collapse/expand). He wanted events that weren't JSON to show up this way, too! (I tried to explain that wasn't the purpose of this screen, but it was an interesting exercise, so what the heck....)&lt;/P&gt;
&lt;P&gt;Here's what I came up with that will take any event, and format it as JSON so the Splunkweb JSON parser will kick in.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;your search here
| foreach * 
    [eval jsonmv_ = mvappend(jsonmv_,"\"&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;\":\"" + &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; + "\"")] 
| eval _raw = "{" + mvjoin(jsonmv_,",") + "}" 
| fields - jsonmv_
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting event(s) will be in JSON format, and will display with colors, etc. in Splunkweb.&lt;/P&gt;
&lt;P&gt;NOTE: This is a VERY inefficient thing to do! You are basically having Splunk parse the event into fields (field extractions), then munging all those field back together into a JSON-formatted string, THEN having Splunk parse the JSON back into fields.&lt;/P&gt;
&lt;P&gt;Like I said - an interesting exercise to see if it was possible, but not very useful in a production situation.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 12:48:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288299#M55096</guid>
      <dc:creator>kcepull2</dc:creator>
      <dc:date>2023-05-22T12:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an event INTO JSON</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288300#M55097</link>
      <description>&lt;P&gt;Hello @kcepull2 - Thank you for sharing this question and providing a solution. Do you think you can put the solution as an answer below so it can be Accepted? That way this question doesn't look like its unanswered forever? Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 16:41:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288300#M55097</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-05-11T16:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an event INTO JSON</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288301#M55098</link>
      <description>&lt;P&gt;Here's what I came up with that will take any event, and format it as JSON so the Splunkweb JSON parser will kick in.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your search here
 | foreach * 
     [eval jsonmv_ = mvappend(jsonmv_,"\"&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;\":\"" + &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; + "\"")] 
 | eval _raw = "{" + mvjoin(jsonmv_,",") + "}" 
 | fields - jsonmv_
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 May 2017 18:32:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288301#M55098</guid>
      <dc:creator>kcepull2</dc:creator>
      <dc:date>2017-05-11T18:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an event INTO JSON</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288302#M55099</link>
      <description>&lt;P&gt;Sure! Thanks for the suggestion. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 18:32:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/288302#M55099</guid>
      <dc:creator>kcepull2</dc:creator>
      <dc:date>2017-05-11T18:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an event INTO JSON</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/644050#M109675</link>
      <description>&lt;P&gt;getting below error when I tried your spl&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Failed to parse templatized search for field 'tag::eventtype'&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 May 2023 00:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-convert-an-event-into-JSON/m-p/644050#M109675</guid>
      <dc:creator>damode1</dc:creator>
      <dc:date>2023-05-22T00:40:56Z</dc:date>
    </item>
  </channel>
</rss>

