<?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: com.splunk.Index.submit() with a JSON is not recognized in Splunk as Type Event parameters in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559058#M92484</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236289"&gt;@krienstra&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think your code should work.&lt;/P&gt;&lt;P&gt;I have tried this and worked fine. Can you please try this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;import com.splunk.*;

public class App {
    public static void main(String[] args) throws Exception {
        HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);

        // Create a map of arguments and add login parameters
        ServiceArgs loginArgs = new ServiceArgs();
        loginArgs.setUsername("admin");
        loginArgs.setPassword("admin123");
        loginArgs.setHost("localhost");
        loginArgs.setPort(8089);

        // Create a Service instance and log in with the argument map
        Service service = Service.connect(loginArgs);

        // Retrieve the index for the data
        Index myIndex = service.getIndexes().get("main");

        Args eventArgs = new Args();
        eventArgs.put("sourcetype", "_json");
        String input = "{\"account\": \"test\",\"password\": \"Welkom\",\"hostname\": \"DESKTOP-KENNETH\",\"application\": \"test\"}";
        myIndex.submit(eventArgs, input);

    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-07-12 at 3.41.34 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15038i7D6CEF054CE896CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2021-07-12 at 3.41.34 PM.png" alt="Screenshot 2021-07-12 at 3.41.34 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jul 2021 10:12:10 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2021-07-12T10:12:10Z</dc:date>
    <item>
      <title>com.splunk.Index.submit() with a JSON is not recognized in Splunk as Type Event parameters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559051#M92483</link>
      <description>&lt;P&gt;I have successfully implemented the Splunk Java SDK to write my own .class and implement the code within programs we run on several machines to send and retrieve data. I am able to retrieve search results as a List of &amp;lt;Event&amp;gt; or submit data to the index.&lt;/P&gt;&lt;P&gt;However, Splunk does not format my submitted data to the main index when presented as JSON.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run the following code, the JSON is somehow formatted in the Splunk interface as a JSON with it's red/green formatting HOWEVER the data is &lt;U&gt;not formatted through Type Event&lt;/U&gt; and therefore I can not search data based on an "application=test" String:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;Index myIndex = service.getIndexes().get("main");
eventArgs.put("sourcetype", "_json");
String input = "{\"account\": \"test\",\"password\": \"Welkom\",\"hostname\": \"DESKTOP-KENNETH\",\"application\": \"test\"}";
myIndex.submit(eventArgs, input);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I need to submit a JSON where Splunk will recognize this as a Type Event with it's corresponding key/value pairs?&lt;/P&gt;&lt;P&gt;This search &lt;STRONG&gt;will not retrieve the submitted JSON&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main application="test"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Type Event now has only one key/value pair: "timestamp: none".&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 09:28:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559051#M92483</guid>
      <dc:creator>krienstra</dc:creator>
      <dc:date>2021-07-12T09:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: com.splunk.Index.submit() with a JSON is not recognized in Splunk as Type Event parameters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559058#M92484</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236289"&gt;@krienstra&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think your code should work.&lt;/P&gt;&lt;P&gt;I have tried this and worked fine. Can you please try this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;import com.splunk.*;

public class App {
    public static void main(String[] args) throws Exception {
        HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);

        // Create a map of arguments and add login parameters
        ServiceArgs loginArgs = new ServiceArgs();
        loginArgs.setUsername("admin");
        loginArgs.setPassword("admin123");
        loginArgs.setHost("localhost");
        loginArgs.setPort(8089);

        // Create a Service instance and log in with the argument map
        Service service = Service.connect(loginArgs);

        // Retrieve the index for the data
        Index myIndex = service.getIndexes().get("main");

        Args eventArgs = new Args();
        eventArgs.put("sourcetype", "_json");
        String input = "{\"account\": \"test\",\"password\": \"Welkom\",\"hostname\": \"DESKTOP-KENNETH\",\"application\": \"test\"}";
        myIndex.submit(eventArgs, input);

    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-07-12 at 3.41.34 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15038i7D6CEF054CE896CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2021-07-12 at 3.41.34 PM.png" alt="Screenshot 2021-07-12 at 3.41.34 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt; Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 10:12:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559058#M92484</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-12T10:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: com.splunk.Index.submit() with a JSON is not recognized in Splunk as Type Event parameters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559062#M92485</link>
      <description>&lt;P&gt;Hi Kamlesh,&lt;/P&gt;&lt;P&gt;Could you search for "application=test" instead of "sourcetype=_json"? I see there is a problem with adding a "sourcetype: _json" via Args().&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is when I submit(Args eventArgs, String data) - it does &lt;U&gt;not set the Type Event key/value pairs&lt;/U&gt;:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krienstra_0-1626085619536.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15039i5B842144CC695CFE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="krienstra_0-1626085619536.png" alt="krienstra_0-1626085619536.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is if I only submit(String data) - it picks up all the key/value pairs:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krienstra_1-1626085692264.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15040i64B263D02E1EC653/image-size/medium?v=v2&amp;amp;px=400" role="button" title="krienstra_1-1626085692264.png" alt="krienstra_1-1626085692264.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 10:30:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559062#M92485</guid>
      <dc:creator>krienstra</dc:creator>
      <dc:date>2021-07-12T10:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: com.splunk.Index.submit() with a JSON is not recognized in Splunk as Type Event parameters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559075#M92487</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236289"&gt;@krienstra&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here, I suggest not to use _json sourcetype and clone it and use.&lt;/P&gt;&lt;P&gt;Or create below configurations in props.conf and send data to this sourcetype.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[m_json]
KV_MODE = json&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-07-12 at 5.23.41 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15041i22E47D80EFA11D85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2021-07-12 at 5.23.41 PM.png" alt="Screenshot 2021-07-12 at 5.23.41 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this will help you.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 11:54:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559075#M92487</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-12T11:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: com.splunk.Index.submit() with a JSON is not recognized in Splunk as Type Event parameters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559082#M92489</link>
      <description>&lt;P&gt;That's right, I'll skip the "_json" and use another sourcetype. It seems that "_json" is not giving me the right result, I can use any other sourcetype except this (not sure what exactly "_json" does as a sourcetype, but it's not working and I'll refrain from).&amp;nbsp;&lt;/P&gt;&lt;P&gt;"json" does seem to work, giving me the right Event Types key/value pairs:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krienstra_0-1626093392787.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15042iC252DFB7FE05CA1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="krienstra_0-1626093392787.png" alt="krienstra_0-1626093392787.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;String input = "{\"account\": \"test\",\"password\": \"Welkom\",\"hostname\": \"DESKTOP-KENNETH\",\"application\": \"test\"}";
Args eventArgs = new Args();
eventArgs.put("sourcetype", "json");
handler.sendEvent(eventArgs, "main", input);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 12:40:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/com-splunk-Index-submit-with-a-JSON-is-not-recognized-in-Splunk/m-p/559082#M92489</guid>
      <dc:creator>krienstra</dc:creator>
      <dc:date>2021-07-12T12:40:36Z</dc:date>
    </item>
  </channel>
</rss>

