logstash-plugins / logstash-integration-aws

Apache License 2.0
7 stars 17 forks source link

Support SQS message (user) attributes #22

Open piequi opened 1 year ago

piequi commented 1 year ago

Currently the SQS input plugin only handles message body, no matter there are message attributes defined by the user. There is a need to handle those attributes when receiving log events because they could contain relevant metadata for the event logged.

We, for example, have implemented a Python logging handler that sends JSON records containing log messages to a SQS queue. Those messages are read by Logstash, processed and indexed in Elasticsearch.

The content of those JSON records is defined by https://docs.python.org/3/library/logging.html#logrecord-attributes.

With the current implementation of the SQS input plugin, we cannot enrich those records with context metadata (like the cloud region were the service emitting the logs is running).

Using SQS message user attributes, we could add alongside to the log records some metadata to enrich the corresponding event logged.

The idea could be to handle those user attributes in https://github.com/logstash-plugins/logstash-integration-aws/blob/183d113484b8a555abca91db00b2a6844274a258/lib/logstash/inputs/sqs.rb#L132

I already started implementing this and will submit a PR shortly for review.