Splunk AWS SQS-Based S3 Integration and Best Practices

Author

Reads 1.1K

Computer server in data center room
Credit: pexels.com, Computer server in data center room

To integrate Splunk with Amazon S3 using AWS SQS, you'll need to set up an SQS queue to handle the messages generated by S3 events. This allows Splunk to process the data in real-time.

The SQS queue acts as a buffer, enabling Splunk to handle large volumes of data without overwhelming the system. This is particularly useful when dealing with high-traffic S3 buckets.

Splunk supports various message formats, including JSON and CSV, which can be used to send data from S3 to SQS.

Service Configuration Prerequisites

Before you can start integrating Splunk with AWS SQS-based S3, you need to configure a few services. First, you'll need to create two SQS queues: one to receive notifications and another to serve as a dead letter queue.

Creating an SNS topic is also a crucial step, as it will allow S3 to send notifications to Splunk about new events in the S3 bucket.

To enable S3 to send notifications to SNS, you'll need to configure S3 to send notifications for all object create events to the SNS topic. This will let S3 notify Splunk that new events have been written to the S3 bucket.

Expand your knowledge: Create S3 Bucket Aws Cli

Computer server in data center room
Credit: pexels.com, Computer server in data center room

To complete the setup, you'll need to subscribe the main SQS queue to the corresponding SNS topic. This will ensure that Splunk receives the notifications it needs to process the events from S3.

Here's a summary of the steps:

  1. Create an SQS Queue to receive notifications.
  2. Create a second SQS Queue to serve as a dead letter queue.
  3. Create an SNS Topic.
  4. Configure S3 to send notifications to the SNS Topic.
  5. Subscribe the main SQS Queue to the SNS Topic.

Configuration

To configure an SQS-Based S3 input, you'll need to create an SQS Queue to receive notifications and a second SQS Queue to serve as a dead letter queue. Additionally, an SNS Topic must be created.

Before configuring inputs manually in inputs.conf, you'll need to create a stanza using the provided template and add it to $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/inputs.conf. This template includes a setting for s3_file_decoder, which determines how Splunk processes the data.

The valid values for s3_file_decoder are CustomLogs, CloudTrail, ELBAccessLogs, CloudFrontAccessLogs, S3AccessLogs, Config, DelimitedFilesDecoder, and TransitGatewayFlowLogs. If you want to ingest custom logs, you must set s3_file_decoder = CustomLogs, but keep in mind that this setting does not parse the data.

To remove duplication of events without unique IDs, use the hash function.

Using Configuration Files

Credit: youtube.com, 07 Configuration Files

Using configuration files is a crucial step in setting up your Splunk instance to collect data from various sources. To configure an SQS-Based S3 input, you need to create a stanza in the inputs.conf file.

The stanza should be placed in the $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/inputs.conf directory. If the file or path does not exist, you need to create it. You can find more information on these settings in the /README/inputs.conf.spec file under your add-on directory.

To collect cloudtrail data, you can use the following template as a starting point. You'll need to specify the s3_file_decoder value, which can be one of the following: CustomLogs, CloudTrail, ELBAccessLogs, CloudFrontAccessLogs, S3AccessLogs, Config, DelimitedFilesDecoder, or TransitGatewayFlowLogs.

If you want to ingest custom logs other than the natively supported AWS log types, you'll need to set s3_file_decoder = CustomLogs. This will let you ingest custom logs into your Splunk platform instance, but it won't parse the data. You'll need to perform additional configurations in props.conf and transforms.conf to parse the collected data to meet your specific requirements.

The CustomLogs S3 parser supports the following archived file formats: .tar, .tar.gz, .tar.bz2, .tgz, .gz, .gzip, and .zip. Because events don't have unique IDs, you should use the hash function to remove duplication.

You might enjoy: Aws Create S3 Bucket

Configuring Cribl Stream with Amazon SQS

Credit: youtube.com, ⚡ Master AWS SQS in Simple Steps | Message Queues Explained with Demo 🚀

Configuring Cribl Stream with Amazon SQS is a straightforward process. To get started, navigate to the top nav and click Manage, then select a Worker Group to configure.

There are two options to configure Cribl Stream: via the graphical QuickConnect UI or the Routing UI. If you choose QuickConnect, click Routing > QuickConnect (Stream) or Collect (Edge), then Add Source at left, and select Amazon > SQS.

Alternatively, if you prefer the Routing UI, click Data > Sources (Stream) or More > Sources (Edge), then select Amazon > SQS. Next, click New Source to open a New Source modal that provides the options below.

To receive data from Amazon SQS, you'll need to configure the SQS queue URL. This can be done by entering the full SQS queue URL in the SQS Queue Name box.

The following permissions are needed on the SQS queue:

  • sqs:ReceiveMessage
  • sqs:DeleteMessage
  • sqs:GetQueueAttributes
  • sqs:GetQueueUrl
  • sqs:CreateQueue (optional)

These permissions are essential for Cribl Stream to interact with your SQS queue. Make sure to grant these permissions to ensure seamless data collection.

Permissions

Credit: youtube.com, Splunk integration with S3 using Splunk Smart Store

Permissions are a crucial aspect of setting up Splunk AWS SQS-Based S3 inputs. The necessary permissions vary depending on the AWS services used.

To configure AWS permissions, you'll need to grant the following permissions:

  • For SQS, you'll need `sqs:ReceiveMessage`, `sqs:DeleteMessage`, `sqs:GetQueueAttributes`, `sqs:GetQueueUrl`, and optionally `sqs:CreateQueue` if you want Cribl Stream to create the queue.
  • For S3, you'll need `GetObject` if Bucket Versioning is disabled, and `GetObjectVersion` if it's enabled.
  • For KMS, you'll need `Decrypt`.

You can find more information on these permissions in the AWS documentation.

If you're using an IAM role with the AWS SQS-Based S3 input, you'll need to create an IAM role with the necessary permissions and add it to your Splunk configuration.

Setup and Installation

To set up Splunk with AWS SQS-based S3, you'll first need to create an SQS queue. This queue will be used to store messages sent from S3.

You can create an SQS queue using the AWS Management Console, the AWS CLI, or the AWS SDKs. For this example, we'll use the AWS Management Console.

Next, you'll need to create an IAM role that allows Splunk to access the SQS queue and S3 bucket. This role will grant the necessary permissions to read from the SQS queue and write to the S3 bucket.

The IAM role should have the following permissions: SQSReadOnlyAccess and S3ReadOnlyAccess. These permissions will allow Splunk to read from the SQS queue and S3 bucket, but not write to them.

Here's an interesting read: S3 Console Aws

Migrating from Generic

Person analyzing business data on a laptop in a modern indoor setting.
Credit: pexels.com, Person analyzing business data on a laptop in a modern indoor setting.

If you're using a generic S3 input to collect data, it's worth considering a switch to the SQS-Based S3 input for better ingestion performance.

To make the switch, you'll first need to perform some prerequisite configurations of AWS services. This includes setting up an SQS queue with a Dead Letter Queue and proper visibility timeout configured.

Set up the S3 bucket with the S3 key prefix, if specified, to send notifications to the SQS queue. This can be done by following the instructions in the Splunk Add-on for AWS.

You'll also need to add an SQS-Based S3 input using the SQS queue you just configured. Make sure the new input is enabled and starts collecting data from the bucket.

To phase out the old generic S3 input, edit it and set the End Date/Time field to the current system time. Wait until all the task executions of the old input are complete, which may take at least double your polling frequency.

On a similar theme: Aws Data Pipeline S3 Athena

Close-up of financial documents with eyeglasses, depicting data analysis and business insights.
Credit: pexels.com, Close-up of financial documents with eyeglasses, depicting data analysis and business insights.

Once the old input is complete, disable it to prevent any further data collection. Finally, run the following searches to delete any duplicate events collected during the transition:

You may also want to delete the old generic S3 input once you're sure the new SQS-Based S3 input is working as expected.

Auto Scale Data Collection

To auto scale data collection, you can create an AWS auto scaling group for your heavy forwarder instances where the SQS-Based S3 inputs is running. This involves specifying a launch configuration or creating an AMI to provision new EC2 instances that host heavy forwarders.

You can use a bootstrap script to install the Splunk Add-on for AWS and configure SQS-Based S3 inputs. For detailed information about the auto-scaling group and how to create it, see https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html.

To monitor your SQS-Based S3 inputs, you can set CloudWatch alarms for one of the following Amazon SQS metrics: SQS queue length, SQS message count, or SQS average message delay. For instructions on setting CloudWatch alarms for Amazon SQS metrics, see https://docs.aws.amazon.com/cdk/v1/guide/how-to-set-cw-alarm.html.

You can use the CloudWatch alarm as a trigger to provision new heavy forwarder instances with SQS-Based S3 inputs configured to consume messages from the same SQS queue. This will improve ingestion performance and help you handle large volumes of data.

App のインストール&確認

An artist's illustration of artificial intelligence (AI). This image represents storage of collected data in AI. It was created by Wes Cockx as part of the Visualising AI project launched ...
Credit: pexels.com, An artist's illustration of artificial intelligence (AI). This image represents storage of collected data in AI. It was created by Wes Cockx as part of the Visualising AI project launched ...

App Store では、検索バーにアプリの名前を入力し、検索結果からアプリを選択します。Google Play Store では、検索バーにアプリの名前を入力し、検索結果からアプリを選択します。

アプリをダウンロードしたら、インストールを開始します。インストールプロセスは数秒で完了します。

アプリをインストールしたら、ホーム画面にアプリのアイコンが表示されます。アプリを起動すると、インストールが正常に完了したことを確認できます。

SQS Integration

To configure SQS-Based S3 inputs, you'll need to collect specific events from various AWS services. These events include CloudFront Access Logs, Config, ELB Access logs, CloudTrail, S3 Access Logs, VPC Flow Logs, Transit Gateway Flow Logs, and Custom data types.

You can configure SQS-Based S3 inputs to collect these events by following the steps outlined in the AWS documentation.

To receive data from Amazon SQS, you'll need to configure Cribl Stream, which involves selecting a Worker Group and choosing the SQS source. You can do this via the QuickConnect UI or the Routing UI.

To configure SQS permissions, you'll need to grant the following permissions on the SQS queue: sqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueAttributes, sqs:GetQueueUrl, and sqs:CreateQueue (if you want Cribl Stream to create the queue).

You'll also need to create an SQS queue to receive notifications and a second SQS queue to serve as a dead letter queue. This is a crucial step in setting up SQS-Based S3 inputs.

Credit: youtube.com, Splunk App AWS How-to: 8 - Custom S3 Files via SQS-based S3

Here are the SQS permissions you'll need to grant:

  • sqs:ReceiveMessage
  • sqs:DeleteMessage
  • sqs:GetQueueAttributes
  • sqs:GetQueueUrl
  • sqs:CreateQueue (optional)

Note that you'll need to create two SQS queues: one for Config and one for CloudTrail. This is because Splunk will treat them as separate source types and you'll need to create separate inputs for each.

To create an SQS queue, you can follow the steps outlined in the AWS documentation.

To configure S3 to send notifications for All object create events to an SNS Topic, you'll need to follow these steps:

  1. Create an SNS Topic.
  2. Subscribe the main SQS Queue to the corresponding SNS Topic.

By following these steps, you'll be able to set up SQS-Based S3 inputs and collect events from various AWS services.

Best Practices and Settings

To collect historical logs stored in S3 buckets, use the generic S3 input instead of the SQS-Based S3 input, as the former allows you to set the initial scan time parameter to collect data generated after a specified time in the past.

For high throughput data ingestion from an S3 bucket, configure multiple SQS-Based S3 inputs for the S3 bucket to scale out data collection. This approach ensures that data is collected efficiently and effectively.

Credit: youtube.com, GDI: AWS CloudTrail using Splunk Data Manager (S3): Part 1

To prevent data duplication, configure the SQS visibility timeout to 5 minutes or longer. If the visibility timeout for a message is reached before the message is fully processed by the SQS-Based S3 input, the message reappears in the queue and is retrieved and processed again.

Here are some key settings to keep in mind when configuring an SQS-Based S3 input:

  • s3_file_decoder = CustomLogs for ingesting custom logs
  • Valid values for s3_file_decoder are CustomLogs, CloudTrail, ELBAccessLogs, CloudFrontAccessLogs, S3AccessLogs, Config, DelimitedFilesDecoder, TransitGatewayFlowLogs
  • CustomLogs S3 parser supports archived file formats: .tar, .tar.gz, .tar.bz2, .tgz, .gz, .gzip, and .zip

Best Practices

To collect historical logs stored in S3 buckets, use the generic S3 input instead of the SQS-Based S3 input, as the former allows you to set the initial scan time parameter to collect data generated after a specified time in the past.

To collect logs from multiple S3 buckets, even across regions, set up one input to collect data from all the buckets by configuring these buckets to send notifications to the same SQS queue from which the SQS-Based S3 input polls messages.

Configuring multiple SQS-Based S3 inputs for an S3 bucket can help achieve high throughput data ingestion, but you might need to wait for a few minutes before new events are ingested and can be searched.

A fresh viewpoint: Aws S3 Copy Multiple Files

Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.
Credit: pexels.com, Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.

The SQS-Based S3 input is stateless, which means that if one input goes down, the other inputs continue to collect data and take over the load from the failed input, enhancing fault tolerance.

The SQS-Based S3 input supports signature validation, which requires setting up a Dead Letter Queue for the SQS queue to store invalid messages, and configuring the SQS visibility timeout to prevent multiple inputs from receiving and processing messages in a queue more than once.

Here are some key settings to keep in mind for the SQS-Based S3 input:

  • Initial scan time parameter: Set to collect data generated after a specified time in the past.
  • SQS visibility timeout: Set to 5 minutes or longer to prevent duplicate data.
  • Dead Letter Queue: Set up to store invalid messages.
  • SQS queue: Configure to send notifications to the same SQS queue from which the SQS-Based S3 input polls messages.

Config Settings

To configure an SQS-Based S3 input, create a stanza in $SPLUNK_HOME/etc/apps/Splunk_TA_aws/local/inputs.conf using the following template.

Valid values for s3_file_decoder are CustomLogs, CloudTrail, ELBAccessLogs, CloudFrontAccessLogs, S3AccessLogs, Config, DelimitedFilesDecoder, and TransitGatewayFlowLogs.

If you want to ingest custom logs other than the natively supported AWS log types, you must set s3_file_decoder = CustomLogs.

CustomLogs S3 parser supports archived file formats like .tar, .tar.gz, .tar.bz2, .tgz, .gz, .gzip, and .zip.

To remove duplication, use the hash function because events do not have unique IDs.

For more information on these settings, see /README/inputs.conf.spec under your add-on directory.

CloudTrail and Logging

Credit: youtube.com, Splunk App AWS How-to: 4 - Cloudtrail

To start, you'll want to set up CloudTrail to record all activity across all regions, including both read and write logs. This will give you a complete picture of what's happening in your AWS environment.

You'll also need to create an S3 bucket to store CloudTrail logs. You can use a new bucket or an existing one you already have set up.

In terms of indexing, you can use the default index, which is fine for now. Keep in mind that using a non-default index won't prevent you from using the App for AWS, as it will automatically add the index to your base search macro.

If this caught your attention, see: Aws S3 Set Content Type

CloudTrailの設定

To start setting up CloudTrail, it's recommended to enable logging for all regions. This will allow you to capture both read and write logs.

You'll need to create an S3 Bucket specifically for storing CloudTrail data. This can be a new bucket or an existing one.

For indexing, you can use the default index, which is perfectly fine. If you choose to use a custom index, you'll still be able to use the App for AWS.

The default index is the main index, and it's a good starting point.

Configログとは?

Credit: youtube.com, How to use CloudTrail Lake for Log Management Audit Complaince report

Configログは、AWS Configが管理対象リソースの構成と変更を記録するために使用されます。

Configログは、管理対象リソースの構成と変更を記録するために使用されます。

Configログには、リソースの構成と変更、ルールの評価結果などが記録されています。

Configログを使用すると、管理対象リソースの構成と変更を監視および分析できます。

Configログは、AWS Configが管理対象リソースの構成と変更を記録するために使用されるログデータの一種です。

Import and Supported Types

The SQS-Based S3 input in Splunk supports two message types: ConfigurationHistoryDeliveryCompleted and ConfigurationSnapshotDeliveryCompleted.

You can choose the menu path that corresponds to the data type you want to collect, and the system will automatically set the source type and display relevant field settings in the subsequent configuration page.

For AWS logs, the recommended way to collect data is through the SQS-Based S3 input, which is also recommended for Config and CloudTrail.

Here are the supported sourcetypes for the SQS-Based S3 input:

SourceType Mapping with File Decoder

SourceType Mapping with File Decoder is a crucial step in configuring your SQS-Based S3 input. You can find the recommended sourcetypes for each S3 file decoder in the table below.

For example, if you're using the CloudTrail decoder, your sourcetype will be aws:cloudtrail. If you're using the Custom Logs decoder, your sourcetype will be aws:s3. It's also worth noting that the CustomLogs S3 parser supports a variety of archived file formats, including tar, tar.gz, tar.bz2, tgz, gz, gzip, and zip.

Splunk Add-on for AWS Custom Data

Credit: youtube.com, Ingest AWS S3 Logs Into Splunk

To use the Splunk Add-on for AWS Custom Data, you'll need to select the SQS queue name in the AWS Input Configuration. However, if the "Save" button turns grey and you can't save the configuration, it's likely due to insufficient permissions towards your AWS account.

You can check the splunkd and sourcetype=aws:sqs* logs to see the AWS error behind the UI. This will help you identify the issue.

A sample input.conf entry for the AWS Custom Data is [aws_s3://testtype], which requires an aws_account, bucket_name, and character_set. The host_name is s3.amazonaws.com, and the index is testindex.

Here's an interesting read: Aws S3 Cors Configuration

Supported Message Types

The SQS-Based S3 input supports two main message types.

The ConfigurationHistoryDeliveryCompleted message type is one of the supported types.

ConfigurationSnapshotDeliveryCompleted is another supported message type that can be used.

Here are the supported message types listed out:

  • ConfigurationHistoryDeliveryCompleted
  • ConfigurationSnapshotDeliveryCompleted

Elaine Block

Junior Assigning Editor

Elaine Block is a seasoned Assigning Editor with a keen eye for detail and a passion for storytelling. With a background in technology and a knack for understanding complex topics, she has successfully guided numerous articles to publication across various categories. Elaine's expertise spans a wide range of subjects, from cutting-edge tech solutions like Nextcloud Configuration to in-depth explorations of emerging trends and innovative ideas.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.