<?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 format json event data so that it can be written to a json log and then successfully indexed by Splunk? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621228#M107008</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/251361"&gt;@gut1kor&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Not sure I follow you :&lt;/P&gt;&lt;P&gt;- in the file, in each event if the field name is "host" it should be available just fine, no ?&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;- you need to put it in your inputs.conf with the monitor stanza =&amp;gt; as an option "host = ..." if it is the same one for all the data in the file.&lt;/P&gt;&lt;P&gt;Otherwise, I would suggest adding an alias between host and extracted host for your sourcetype.&lt;/P&gt;&lt;P&gt;What do you think ?&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 12:17:08 GMT</pubDate>
    <dc:creator>emallinger</dc:creator>
    <dc:date>2022-11-17T12:17:08Z</dc:date>
    <item>
      <title>How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621207#M107004</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I am new here and would like to find a way to tackle this problem. I have structured json events that I am able to push to http event collector and create dashboards. However, if I save the same json event data to a logfile and use the forwarder then Splunk is unable to extract the fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My sample json event is below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;{"time":1668673601179,&lt;/P&gt;&lt;P&gt;"host":"SAG-13X8573",&lt;/P&gt;&lt;P&gt;"event":&lt;/P&gt;&lt;P&gt;{"correlationid":"11223361",&lt;/P&gt;&lt;P&gt;"name":"API Start",&lt;/P&gt;&lt;P&gt;"apiName":"StatementsAPI",&lt;/P&gt;&lt;P&gt;"apiOperation":"getStatements",&lt;/P&gt;&lt;P&gt;"method":"GET",&lt;/P&gt;&lt;P&gt;"requestHeaders":&lt;/P&gt;&lt;P&gt;&amp;nbsp; {"Accept":"application/json",&lt;/P&gt;&lt;P&gt;&amp;nbsp; "Content-Type":"application/json"},&lt;/P&gt;&lt;P&gt;&amp;nbsp; "pathParams":&lt;/P&gt;&lt;P&gt;&amp;nbsp; {"customerID":"11223344"},&lt;/P&gt;&lt;P&gt;&amp;nbsp;"esbReqHeaders":&lt;/P&gt;&lt;P&gt;{"Accept":"application/json"}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if I post this to http event collector I am able to see the fields correctly like below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gut1kor_0-1668676008313.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22531i9D053A916A4F655A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gut1kor_0-1668676008313.png" alt="gut1kor_0-1668676008313.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;gut1kor_0-1668676008313.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I save the same json data to a log file and forwarder sends this data to Splunk, it couldn't parse the data properly. All I see is like below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gut1kor_1-1668676086604.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/22532i9290DDDB334A7F23/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gut1kor_1-1668676086604.png" alt="gut1kor_1-1668676086604.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;gut1kor_1-1668676086604.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The event fields are not extracted properly including the timestamp.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should I format the json data in any other way before writing it to log file? Or any other configurations need to be done to make it work? Pls let me know. Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 09:15:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621207#M107004</guid>
      <dc:creator>gut1kor</dc:creator>
      <dc:date>2022-11-17T09:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621221#M107005</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I think only the content of "event" in your example should be written in a file for a forwarder input monitor.&lt;/P&gt;&lt;P&gt;"time" and "host" are metadata that can be used in HEC entry but are not strictly necessary in files.&lt;/P&gt;&lt;P&gt;The host value in file monitor will be either the default hostname of the forwarder or the one you set in the monitor stanza for this particular file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have both entry types, and I can confirm the format is different.&lt;/P&gt;&lt;P&gt;In file : JSONL with only the content of your "event" example&lt;/P&gt;&lt;P&gt;In HEC entry points : same format as yours with a bunch of metadata, like sourcetype for the indexer to be able to correctly index the data source.&lt;/P&gt;&lt;P&gt;So you should make SURE that there is a timestamp/date field IN the event (and not outside of if as per your example).&lt;/P&gt;&lt;P&gt;Try it and post the results ?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ema&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 11:19:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621221#M107005</guid>
      <dc:creator>emallinger</dc:creator>
      <dc:date>2022-11-17T11:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621223#M107006</link>
      <description>&lt;P&gt;Hi Ema,&lt;/P&gt;&lt;P&gt;thank you very much. I will try this and post the results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we want the hostname as well in the event data, is it possible to make Splunk use it?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 11:29:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621223#M107006</guid>
      <dc:creator>gut1kor</dc:creator>
      <dc:date>2022-11-17T11:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621226#M107007</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223411"&gt;@emallinger&lt;/a&gt;&amp;nbsp;thank you very much, as you said I have moved the date and host fields to event part and wrote the json to log file and now Splunk could extract timestamp and other fields as usual. For host in event data it's showing extracted_host. I guess if I don't find any solution to make Splunk use this parameter as actual host for the event, I probably need to tweak my dashboard query; something like if extracted_host exists in the event then I will use it's value otherwise default host value.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 12:08:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621226#M107007</guid>
      <dc:creator>gut1kor</dc:creator>
      <dc:date>2022-11-17T12:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621228#M107008</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/251361"&gt;@gut1kor&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Not sure I follow you :&lt;/P&gt;&lt;P&gt;- in the file, in each event if the field name is "host" it should be available just fine, no ?&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;- you need to put it in your inputs.conf with the monitor stanza =&amp;gt; as an option "host = ..." if it is the same one for all the data in the file.&lt;/P&gt;&lt;P&gt;Otherwise, I would suggest adding an alias between host and extracted host for your sourcetype.&lt;/P&gt;&lt;P&gt;What do you think ?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 12:17:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621228#M107008</guid>
      <dc:creator>emallinger</dc:creator>
      <dc:date>2022-11-17T12:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621233#M107009</link>
      <description>&lt;P&gt;Hi Ema,&lt;/P&gt;&lt;P&gt;If the host is part of event data then it's only showing it as 'extracted_host' and original host name (of log file) is picked up as 'host' parameter. The use case is that transaction flow happens across multiple applications. So all applications emit these events and some will be routed to through a queuing mechanism before written to a central log file and some will be pushed through HEC. So it's a must that we extract this hostname from event for tracking purpose.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will read about this alias creation and try.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 12:34:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621233#M107009</guid>
      <dc:creator>gut1kor</dc:creator>
      <dc:date>2022-11-17T12:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621234#M107010</link>
      <description>&lt;P&gt;Ok, I understand.&lt;/P&gt;&lt;P&gt;That means it got improved in the version you are using !&lt;/P&gt;&lt;P&gt;Because&amp;nbsp; in the past, I had some data sources where host, source and other splunk default fields had been used and it got all merged. unfortunately, the data didn't meant the same thing, so it was a problem.&lt;/P&gt;&lt;P&gt;In that case, I think the alias is your best bet.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 12:43:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621234#M107010</guid>
      <dc:creator>emallinger</dc:creator>
      <dc:date>2022-11-17T12:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621374#M107028</link>
      <description>&lt;P&gt;Hi again,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/251361"&gt;@gut1kor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Found another way to set host per event with props.conf and TRANSFORMS :&lt;/P&gt;&lt;P&gt;[sourcetype_name]&lt;/P&gt;&lt;P&gt;TRANSFORMS-register=name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[name]&lt;/P&gt;&lt;P&gt;SOURCE_KEY=_raw&lt;/P&gt;&lt;P&gt;REGEX = server:(\w+)&amp;nbsp; # capturing regex adated to your data&lt;/P&gt;&lt;P&gt;DEST_KEY = MetaData:Host&lt;/P&gt;&lt;P&gt;FORMAT = host::$1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need to be tested.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ema&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 11:44:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621374#M107028</guid>
      <dc:creator>emallinger</dc:creator>
      <dc:date>2022-11-18T11:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to format json event data so that it can be written to a json log and then successfully indexed by Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621376#M107029</link>
      <description>&lt;P&gt;Hi Ema, thank you very much, I really appreciate your help. I will try this and let you know.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 12:18:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-format-json-event-data-so-that-it-can-be-written-to-a/m-p/621376#M107029</guid>
      <dc:creator>gut1kor</dc:creator>
      <dc:date>2022-11-18T12:18:01Z</dc:date>
    </item>
  </channel>
</rss>

