<?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 Modify Field with Regex at Index Time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526726#M148674</link>
    <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have IIS logs that are logging multiple IPs to the X-Forwarded-For field as below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;114.119.136.78,+162.158.119.25
 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to apply a regex to the X-Forwarded-For field at index time to ensure the field only contains the first IP, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;114.119.136.78&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, anything after the first comma should be cut out of the field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have tried to achieve this with the following props/transforms:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#props
[iis]
TRANSFORMS-rm-extra-ips = rm_extra_ips

#transforms
[rm_extra_ips]
SOURCE_KEY = field:X_Forwarded_For
REGEX = ^(.+?),&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do this?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 27 Oct 2020 21:22:44 GMT</pubDate>
    <dc:creator>dbuehler</dc:creator>
    <dc:date>2020-10-27T21:22:44Z</dc:date>
    <item>
      <title>Modify Field with Regex at Index Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526726#M148674</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have IIS logs that are logging multiple IPs to the X-Forwarded-For field as below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;114.119.136.78,+162.158.119.25
 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to apply a regex to the X-Forwarded-For field at index time to ensure the field only contains the first IP, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;114.119.136.78&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, anything after the first comma should be cut out of the field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have tried to achieve this with the following props/transforms:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#props
[iis]
TRANSFORMS-rm-extra-ips = rm_extra_ips

#transforms
[rm_extra_ips]
SOURCE_KEY = field:X_Forwarded_For
REGEX = ^(.+?),&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do this?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 21:22:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526726#M148674</guid>
      <dc:creator>dbuehler</dc:creator>
      <dc:date>2020-10-27T21:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Field with Regex at Index Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526731#M148675</link>
      <description>&lt;P&gt;If you want to modify the field at index time you would use SEDCMD, described in props.conf docs here&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and also see this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.0/Data/Anonymizedata" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.1.0/Data/Anonymizedata&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and also some community posts, e.g.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/How-to-configure-SEDCMD-in-props-conf/m-p/196633" target="_blank"&gt;https://community.splunk.com/t5/Getting-Data-In/How-to-configure-SEDCMD-in-props-conf/m-p/196633&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/SEDCMD-a-field/m-p/413484" target="_blank"&gt;https://community.splunk.com/t5/Getting-Data-In/SEDCMD-a-field/m-p/413484&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 23:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526731#M148675</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-10-27T23:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Field with Regex at Index Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526850#M148712</link>
      <description>&lt;P&gt;Thanks, I was looking into SEDCMD originally, I've used it for other purposes before.&lt;/P&gt;&lt;P&gt;Can SEDCMD operate on just one field? Or does it have to operate on the entire event (_raw)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 12:33:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526850#M148712</guid>
      <dc:creator>dbuehler</dc:creator>
      <dc:date>2020-10-28T12:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Field with Regex at Index Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526878#M148720</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Based on props.conf's spec no, if must operate towards _raw.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SEDCMD-&amp;lt;class&amp;gt; = &amp;lt;sed script&amp;gt;
* Only used at index time.
* Commonly used to anonymize incoming data at index time, such as credit
  card or social security numbers. For more information, search the online
  documentation for "anonymize data."
* Used to specify a sed script which Splunk software applies to the _raw
  field.
* A sed script is a space-separated list of sed commands. Currently the
  following subset of sed commands is supported:
    * replace (s) and character substitution (y).
* Syntax:
    * replace - s/regex/replacement/flags
      * regex is a perl regular expression (optionally containing capturing
        groups).
      * replacement is a string to replace the regex match. Use \n for back
        references, where "n" is a single digit.
      * flags can be either: g to replace all matches, or a number to
        replace a specified match.
    * substitute - y/string1/string2/
      * substitutes the string1[i] with string2[i]
* No default.&lt;/LI-CODE&gt;&lt;P&gt;r. Ismo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 14:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/526878#M148720</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-10-28T14:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Field with Regex at Index Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/527982#M149049</link>
      <description>&lt;P&gt;For some reason my props.conf config isn't being applied to my data.&lt;/P&gt;&lt;P&gt;I've found that this is the regex I need:&lt;/P&gt;&lt;P&gt;s/,+[.0-9\:a-z]*//g&lt;/P&gt;&lt;P&gt;And this regex works perfectly when run manually, i.e. using a sed command against a text file with a sample event:&lt;/P&gt;&lt;P&gt;cat sample.txt | sed 's/,+[.0-9\:a-z]*//g'&lt;/P&gt;&lt;P&gt;My props.conf (placed on my two indexers in /opt/splunk/etc/apps/my-iis-app/local) is configured to apply to the 'iis' sourcetype, which is correct, and looks like:&lt;/P&gt;&lt;P&gt;[iis]&lt;/P&gt;&lt;P&gt;SEDCMD-remove-extra-ips = s/,+[.0-9\:a-z]*//g&lt;/P&gt;&lt;P&gt;After restarting Splunk, the events are coming in un-modified. It appears the regex isn't being applied at all, as even if I change my config to a very simple test regex, that doesn't work either, e.g.:&lt;/P&gt;&lt;P&gt;[iis]&lt;BR /&gt;SEDCMD-test = s/10/test/g&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:59:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/527982#M149049</guid>
      <dc:creator>dbuehler</dc:creator>
      <dc:date>2020-11-04T17:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Field with Regex at Index Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/527999#M149057</link>
      <description>Shoul you have \. Instead of . In your shed expression? First match to . second one match to every character.</description>
      <pubDate>Wed, 04 Nov 2020 18:46:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/527999#M149057</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-11-04T18:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modify Field with Regex at Index Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/528005#M149058</link>
      <description>&lt;P&gt;That regex works just the same in manual tests, but does not work when applied as a SEDCMD in props.conf.&lt;/P&gt;&lt;P&gt;It seems clear my props SEDCMD is not being applied to my data at all.&lt;/P&gt;&lt;P&gt;If I run:&lt;/P&gt;&lt;P&gt;/opt/splunk/bin/splunk btool --debug props list |grep SEDCMD&lt;/P&gt;&lt;P&gt;I see my setting showing up in the output. Is there any other way to troubleshoot if my SEDCMD is being applied?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 19:10:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-Field-with-Regex-at-Index-Time/m-p/528005#M149058</guid>
      <dc:creator>dbuehler</dc:creator>
      <dc:date>2020-11-04T19:10:25Z</dc:date>
    </item>
  </channel>
</rss>

