<?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: Rex Field Extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660458#M228007</link>
    <description>&lt;P&gt;If that is your _raw event, just do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath correlation_id&lt;/LI-CODE&gt;&lt;P&gt;and it will give you the correlation_id field&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2023 22:25:22 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2023-10-11T22:25:22Z</dc:date>
    <item>
      <title>Rex Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660455#M228006</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@All ,&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;I want to extract the correlation_id for the below payload, can anyone help me to write rex command.&lt;BR /&gt;&lt;BR /&gt;{"message_type": "INFO", "processing_stage": "Deleted message from queue", "message": "Deleted message from queue", "correlation_id": "['321e2253-443a-41f1-8af3-81dbdb8bcc77']", "error": "", "invoker_agent": "arn:aws:sqs:eu-central-1:981503094308:prd-ccm-incontact-ingestor-queue-v1", "invoked_component": "prd-ccm-incontact-ingestor-v1", "request_payload": "", "response_details": "{'ResponseMetadata': {'RequestId': 'a04c3e82-fe3a-5986-b61c-6323fd295e18', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'a04c3e82-fe3a-5986-b61c-6323fd295e18', 'x-amzn-trace-id': 'Root=1-652700cc-f7ed3cf574ce28da63f6625d;Parent=865f4dad6eddf3c1;Sampled=1', 'date': 'Wed, 11 Oct 2023 20:08:51 GMT', 'content-type': 'text/xml', 'content-length': '215', 'connection': 'keep-alive'}, 'RetryAttempts': 0}}", "invocation_timestamp": "2023-10-11T20:08:51Z", "response_timestamp": "2023-10-11T20:08:51Z", "original_source_app": "YMKT", "target_idp_application": "", "retry_attempt": "1", "custom_attributes": {"entity-internal-id": "", "root-entity-id": "", "campaign-id": "", "campaign-name": "", "marketing-area": "", "lead-id": "", "record_count": "1", "country": ["India"]}}&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 21:18:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660455#M228006</guid>
      <dc:creator>parthiban</dc:creator>
      <dc:date>2023-10-11T21:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660458#M228007</link>
      <description>&lt;P&gt;If that is your _raw event, just do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath correlation_id&lt;/LI-CODE&gt;&lt;P&gt;and it will give you the correlation_id field&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 22:25:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660458#M228007</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-10-11T22:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660499#M228026</link>
      <description>&lt;P&gt;As I always caution people in this forum, do not treat structured data such as JSON as text. &amp;nbsp;Regex is usually not the right tool.&lt;/P&gt;&lt;P&gt;Is the illustrated JSON the raw event? &amp;nbsp;If so, Splunk should have given you a field named correlation_id of value&amp;nbsp;&lt;SPAN&gt;['321e2253-443a-41f1-8af3-81dbdb8bcc77']. &amp;nbsp;If it is part of a raw event that is compliant JSON, you need to show the full raw event - and Splunk should have given you a field named &lt;EM&gt;some_path&lt;/EM&gt;.correlation_id. &amp;nbsp;If it is part of a raw event that is not JSON, you need to show the raw event so we can help you extract the JSON part, then you can use spath on the JSON part. &amp;nbsp;This is much more robust and maintainable than using regex on structured data.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 10:23:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660499#M228026</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-12T10:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660503#M228028</link>
      <description>&lt;P&gt;"Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;, thank you for your response. I need a regular expression to extract the correlation_id because I want to calculate the average time taken for two source events. The samples I provided are as follows:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;correlation_id: "['321e2253-443a-41f1-8af3-81dbdb8bcc77']"&lt;/LI&gt;&lt;LI&gt;correlation_id: "11315ad3-02a3-419d-a656-85972e07a1a5"&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;These are two format logs one is in array format and another normal value. Thanks in advance&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 10:35:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660503#M228028</guid>
      <dc:creator>parthiban</dc:creator>
      <dc:date>2023-10-12T10:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Field Extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660774#M228140</link>
      <description>&lt;BLOCKQUOTE&gt;The samples I provided are as follows:&lt;UL&gt;&lt;LI&gt;correlation_id: "['321e2253-443a-41f1-8af3-81dbdb8bcc77']"&lt;/LI&gt;&lt;LI&gt;correlation_id: "11315ad3-02a3-419d-a656-85972e07a1a5"&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;These are two format logs one is in array format and another normal value. Thanks in advance&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Did you forget to provide one of samples you alluded to? &amp;nbsp;The only sample (if it is raw event) you provided would have these fields available to you by Splunk:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;fieldname&lt;/TD&gt;&lt;TD&gt;fieldvalue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;correlation_id&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;['321e2253-443a-41f1-8af3-81dbdb8bcc77']&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;custom_attributes.campaign-id&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="47px"&gt;custom_attributes.campaign-name&lt;/TD&gt;&lt;TD width="543.90625px" height="47px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;custom_attributes.country{}&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;India&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="47px"&gt;custom_attributes.entity-internal-id&lt;/TD&gt;&lt;TD width="543.90625px" height="47px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;custom_attributes.lead-id&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="47px"&gt;custom_attributes.marketing-area&lt;/TD&gt;&lt;TD width="543.90625px" height="47px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;custom_attributes.record_count&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;custom_attributes.root-entity-id&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;error&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;invocation_timestamp&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;2023-10-11T20:08:51Z&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;invoked_component&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;prd-ccm-incontact-ingestor-v1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="47px"&gt;invoker_agent&lt;/TD&gt;&lt;TD width="543.90625px" height="47px"&gt;arn:aws:sqs:eu-central-1:981503094308:prd-ccm-incontact-ingestor-queue-v1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;message&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;Deleted message from queue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;message_type&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;INFO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;original_source_app&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;YMKT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;processing_stage&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;Deleted message from queue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;request_payload&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="157px"&gt;response_details&lt;/TD&gt;&lt;TD width="543.90625px" height="157px"&gt;{'ResponseMetadata': {'RequestId': 'a04c3e82-fe3a-5986-b61c-6323fd295e18', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'a04c3e82-fe3a-5986-b61c-6323fd295e18', 'x-amzn-trace-id': 'Root=1-652700cc-f7ed3cf574ce28da63f6625d;Parent=865f4dad6eddf3c1;Sampled=1', 'date': 'Wed, 11 Oct 2023 20:08:51 GMT', 'content-type': 'text/xml', 'content-length': '215', 'connection': 'keep-alive'}, 'RetryAttempts': 0}}&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;response_timestamp&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;2023-10-11T20:08:51Z&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;retry_attempt&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="247.09375px" height="25px"&gt;target_idp_application&lt;/TD&gt;&lt;TD width="543.90625px" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;As you can see, there is only one correlation_id; the value&amp;nbsp;11315ad3-02a3-419d-a656-85972e07a1a5 is nowhere in this sample. &amp;nbsp;The field response_details contains a pseudo JSON that can be transformed into conformant JSON, but it also does not contain any embedded key named correlation_id nor any embedded value of&amp;nbsp;11315ad3-02a3-419d-a656-85972e07a1a5.&lt;/P&gt;&lt;P&gt;I also fail to see the significance of&amp;nbsp;11315ad3-02a3-419d-a656-85972e07a1a5 vs&amp;nbsp;&lt;SPAN&gt;['321e2253-443a-41f1-8af3-81dbdb8bcc77']. &amp;nbsp;In JSON, they are just strings. &amp;nbsp;None of them is special. &amp;nbsp;As I mentioned earlier&lt;/SPAN&gt;&lt;SPAN&gt;, it is best not to use regex on structured data like this. &amp;nbsp;As your sample event is conformant JSON, using Splunk's built in function is a lot more robust and saves a lot headaches in future maintenance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 09:23:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Field-Extraction/m-p/660774#M228140</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-14T09:23:38Z</dc:date>
    </item>
  </channel>
</rss>

