<?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: Force inclusion of space character as a first character in FORMAT string in transforms.conf in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709172#M117164</link>
    <description>&lt;P&gt;Looks good! Just be mindful of the difference between the plus (+) operator and the dot (.) operator. Plus concatenates strings and&amp;nbsp;&lt;EM&gt;adds&lt;/EM&gt; numbers, but dot concatenates both strings and numbers as strings. If you're unsure of the order of operations or the variable value in other contexts, you can wrap the variables in the tostring() function.&lt;/P&gt;&lt;P&gt;It's interesting that Splunk also assumed a leading space would work in the SC4S transforms:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[metadata_time]
SOURCE_KEY = _time
REGEX = (.*)
FORMAT =  t="$1$0
DEST_KEY = _raw&lt;/LI-CODE&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;'s suggestion to escape the space with i.e. a blackslash just evaluates to a literal backslash followed by a space.&lt;/P&gt;</description>
    <pubDate>Sun, 19 Jan 2025 21:02:52 GMT</pubDate>
    <dc:creator>tscroggins</dc:creator>
    <dc:date>2025-01-19T21:02:52Z</dc:date>
    <item>
      <title>Force inclusion of space character as a first character in FORMAT string in transforms.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709147#M117154</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;I am experimenting with the SC4S transforms that are posted here:&lt;BR /&gt;&lt;A href="https://splunk.github.io/splunk-connect-for-syslog/main/sources/vendor/Splunk/heavyforwarder/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://splunk.github.io/splunk-connect-for-syslog/main/sources/vendor/Splunk/heavyforwarder/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;My problem is that I am trying to reformat fields, and in one particular place I would need to ensure that a space preceeds the _h= part in the transform stanza below.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[md_host]
SOURCE_KEY = MetaData:Host
REGEX = ^host::(.*)$
FORMAT = _h=$1 $0
DEST_KEY = _raw&lt;/LI-CODE&gt;&lt;P&gt;However if I add multiple whitespaces in the FORMAT string, right after the equals sign in the above example, they will be ignored.&lt;BR /&gt;Should put the whole thing betweem quotes? Wouldn't the quotes be included in the _raw string?&lt;/P&gt;&lt;P&gt;What would be the right solution for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2025 16:31:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709147#M117154</guid>
      <dc:creator>wowbaggerHU</dc:creator>
      <dc:date>2025-01-18T16:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Force inclusion of space character as a first character in FORMAT string in transforms.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709150#M117155</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/275493"&gt;@wowbaggerHU&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can use INGEST_EVAL as a workaround:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;# transforms.conf
[md_host]
INGEST_EVAL = _raw:=" h=\"".host."\" "._raw&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 18 Jan 2025 23:34:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709150#M117155</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2025-01-18T23:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Force inclusion of space character as a first character in FORMAT string in transforms.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709157#M117157</link>
      <description>&lt;P&gt;Apart from &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/49493"&gt;@tscroggins&lt;/a&gt; 's solution you could try escaping your initial space. It should show the config parser that there is a non-space character so your key-value pair in config is split properly but since the space doesn't normally need escaping it shouldn't hurt.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jan 2025 08:36:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709157#M117157</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-01-19T08:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Force inclusion of space character as a first character in FORMAT string in transforms.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709159#M117159</link>
      <description>&lt;P&gt;Good idea, I tried it, but unfortunately it doesn't seem to work. I have this configured:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[md_host]
SOURCE_KEY = MetaData:Host
REGEX = ^host::(.*)$
FORMAT = \ _h=$1 $0
DEST_KEY = _raw

[md_subsecond_default]
SOURCE_KEY = _meta
REGEX = _subsecond=(\.\d+)
FORMAT = $1$0
DEST_KEY = _raw

[md_time_default]
SOURCE_KEY = _time
REGEX = (.*)
FORMAT = _ts=$1$0
DEST_KEY = _raw&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        0x0040:  e073 339e e073 339e 3232 3738 205f 7473  .s3..s3.2278._ts
        0x0050:  3d31 3733 3732 3739 3038 315c 205f 683d  =1737279081\._h=
        0x0060:  7370 6c75 6e6b 2d68 6620 5f69 6478 3d5f  splunk-hf._idx=_&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;But I agree, this would have been the most elegant solution.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jan 2025 09:37:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709159#M117159</guid>
      <dc:creator>wowbaggerHU</dc:creator>
      <dc:date>2025-01-19T09:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Force inclusion of space character as a first character in FORMAT string in transforms.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709168#M117162</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/49493"&gt;@tscroggins&lt;/a&gt;Thanks for the idea. It worked, though I added my own set of modifications to it.&lt;/P&gt;&lt;P&gt;As a final touch I would like to put the relevant part of my config here, so as to contribute it back to the community:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[md_host]
INGEST_EVAL = _raw=" _h=".host." "._raw

[md_subsecond]
SOURCE_KEY = _meta
REGEX = _subsecond=(\.\d+)
FORMAT = $1$0
DEST_KEY = _raw

[md_time]
SOURCE_KEY = _time
REGEX = (.*)
FORMAT = _ts=$1$0
DEST_KEY = _raw&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 13:22:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709168#M117162</guid>
      <dc:creator>wowbaggerHU</dc:creator>
      <dc:date>2025-01-20T13:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Force inclusion of space character as a first character in FORMAT string in transforms.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709172#M117164</link>
      <description>&lt;P&gt;Looks good! Just be mindful of the difference between the plus (+) operator and the dot (.) operator. Plus concatenates strings and&amp;nbsp;&lt;EM&gt;adds&lt;/EM&gt; numbers, but dot concatenates both strings and numbers as strings. If you're unsure of the order of operations or the variable value in other contexts, you can wrap the variables in the tostring() function.&lt;/P&gt;&lt;P&gt;It's interesting that Splunk also assumed a leading space would work in the SC4S transforms:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[metadata_time]
SOURCE_KEY = _time
REGEX = (.*)
FORMAT =  t="$1$0
DEST_KEY = _raw&lt;/LI-CODE&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;'s suggestion to escape the space with i.e. a blackslash just evaluates to a literal backslash followed by a space.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jan 2025 21:02:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709172#M117164</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2025-01-19T21:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Force inclusion of space character as a first character in FORMAT string in transforms.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709206#M117167</link>
      <description>&lt;P&gt;Thanks for the explanation, it was educational. I have corrected the plus operators where appropriate.&lt;BR /&gt;On the other hand, I have now triple-checked, and in deed, multiple leading whitespaces are ignored in the FORMAT string.&lt;/P&gt;&lt;P&gt;But yes, it would seem that Splunk or whoever wrote the SC4S config assumed that they would be honored.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 08:08:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Force-inclusion-of-space-character-as-a-first-character-in/m-p/709206#M117167</guid>
      <dc:creator>wowbaggerHU</dc:creator>
      <dc:date>2025-01-20T08:08:15Z</dc:date>
    </item>
  </channel>
</rss>

