Awesome
Sentry/Raven SQS Proxy
About
This is a very simple Python project that polls SQS for Sentry messages and then proxies them over to a Sentry instance.
This is based on the implementation of the Sentry.IO SQSTransport
as implemented in this PR to raven-python.
How to use:
The first part in using this is to make use of the Sentry SQSTransport
implemented in the getsentry/raven-python
project.
This will have an instance, lambda function, or anything with AWS credentials to an SQS queue to forward all Sentry messages to SQS. This project will then listen for those messages on the queue and simply proxy them over to Sentry for storage.
Required Items:
For sending to the SQS queue, you will need the following:
- An SQS queue
- An IAM role with the following permissions to the SQS queue in question:
sqs:GetQueueUrl sqs:SendMessage
- A Sentry DSN
- Python code that creates a Sentry client that looks similar to this:
from raven.base import Client from raven.transport.sqs import SQSTransport # SQS details that are required are: # 1. `sqs_region` # 2. `sqs_account` This is the 12 digit AWS account number # 3. `sqs_name` sentry_client = Client(dsn="https://some-sentry-dsn?sqs_region=REGION&sqs_account=ACCOUNT_NUMsqs_name=QUEUE_NAME", transport=SQSTransport)
For retrieving messages:
- Access to the SQS queue the source app above is sending to. This will need the following permissions against the queue:
sqs:GetQueueUrl sqs:SendMessage sqs:DeleteMessage
- Network-level access to the Sentry instance
Installation:
- Make and activate a Python virtual environment
- Run
pip install raven_sqs_proxy
to install this - Hopefully you are running with on-instance AWS IAM role credentials. Otherwise, you will need to export them into your environment.
- Run
sqsproxy --queue-name NAME-OF-QUEUE --queue-region QUEUE-REGION --queue-account AWS_ACCOUNT_ID_OF_QUEUE
That's it.