<?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: Replace values of host, before indexing, with data from event in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Replace-values-of-host-before-indexing-with-data-from-event/m-p/706364#M21033</link>
    <description>&lt;P&gt;In props.conf, when you are using sourcetype as stanza name, use just the name of sourcetype instead add prefix sourcetype::&lt;/P&gt;</description>
    <pubDate>Mon, 09 Dec 2024 15:47:53 GMT</pubDate>
    <dc:creator>isoutamo</dc:creator>
    <dc:date>2024-12-09T15:47:53Z</dc:date>
    <item>
      <title>Replace values of host, before indexing, with data from event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Replace-values-of-host-before-indexing-with-data-from-event/m-p/706224#M21001</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I’m currently working on extracting the webaclId field from AWS WAF logs and setting it as the host metadata in Splunk. However, I’ve been running into issues where the regex doesn’t seem to work, and Splunk throws the error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;Log Example:&lt;/H3&gt;&lt;P&gt;Below is an obfuscated example of an event from the logs I’m working with:&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;{
"timestamp": 1733490000011,
"formatVersion": 1,
"webaclId": "arn:aws:wafv2:region:account-id:regional/webacl/webacl-name/resource-id",
"action": "ALLOW",
"httpRequest": {
"clientIp": "192.0.2.1",
"country": "XX",
"headers": [
{ "name": "Host", "value": "example.com" }
],
"uri": "/v2.01/endpoint/path/resource",
"httpMethod": "GET"
}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I want to extract the webacl-name from the webaclId field and set it as the host metadata in Splunk. For the above example, the desired host value should be:&amp;nbsp;webacl-name&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here’s my current Splunk configuration:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;inputs.conf:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;[monitor:///opt/splunk/etc/tes*.txt]
disabled = false
index = test
sourcetype = aws:waf&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;props.conf:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[sourcetype::aws:waf]
TRANSFORMS-set_host = extract_webacl_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;transforms.conf:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[extract_webacl_name]
REGEX = \"webaclId\":\"[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:regional\/webacl\/([^\/]+)\/
FORMAT = host::$1
DEST_KEY = MetaData:Host
SOURCE_KEY = _raw&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;H3&gt;&lt;FONT size="4"&gt;What I’ve Tried:&lt;BR /&gt;&lt;FONT size="3"&gt;I’ve validated the regex on external tools like regex101, and it works for the log structure.&lt;BR /&gt;&lt;BR /&gt;For example, the regex successfully extracts webacl-name from:&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;H3&gt;&lt;FONT size="4"&gt;&lt;FONT size="3"&gt;"webaclId":"arn:aws:wafv2:region:account-id:regional/webacl/webacl-name/resource-id"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;H3&gt;&lt;FONT size="4"&gt;&lt;FONT size="3"&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;&lt;STRONG&gt;Manual rex Testing in Splunk:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;index=test sourcetype=aws:waf 
| rex field=_raw "\"webaclId\":\"[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:regional\/webacl\/(?&amp;lt;webacl_name&amp;gt;[^\/]+)\/" 
| table _raw webacl_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;H3&gt;Questions:&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;Does my transforms.conf configuration have any issues I might be missing?&lt;/LI&gt;&lt;LI&gt;Is there an alternative or more efficient way to handle this extraction and rewrite the host field?&lt;/LI&gt;&lt;LI&gt;Are there any known limitations or edge cases with using JSON data for MetaData:Host updates?&lt;P&gt;I’d greatly appreciate any insights or suggestions. Thank you for your help!&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Fri, 06 Dec 2024 23:38:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Replace-values-of-host-before-indexing-with-data-from-event/m-p/706224#M21001</guid>
      <dc:creator>nuaraujo</dc:creator>
      <dc:date>2024-12-06T23:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values of host, before indexing, with data from event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Replace-values-of-host-before-indexing-with-data-from-event/m-p/706354#M21031</link>
      <description>&lt;LI-CODE lang="markup"&gt;\"webaclId\":\s\"[^:]+:[^:]+:[^:]+:[^:]+:[^:]+:regional\/webacl\/([^\/]+)\/&lt;/LI-CODE&gt;&lt;P&gt;Your example data has a space&amp;nbsp;&lt;STRONG&gt;"webaclId": "&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Verified from regex101&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 15:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Replace-values-of-host-before-indexing-with-data-from-event/m-p/706354#M21031</guid>
      <dc:creator>dural_yyz</dc:creator>
      <dc:date>2024-12-09T15:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values of host, before indexing, with data from event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Replace-values-of-host-before-indexing-with-data-from-event/m-p/706364#M21033</link>
      <description>&lt;P&gt;In props.conf, when you are using sourcetype as stanza name, use just the name of sourcetype instead add prefix sourcetype::&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 15:47:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Replace-values-of-host-before-indexing-with-data-from-event/m-p/706364#M21033</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-12-09T15:47:53Z</dc:date>
    </item>
  </channel>
</rss>

