<?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 Ingesting and 'Transforming' AWS SQS Messages in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639226#M109147</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; We are trying to ingest JSON based messages from an AWS SQS topic.&amp;nbsp; &amp;nbsp; When ingesting the messages we are finding extra added json around the actual Message we are trying to ingest.&amp;nbsp; The extra JSON is automatically added in by AWS SQS.&amp;nbsp; The actual Message we want to ingest has the xpath of&amp;nbsp; "?BodyJson?Message".&amp;nbsp; &amp;nbsp; Can we configure the Splunk TA to pull the SQS Messages off the topic but apply some type of xpath or transform to only ingest the Message (?BodyJson?Message).&amp;nbsp; &amp;nbsp; &amp;nbsp;See screenshot below.&amp;nbsp; While pulling the message off the SQS topic we only want the message in the green rectangle.&amp;nbsp; &amp;nbsp;but its buried in all the other json....&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2023-04-07_12-20-57.jpg" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24843iB6167F384C7DB469/image-size/large?v=v2&amp;amp;px=999" role="button" title="2023-04-07_12-20-57.jpg" alt="2023-04-07_12-20-57.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Actual JSON to whole message above in screenshot.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"MessageId": 23411111111444,
"ReceiptHandle": "y",
"MD5OfBody": 23411333333333111111444,
"Body": "{\n \"Type\" : \"Notification\",\n \"MessageId\" : \"xxxxxxx-xxx-xxxxxx\",\n \"TopicArn\" : \"arn:topic123\",\n \"Message\" : \"{\\\"timestamp\\\": \\\"1680882420000\\\", \\\"metric_name:test\\\": \\\"0\\\", \\\"aggregation\\\": \\\"avg\\\", \\\"resolution\\\": \\\"1m\\\", \\\"unit\\\": \\\"Percent\\\", \\\"entity.id\\\": \\\"SERVICE-12345\\\", \\\"entity.name\\\": \\\"test\\\", \\\"source.name\\\": \\\"testsource\\\"}\",\n \"Timestamp\" : \"2023-04-07T15:56:02.509Z\",\n \"SignatureVersion\" : \"1\",\n \"Signature\" : \"23423423423\",\n \"SigningCertURL\" : \"https://sns.u234234234234234234\",\n \"UnsubscribeURL\" : \"https://sns.23423423423423423423\"\n}",
"Attributes": {
"SenderId": "xxxxxxxxxxxxxxx",
"ApproximateFirstReceiveTimestamp": "1680882978026",
"ApproximateReceiveCount": "1",
"SentTimestamp": "1680882962536"
},
"BodyJson": {
"Type": "Notification",
"MessageId": "xxxxxxxxxxxxxxxxx",
"TopicArn": "arn:aws:sns:us-east-1:996142040734:APP-4498-dev-PerfEngDynatraceAPIClient-DynatraceMetricsSNSTopic-qFolXGcy2Ufh",
"Message": "{\"timestamp\": \"1680882420000\", \"metric_name:test\": \"0\", \"aggregation\": \"avg\", \"resolution\": \"1m\", \"unit\": \"Percent\", \"entity.id\": \"SERVICE-12345\", \"entity.name\": \"test\", \"source.name\": \"testsource\"}",
"Timestamp": "2023-04-07T15:56:02.509Z",
"SignatureVersion": "1",
"Signature": 23423423423,
"SigningCertURL": "https://sns.u234234234234234234",
"UnsubscribeURL": "https://sns.23423423423423423423"
}
}&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 10 Apr 2023 14:00:56 GMT</pubDate>
    <dc:creator>y2000maxima</dc:creator>
    <dc:date>2023-04-10T14:00:56Z</dc:date>
    <item>
      <title>Ingesting and 'Transforming' AWS SQS Messages</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639226#M109147</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; We are trying to ingest JSON based messages from an AWS SQS topic.&amp;nbsp; &amp;nbsp; When ingesting the messages we are finding extra added json around the actual Message we are trying to ingest.&amp;nbsp; The extra JSON is automatically added in by AWS SQS.&amp;nbsp; The actual Message we want to ingest has the xpath of&amp;nbsp; "?BodyJson?Message".&amp;nbsp; &amp;nbsp; Can we configure the Splunk TA to pull the SQS Messages off the topic but apply some type of xpath or transform to only ingest the Message (?BodyJson?Message).&amp;nbsp; &amp;nbsp; &amp;nbsp;See screenshot below.&amp;nbsp; While pulling the message off the SQS topic we only want the message in the green rectangle.&amp;nbsp; &amp;nbsp;but its buried in all the other json....&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2023-04-07_12-20-57.jpg" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24843iB6167F384C7DB469/image-size/large?v=v2&amp;amp;px=999" role="button" title="2023-04-07_12-20-57.jpg" alt="2023-04-07_12-20-57.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Actual JSON to whole message above in screenshot.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"MessageId": 23411111111444,
"ReceiptHandle": "y",
"MD5OfBody": 23411333333333111111444,
"Body": "{\n \"Type\" : \"Notification\",\n \"MessageId\" : \"xxxxxxx-xxx-xxxxxx\",\n \"TopicArn\" : \"arn:topic123\",\n \"Message\" : \"{\\\"timestamp\\\": \\\"1680882420000\\\", \\\"metric_name:test\\\": \\\"0\\\", \\\"aggregation\\\": \\\"avg\\\", \\\"resolution\\\": \\\"1m\\\", \\\"unit\\\": \\\"Percent\\\", \\\"entity.id\\\": \\\"SERVICE-12345\\\", \\\"entity.name\\\": \\\"test\\\", \\\"source.name\\\": \\\"testsource\\\"}\",\n \"Timestamp\" : \"2023-04-07T15:56:02.509Z\",\n \"SignatureVersion\" : \"1\",\n \"Signature\" : \"23423423423\",\n \"SigningCertURL\" : \"https://sns.u234234234234234234\",\n \"UnsubscribeURL\" : \"https://sns.23423423423423423423\"\n}",
"Attributes": {
"SenderId": "xxxxxxxxxxxxxxx",
"ApproximateFirstReceiveTimestamp": "1680882978026",
"ApproximateReceiveCount": "1",
"SentTimestamp": "1680882962536"
},
"BodyJson": {
"Type": "Notification",
"MessageId": "xxxxxxxxxxxxxxxxx",
"TopicArn": "arn:aws:sns:us-east-1:996142040734:APP-4498-dev-PerfEngDynatraceAPIClient-DynatraceMetricsSNSTopic-qFolXGcy2Ufh",
"Message": "{\"timestamp\": \"1680882420000\", \"metric_name:test\": \"0\", \"aggregation\": \"avg\", \"resolution\": \"1m\", \"unit\": \"Percent\", \"entity.id\": \"SERVICE-12345\", \"entity.name\": \"test\", \"source.name\": \"testsource\"}",
"Timestamp": "2023-04-07T15:56:02.509Z",
"SignatureVersion": "1",
"Signature": 23423423423,
"SigningCertURL": "https://sns.u234234234234234234",
"UnsubscribeURL": "https://sns.23423423423423423423"
}
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 10 Apr 2023 14:00:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639226#M109147</guid>
      <dc:creator>y2000maxima</dc:creator>
      <dc:date>2023-04-10T14:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Ingesting and 'Transforming' AWS SQS Messages</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639315#M109159</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can do this pretty easily with an INGEST_EVAL transform:&lt;/P&gt;&lt;PRE&gt;# props.conf&lt;BR /&gt;&lt;BR /&gt;[aws:sqs]&lt;BR /&gt;TRANSFORMS-copy_bodyjson_message_to_raw = copy_bodyjson_message_to_raw&lt;BR /&gt;&lt;BR /&gt;# transforms.conf&lt;BR /&gt;&lt;BR /&gt;[copy_bodyjson_message_to_raw]&lt;BR /&gt;INGEST_EVAL = _raw=json_extract(_raw, "BodyJson.Message"), _time=strptime(json_extract(_raw, "timestamp"), "%s%3Q")&lt;/PRE&gt;&lt;P&gt;The example transform also extracts the timestamp from the inner JSON message.&lt;/P&gt;&lt;P&gt;If you have other events with sourcetype = aws:sqs, you can use a source stanza in props.conf instead of a source type stanza and reference the SQS input by name:&lt;/P&gt;&lt;PRE&gt;[source::&amp;lt;your_sqs_source_name&amp;gt;]&lt;BR /&gt;TRANSFORMS-copy_bodyjson_message_to_raw = copy_bodyjson_message_to_raw&lt;/PRE&gt;&lt;P&gt;If you need to retain the original event, you can clone the event into a new source type and modify _raw on the cloned event:&lt;/P&gt;&lt;PRE&gt;# props.conf&lt;BR /&gt;&lt;BR /&gt;[source::&amp;lt;your_sqs_source_name&amp;gt;]&lt;BR /&gt;TRANSFORMS-clone_service_metric = clone_service_metric&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;[aws:sqs:service_metric]&lt;BR /&gt;&lt;/SPAN&gt;TRANSFORMS-copy_bodyjson_message_to_raw = copy_bodyjson_message_to_raw&lt;BR /&gt;&lt;BR /&gt;# transforms.conf&lt;BR /&gt;&lt;BR /&gt;[clone_service_metric]&lt;BR /&gt;REGEX = .&lt;BR /&gt;CLONE_SOURCETYPE = aws:sqs:service_metric&lt;BR /&gt;&lt;BR /&gt;[copy_bodyjson_message_to_raw]&lt;BR /&gt;INGEST_EVAL = _raw=json_extract(_raw, "BodyJson.Message"), _time=strptime(json_extract(_raw, "timestamp"), "%s%3Q")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 00:31:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639315#M109159</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2023-04-10T00:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Ingesting and 'Transforming' AWS SQS Messages</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639368#M109167</link>
      <description>&lt;P data-unlink="true"&gt;Thank you very much&amp;nbsp;tscroggins.&amp;nbsp; We will try your suggestion out.&amp;nbsp; &amp;nbsp;Hopefully being on Splunk SaaS won't prevent our ability to do this.&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 13:37:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639368#M109167</guid>
      <dc:creator>y2000maxima</dc:creator>
      <dc:date>2023-04-10T13:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Ingesting and 'Transforming' AWS SQS Messages</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639374#M109169</link>
      <description>&lt;P&gt;You'll likely need to contact Splunk support to implement INGEST_EVAL. If the schema and field order of the outer and inner JSON never change, you can also use a combination of SEDCMD and a regular transform:&lt;/P&gt;&lt;PRE&gt;# props.conf&lt;BR /&gt;&lt;BR /&gt;[aws:sqs]&lt;BR /&gt;MAX_TIMESTAMP_LOOKAHEAD = 13&lt;BR /&gt;SEDCMD-unescape = s/\\//g&lt;BR /&gt;TIME_FORMAT = %s%3Q&lt;BR /&gt;TIME_PREFIX = "Message"\s*:\s*"\{\\"timestamp\\"\s*:\s*\\"&lt;BR /&gt;TRANSFORMS-copy_message_to_raw = copy_message_to_raw&lt;BR /&gt;&lt;BR /&gt;# transforms.conf&lt;BR /&gt;&lt;BR /&gt;[copy_message_to_raw]&lt;BR /&gt;DEST_KEY = _raw&lt;BR /&gt;FORMAT = $1&lt;BR /&gt;REGEX = "Message"\s*:\s*"([^}]+\})&lt;/PRE&gt;&lt;P&gt;Everything above can be implemented through the user interface.&lt;/P&gt;&lt;P&gt;Note that the SEDCMD regular expression will aggressively remove all backslashes. In my test environment (Splunk Enterprise 9.0.4.1), typical solutions for stripping backslashes end up&amp;nbsp;&lt;EM&gt;adding&lt;/EM&gt; backslashes. E.g.:&lt;/P&gt;&lt;PRE&gt;\" =&amp;gt; s/\x5C"/"/g =&amp;gt; \\"&lt;/PRE&gt;&lt;P&gt;Splunk's treatment of backslashes in SEDCMD and SPL regular expression commands has always been finicky. Strict adherence to C-style escape sequences in SPL strings and no special handling in SEDCMD would be preferred, but I think they're doing their best to balance the user experience.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 15:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639374#M109169</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2023-04-10T15:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Ingesting and 'Transforming' AWS SQS Messages</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639527#M109197</link>
      <description>&lt;P&gt;Thank you again!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 17:00:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Ingesting-and-Transforming-AWS-SQS-Messages/m-p/639527#M109197</guid>
      <dc:creator>y2000maxima</dc:creator>
      <dc:date>2023-04-11T17:00:28Z</dc:date>
    </item>
  </channel>
</rss>

