AWS SQS

Collect logs from AWS SQS

status: beta role: aggregator delivery: at-least-once egress: stream state: stateless output: log

Requirements

The AWS SQS source requires an SQS queue.

Configuration

Example configurations

{
  "sources": {
    "my_source_id": {
      "type": "aws_sqs",
      "poll_secs": 15,
      "client_concurrency": 1,
      "region": "us-east-1",
      "queue_url": "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
    }
  }
}
[sources.my_source_id]
type = "aws_sqs"
poll_secs = 15
client_concurrency = 1
region = "us-east-1"
queue_url = "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
---
sources:
  my_source_id:
    type: aws_sqs
    acknowledgements: null
    poll_secs: 15
    client_concurrency: 1
    region: us-east-1
    queue_url: https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue
{
  "sources": {
    "my_source_id": {
      "type": "aws_sqs",
      "endpoint": "127.0.0.0:5000/path/to/service",
      "poll_secs": 15,
      "client_concurrency": 1,
      "region": "us-east-1",
      "queue_url": "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
    }
  }
}
[sources.my_source_id]
type = "aws_sqs"
endpoint = "127.0.0.0:5000/path/to/service"
poll_secs = 15
client_concurrency = 1
region = "us-east-1"
queue_url = "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
---
sources:
  my_source_id:
    type: aws_sqs
    auth: null
    endpoint: 127.0.0.0:5000/path/to/service
    acknowledgements: null
    poll_secs: 15
    client_concurrency: 1
    framing: null
    proxy: null
    region: us-east-1
    queue_url: https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue
    decoding: null

acknowledgements

common optional object
Controls how acknowledgements are handled by this source.
Controls if the source will wait for destination sinks to deliver the events before acknowledging receipt.
default: false

auth

optional object
Options for the authentication strategy.

auth.access_key_id

optional string literal
The AWS access key id. Used for AWS authentication when communicating with AWS services.
Examples
"AKIAIOSFODNN7EXAMPLE"

auth.assume_role

optional string literal
The ARN of an IAM role to assume at startup.
Examples
"arn:aws:iam::123456789098:role/my_role"

auth.credentials_file

optional string literal
The path to AWS credentials file. Used for AWS authentication when communicating with AWS services.
Examples
"/path/to/aws/credentials"

auth.profile

optional string literal
The AWS profile name. Used to select AWS credentials from a provided credentials file.
Examples
"develop"
default: default

auth.secret_access_key

optional string literal
The AWS secret access key. Used for AWS authentication when communicating with AWS services.
Examples
"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"

client_concurrency

common optional uint
How many clients are receiving / acking SQS messages. Increasing may allow higher throughput. Note: the default is 1 / CPU core
default: 1 (concurrency)

decoding

optional object
Configures in which way frames are decoded into events.

decoding.codec

optional string literal enum
The decoding method.
Enum options
OptionDescription
bytesEvents containing the byte frame as-is.
jsonEvents being parsed from a JSON string.
syslogEvents being parsed from a Syslog message.
default: bytes

endpoint

optional string literal
Custom endpoint for use with AWS-compatible services. Providing a value for this option will make region moot.
Examples
"127.0.0.0:5000/path/to/service"
Relevant when: region = null

framing

optional object
Configures in which way incoming byte sequences are split up into byte frames.
Options for character_delimited framing.
Relevant when: method = `character_delimited`
The character used to separate frames.
Examples
"\n"
"\t"
The maximum frame length limit. Any frames longer than max_length bytes will be discarded entirely.
Examples
65535
102400

framing.method

optional string literal enum
The framing method.
Enum options
OptionDescription
bytesByte frames are passed through as-is according to the underlying I/O boundaries (e.g. split between messages or stream segments).
character_delimitedByte frames which are delimited by a chosen character.
length_delimitedByte frames whose length is encoded in a header.
newline_delimitedByte frames which are delimited by a newline character.
octet_countingByte frames according to the octet counting format.
default: bytes
Options for newline_delimited framing.
Relevant when: method = `newline_delimited`
The maximum frame length limit. Any frames longer than max_length bytes will be discarded entirely.
Examples
65535
102400

framing.octet_counting

optional object
Options for octet_counting framing.
Relevant when: method = `octet_counting`
The maximum frame length limit. Any frames longer than max_length bytes will be discarded entirely.
Examples
65535
102400

poll_secs

common optional uint
How long to wait when polling SQS for new messages. 0-20 seconds
default: 15 (seconds)

proxy

optional object
Configures an HTTP(S) proxy for Vector to use. By default, the globally configured proxy is used.

proxy.enabled

optional bool
If false the proxy will be disabled.
default: true

proxy.http

optional string literal
The URL to proxy HTTP requests through.
Examples
"http://foo.bar:3128"

proxy.https

optional string literal
The URL to proxy HTTPS requests through.
Examples
"http://foo.bar:3128"

proxy.no_proxy

optional [string]

A list of hosts to avoid proxying. Allowed patterns here include:

PatternExample match
Domain namesexample.com matches requests to example.com
Wildcard domains.example.com matches requests to example.com and its subdomains
IP addresses127.0.0.1 matches requests to 127.0.0.1
CIDR blocks192.168.0.0./16 matches requests to any IP addresses in this range
Splat* matches all hosts

queue_url

required string literal
The URL of the SQS queue to receive events from.
Examples
"https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"

region

required string literal
The AWS region of the target service. If endpoint is provided it will override this value since the endpoint includes the region.
Examples
"us-east-1"
Relevant when: endpoint = null

Environment variables

AWS_ACCESS_KEY_ID

common optional string literal
The AWS access key id. Used for AWS authentication when communicating with AWS services.
Examples
AKIAIOSFODNN7EXAMPLE

AWS_CONFIG_FILE

common optional string literal
Specifies the location of the file that the AWS CLI uses to store configuration profiles.
Default: ~/.aws/config

AWS_CREDENTIAL_EXPIRATION

common optional string literal
Expiration time in RFC 3339 format. If unset, credentials won’t expire.
Examples
1996-12-19T16:39:57-08:00

AWS_DEFAULT_REGION

common optional string literal
The default AWS region.
Examples
/path/to/credentials.json

AWS_PROFILE

common optional string literal
Specifies the name of the CLI profile with the credentials and options to use. This can be the name of a profile stored in a credentials or config file.
Default: default
Examples
my-custom-profile

AWS_ROLE_SESSION_NAME

common optional string literal
Specifies a name to associate with the role session. This value appears in CloudTrail logs for commands performed by the user of this profile.
Examples
vector-session

AWS_SECRET_ACCESS_KEY

common optional string literal
The AWS secret access key. Used for AWS authentication when communicating with AWS services.
Examples
wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

AWS_SESSION_TOKEN

common optional string literal
The AWS session token. Used for AWS authentication when communicating with AWS services.
Examples
AQoEXAMPLEH4aoAH0gNCAPy...truncated...zrkuWJOgQs8IZZaIv2BXIa2R4Olgk

AWS_SHARED_CREDENTIALS_FILE

common optional string literal
Specifies the location of the file that the AWS CLI uses to store access keys.
Default: ~/.aws/credentials

HTTPS_PROXY

common optional string literal

The global URL to proxy HTTPS requests through.

If another HTTPS proxy is set in the configuration file or at a component level, this one will be overridden.

The lowercase variant has priority over the uppercase one.

Examples
http://foo.bar:3128

HTTP_PROXY

common optional string literal

The global URL to proxy HTTP requests through.

If another HTTP proxy is set in the configuration file or at a component level, this one will be overridden.

The lowercase variant has priority over the uppercase one.

Examples
http://foo.bar:3128

NO_PROXY

common optional string literal

List of hosts to avoid proxying globally.

Allowed patterns here include:

PatternExample match
Domain namesexample.com matches requests to example.com
Wildcard domains.example.come matches requests to example.com and its subdomains
IP addresses127.0.0.1 matches requests to 127.0.0.1
CIDR blocks192.168.0.0./16 matches requests to any IP addresses in this range
Splat* matches all hosts

If another no_proxy value is set in the configuration file or at a component level, this one is overridden.

The lowercase variant has priority over the uppercase one.

Examples
localhost,.example.com,192.168.0.0./16
*

http_proxy

common optional string literal

The global URL to proxy HTTP requests through.

If another HTTP proxy is set in the configuration file or at a component level, this one will be overridden.

The lowercase variant has priority over the uppercase one.

Examples
http://foo.bar:3128

https_proxy

common optional string literal

The global URL to proxy HTTPS requests through.

If another HTTPS proxy is set in the configuration file or at a component level, this one will be overridden.

The lowercase variant has priority over the uppercase one.

Examples
http://foo.bar:3128

no_proxy

common optional string literal

List of hosts to avoid proxying globally.

Allowed patterns here include:

PatternExample match
Domain namesexample.com matches requests to example.com
Wildcard domains.example.come matches requests to example.com and its subdomains
IP addresses127.0.0.1 matches requests to 127.0.0.1
CIDR blocks192.168.0.0./16 matches requests to any IP addresses in this range
Splat* matches all hosts

If another no_proxy value is set in the configuration file or at a component level, this one is overridden.

The lowercase variant has priority over the uppercase one.

Examples
localhost,.example.com,192.168.0.0./16
*

Output

Logs

Record

An individual SQS record
Fields
message required string literal
The raw message from the SQS record.
Examples
53.126.150.246 - - [01/Oct/2020:11:25:58 -0400] "GET /disintermediate HTTP/2.0" 401 20308
timestamp required timestamp
The time this message was sent to SQS.
Examples
2020-10-10T17:07:36.452332Z

Telemetry

Metrics

link

component_received_bytes_total

counter
The number of raw bytes accepted by this component from source origins.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
host required
The hostname of the system Vector is running on.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the data originated.
peer_path optional
The pathname from which the data originated.
pid required
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

component_received_event_bytes_total

counter
The number of event bytes accepted by this component either from tagged origins like file and uri, or cumulatively from other origins.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
host required
The hostname of the system Vector is running on.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the data originated.
peer_path optional
The pathname from which the data originated.
pid required
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

component_received_events_total

counter
The number of events accepted by this component either from tagged origins like file and uri, or cumulatively from other origins.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
host required
The hostname of the system Vector is running on.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the data originated.
peer_path optional
The pathname from which the data originated.
pid required
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

component_sent_event_bytes_total

counter
The total number of event bytes emitted by this component.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

component_sent_events_total

counter
The total number of events emitted by this component.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

events_out_total

counter
The total number of events emitted by this component. This metric is deprecated and will be removed in a future version. Use component_sent_events_total instead.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

sqs_message_delete_failed_total

counter
The total number of failures to delete SQS messages.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

How it works

AWS authentication

Vector checks for AWS credentials in the following order:

  1. The access_key_id and secret_access_key options.
  2. The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
  3. The credential_process command in the AWS config file (usually located at ~/.aws/config).
  4. The AWS credentials file (usually located at ~/.aws/credentials).
  5. The IAM instance profile (only works if running on an EC2 instance with an instance profile/role).

If no credentials are found, Vector’s health check fails and an error is logged. If your AWS credentials expire, Vector will automatically search for up-to-date credentials in the places (and order) described above.

Obtaining an access key

In general, we recommend using instance profiles/roles whenever possible. In cases where this is not possible you can generate an AWS access key for any user within your AWS account. AWS provides a detailed guide on how to do this. Such created AWS access keys can be used via access_key_id and secret_access_key options.

Assuming roles

Vector can assume an AWS IAM role via the assume_role option. This is an optional setting that is helpful for a variety of use cases, such as cross account access.

AWS SQS

The aws_sqs source receives messages from AWS SQS (Simple Queue Service). This is a highly scaleable / durable queueing system with at-least-once queuing semantics. Messages are received in batches (up to 10 at a time), and then deleted in batches (again up to 10). Messages are either deleted immediately after receiving, or after it has been fully processed by the sinks, depending on the acknowledgements setting.

Context

By default, the aws_sqs source augments events with helpful context keys.

State

This component is stateless, meaning its behavior is consistent across each input.