Skip to content

Add AWS SQS Alert#1750

Merged
jertel merged 11 commits intojertel:masterfrom
AnthraX1:master
Mar 7, 2026
Merged

Add AWS SQS Alert#1750
jertel merged 11 commits intojertel:masterfrom
AnthraX1:master

Conversation

@AnthraX1
Copy link
Contributor

@AnthraX1 AnthraX1 commented Mar 2, 2026

Description

Add a new SqsAlerter for sending alerts via AWS SQS, modeled after the existing SnsAlerter.

Changes:

  • New alerter class SqsAlerter in elastalert/alerters/sqs.py that sends alert data as a JSON message to an SQS queue
  • Supports authentication via AWS access key/secret or named AWS profile
  • Handles SQS 256 KB message size limit by cropping alert text at 128 KB and falling back to omitting text if the full JSON body still exceeds 256 KB
  • Uses json.dumps(default=str) to safely serialize match data that may contain non-JSON-native types (e.g. datetime objects)
  • Registered sqs as a new alert type in loaders.py
  • Added SQS rule options (sqs_queue_url, sqs_aws_access_key_id, sqs_aws_secret_access_key, sqs_aws_region, sqs_aws_profile) to schema.yaml

New rule options:

Option Required Default Description
sqs_queue_url Yes Full URL of the SQS queue
sqs_aws_access_key_id No AWS access key ID
sqs_aws_secret_access_key No AWS secret access key
sqs_aws_region No us-east-1 AWS region
sqs_aws_profile No Named AWS profile (overrides key/secret if set)

No breaking changes.

Checklist

  • I have reviewed the contributing guidelines.
  • I have included unit tests for my changes or additions.
  • I have successfully run make test-docker with my changes.
  • I have manually tested all relevant modes of the change in this PR.
  • I have updated the documentation.
  • I have updated the changelog.

Questions or Comments

Unit tests cover: get_info, required option validation, EAException on send failure, message size truncation, and AWS profile-based session creation (6 tests, all passing).

Documentation and changelog updates are pending and will be added in a follow-up or upon reviewer request.

AnthraX1 and others added 7 commits April 7, 2025 04:18
- Introduced SqsAlerter class for handling alerts via AWS SQS.
- Updated schema.yaml to include SQS configuration properties.
- Adjusted SqsAlerter to ensure message body adheres to SQS size limits.
Add new SqsAlerter for sending alerts via AWS SQS queues, modeled
after the existing SnsAlerter. Supports authentication via access
key/secret or named AWS profile, and handles SQS 256 KB message
size limit with automatic text truncation.

- New alerter class in elastalert/alerters/sqs.py
- Registered 'sqs' alert type in loaders.py
- Added SQS options to schema.yaml
- Added unit tests in tests/alerters/sqs_test.py

Made-with: Cursor
@nsano-rururu
Copy link
Collaborator

The document has not been modified
docs/source/elastalert.rst
docs/source/alerts.rst

@nsano-rururu
Copy link
Collaborator

It is not added to the New features in CHANGELOG.md

@nsano-rururu
Copy link
Collaborator

Have you run make test-docker locally and confirmed that the test is successful?

@nsano-rururu
Copy link
Collaborator

Have you actually run it and confirmed that an alert notification is sent?

@AnthraX1
Copy link
Contributor Author

AnthraX1 commented Mar 4, 2026

Have you run make test-docker locally and confirmed that the test is successful?

I'll test it now

@AnthraX1
Copy link
Contributor Author

AnthraX1 commented Mar 5, 2026

docker test is successful but not receiving messages on real production env. no errors were logged. I'm trying to figure out

AnthraX1 added 2 commits March 6, 2026 01:34
- Documented the new AWS SQS alerter in alerts.rst, detailing its usage and configuration options.
- Updated elastalert.rst to include AWS SQS in the list of supported alert types.
- Enhanced the SqsAlerter implementation to infer AWS region from the SQS queue URL and adjusted message size handling.
- Updated unit tests to verify new functionality, including region inference and message size limits.
@AnthraX1
Copy link
Contributor Author

AnthraX1 commented Mar 5, 2026

docker test is successful but not receiving messages on real production env. no errors were logged. I'm trying to figure out

prod test passed. Added region infer from queue url. Turns out sqs.send_message() doesn't actually use the region in the url.

Copy link
Owner

@jertel jertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this new feature. I left a couple of comments.

AnthraX1 added 2 commits March 7, 2026 21:56
- Updated CHANGELOG to include a reference to the AWS SQS alerter pull request.
- Refactored the _get_region_from_sqs_url function in sqs.py to remove unnecessary try-except block for improved error handling.
@jertel jertel merged commit 5636e67 into jertel:master Mar 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants