<?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 I have python script with correct output in JSON format , but why 2 event with broken message? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/I-have-python-script-with-correct-output-in-JSON-format-but-why/m-p/631865#M108282</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have python script just like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;#!/bin/python
import os
import json
import datetime

HOMEPATH = '/opt/monitor_dirs/SomeDir'

def path_to_dict(path, depth = 1, first = False):
    for base, dirs, files in os.walk(path):
        r = {'name': base, 'dirs': len(dirs), 'files': len(files)}
        if first:
            r['datetime'] = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S%z")
        if depth &amp;gt; 0:
            r['subdirs'] = {}
            for subdir in dirs:
                r['subdirs'][subdir] = path_to_dict(os.path.join(path, subdir), depth - 1);
        return r


#print path_to_dict(HOMEPATH, 1)
result = path_to_dict(HOMEPATH, 1, True)
if result:
    print (json.dumps(result, sort_keys=True, indent=4))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And i have output&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;# ./file_count.py
{
    "datetime": "2023-02-22T21:10:49",
    "dirs": 9,
    "files": 0,
    "name": "/opt/monitor_dirs/SomeDir",
    "subdirs": {
        "XXXX": {
            "dirs": 0,
            "files": 63,
            "name": "/opt/monitor_dirs/XXXX"
        }
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is some problem in Index&lt;/P&gt;
&lt;P&gt;I have 2 event instead just only one&lt;/P&gt;
&lt;P&gt;1. {&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; ""datetime": "2023-02-22T21:10:49",&lt;BR /&gt;"dirs": 9,&lt;BR /&gt;"files": 0, and so on, but there is no '{'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How i can get only one event with my JSON&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Feb 2023 17:18:28 GMT</pubDate>
    <dc:creator>alexeysharkov</dc:creator>
    <dc:date>2023-02-22T17:18:28Z</dc:date>
    <item>
      <title>I have python script with correct output in JSON format , but why 2 event with broken message?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/I-have-python-script-with-correct-output-in-JSON-format-but-why/m-p/631865#M108282</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have python script just like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;#!/bin/python
import os
import json
import datetime

HOMEPATH = '/opt/monitor_dirs/SomeDir'

def path_to_dict(path, depth = 1, first = False):
    for base, dirs, files in os.walk(path):
        r = {'name': base, 'dirs': len(dirs), 'files': len(files)}
        if first:
            r['datetime'] = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S%z")
        if depth &amp;gt; 0:
            r['subdirs'] = {}
            for subdir in dirs:
                r['subdirs'][subdir] = path_to_dict(os.path.join(path, subdir), depth - 1);
        return r


#print path_to_dict(HOMEPATH, 1)
result = path_to_dict(HOMEPATH, 1, True)
if result:
    print (json.dumps(result, sort_keys=True, indent=4))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And i have output&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;# ./file_count.py
{
    "datetime": "2023-02-22T21:10:49",
    "dirs": 9,
    "files": 0,
    "name": "/opt/monitor_dirs/SomeDir",
    "subdirs": {
        "XXXX": {
            "dirs": 0,
            "files": 63,
            "name": "/opt/monitor_dirs/XXXX"
        }
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is some problem in Index&lt;/P&gt;
&lt;P&gt;I have 2 event instead just only one&lt;/P&gt;
&lt;P&gt;1. {&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; ""datetime": "2023-02-22T21:10:49",&lt;BR /&gt;"dirs": 9,&lt;BR /&gt;"files": 0, and so on, but there is no '{'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How i can get only one event with my JSON&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 17:18:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/I-have-python-script-with-correct-output-in-JSON-format-but-why/m-p/631865#M108282</guid>
      <dc:creator>alexeysharkov</dc:creator>
      <dc:date>2023-02-22T17:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: I have python script with correct output in JSON format , but why 2 event with broken message?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/I-have-python-script-with-correct-output-in-JSON-format-but-why/m-p/631966#M108301</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/235562"&gt;@alexeysharkov&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try updating the print statement in python code?&lt;/P&gt;&lt;P&gt;From:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;print (json.dumps(result, sort_keys=True, indent=4))&lt;/LI-CODE&gt;&lt;P&gt;To&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;print (json.loads(json.dumps(result, sort_keys=True, indent=4)))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if the solution doesn't work for you then please share the extraction configuration from props.conf.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 07:52:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/I-have-python-script-with-correct-output-in-JSON-format-but-why/m-p/631966#M108301</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2023-02-23T07:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: I have python script with correct output in JSON format , but why 2 event with broken message?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/I-have-python-script-with-correct-output-in-JSON-format-but-why/m-p/631995#M108302</link>
      <description>&lt;P&gt;Thanks Kamlesh!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;props.conf was empty &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And now&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[mymonitorinf]
CHARSET=UTF-8
INDEXED_EXTRACTIONS=json
KV_MODE=none
SHOULD_LINEMERGE=true
category=Structured
description=JavaScript Object Notation format. For more information, visit http://json.org/
disabled=false
pulldown_type=true&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Everything OK now! Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 10:37:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/I-have-python-script-with-correct-output-in-JSON-format-but-why/m-p/631995#M108302</guid>
      <dc:creator>alexeysharkov</dc:creator>
      <dc:date>2023-02-23T10:37:01Z</dc:date>
    </item>
  </channel>
</rss>

