# AWS Log Forwarder
AWS Log Forwarder is a Python app that consumes events from an AWS SQS queue, processes log files stored in AWS S3, and forwards the logs either to an HTTP endpoint or writes them to files.
![Image for sap-ecs-aws-log-forwarder](https://raw.githubusercontent.com/sap-ecs-log-forwarders/pypi/main/aws-log-forwarder.png)
## Features
- Consume object creation events from an AWS SQS queue.
- Download and decompress gzipped JSON log files from AWS S3.
- Forward logs to an HTTP endpoint or write them to files.
- Support for TLS protocol.
- Support for different HTTP authentication methods (Token, API Key).
- Configurable through environment variables.
- Configurable timeout to exit the program if no messages are found for a specified duration.
## Prerequisites
- Python 3.8 or higher
- An AWS account with a configured S3 bucket and SQS queue.
- AWS CLI or AWS Management Console access to set up the necessary infrastructure.
## Installation
### With internet access:
```sh
pip install sap-ecs-aws-log-forwarder
pip install sap-ecs-aws-log-forwarder==<version>
```
### Without internet access:
- Navigate to the **Download files** section on **pypi.org** for **sap-ecs-aws-log-forwarder** and download the latest .whl (wheel) file. The file will typically have a name that includes details about compatibility (e.g., example_package-1.0-py3-none-any.whl).
- Navigate to the directory where your **.whl** file is located using the cd command, or provide the full path to the **.whl** file when running the pip command.
Run the following command:
```sh
pip install /path/to/your_file.whl
```
**Example**:
```sh
pip install /User/Downloads/sap_ecs_aws_log_forwarder-1.0.4-py3-none-any.whl
```
## Configuration
Set up the following environment variables to configure the AWS Log Forwarder:
- `AWS_ACCESS_KEY_ID`: Your AWS access key ID.
- `AWS_SECRET_ACCESS_KEY`: Your AWS secret access key.
- `AWS_REGION`: The AWS region where your resources are located.
- `SQS_QUEUE_URL`: The URL of the AWS SQS queue to consume events from.
- `TIMEOUT_DURATION`: The time duration in seconds to wait for messages before exiting.
- `OUTPUT_METHOD`: The method to forward logs (`http` or `files`).
- `HTTP_ENDPOINT`: The HTTP endpoint to forward logs to (required if `OUTPUT_METHOD` is `http`).
- `TLS_CERT_PATH`: Path to the TLS certificate for mutual TLS connections.
- `TLS_KEY_PATH`: Path to the TLS key for mutual TLS connections.
- `AUTH_METHOD`: Authentication method (`token`, `api_key`). Default is `token`.
- **Auth Token**: Set `AUTH_METHOD` to `token` and configure `AUTH_TOKEN`.
- `AUTH_TOKEN`: Bearer/OAuth token for HTTP endpoint authentication.
- **API Key**: Set `AUTH_METHOD` to `api_key` and configure `API_KEY`.
- `API_KEY`: API key for HTTP endpoint API key authentication.
- `OUTPUT_DIR`: The output directory to write log files to (required if `OUTPUT_METHOD` is `files`).
You can set these environment variables in your shell or in a `.env` file.
### Example of setting environment variables in a shell:
```sh
export AWS_ACCESS_KEY_ID="your_access_key_id"
export AWS_SECRET_ACCESS_KEY="your_secret_access_key"
export AWS_REGION="your_region"
export SQS_QUEUE_URL="your_sqs_queue_url"
export TIMEOUT_DURATION=120 # Timeout after 120 seconds of inactivity. DO NOT set for indefinite runs.
# For http
export OUTPUT_METHOD="http"
export HTTP_ENDPOINT="https://your-http-endpoint.com"
# For TLS certs
export TLS_CERT_PATH="/path/to/your/tls_cert.pem"
export TLS_KEY_PATH="/path/to/your/tls_key.pem"
# For Bearer/OAuth Token authentication
export AUTH_METHOD="token"
export AUTH_TOKEN="your_token"
# For API Key authentication
export AUTH_METHOD="api_key"
export API_KEY="your_api_key"
# For file output
export OUTPUT_METHOD="files"
export OUTPUT_DIR="/path/to/your/output/directory/"
```
## Usage
To run the AWS Log Forwarder, use the following command:
```sh
sap-ecs-aws-log-forwarder
```
This will start the process of consuming events from the SQS queue, downloading and processing log files, and forwarding them according to the specified method. The program will exit if no messages are found within the specified timeout duration. If no timeout duration is specified, the program will run indefinitely.
## Things to remember
- If you do not set a **TIMEOUT_DURATION**, the program will run indefinitely.
- Your IAM user needs to have appropriate permissions to read files from the S3 bucket and messages from the SQS queue. This app will fail otherwise.
## References
1. [Amazon SQS Documentation](https://docs.aws.amazon.com/sqs/)
2. [Amazon S3 Documentation](https://docs.aws.amazon.com/s3/)
3. [Managing access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html)
## License
This application and its source code are licensed under the terms of the SAP Developer License Agreement. See the LICENSE file for more information.
## Release Notes
### 1.0.3
- First proper release!
### 1.0.4
- METADATA updates.
### 1.0.5
- Updated README with diagrams and instructions on installing the package without access to the internet.
Raw data
{
"_id": null,
"home_page": "https://www.sap.com/",
"name": "sap-ecs-aws-log-forwarder",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "SAP AWS Log Forwarder, SAP Log Forwarder",
"author": "SAP SE",
"author_email": null,
"download_url": null,
"platform": null,
"description": "# AWS Log Forwarder\n\nAWS Log Forwarder is a Python app that consumes events from an AWS SQS queue, processes log files stored in AWS S3, and forwards the logs either to an HTTP endpoint or writes them to files.\n\n![Image for sap-ecs-aws-log-forwarder](https://raw.githubusercontent.com/sap-ecs-log-forwarders/pypi/main/aws-log-forwarder.png)\n## Features\n\n- Consume object creation events from an AWS SQS queue.\n- Download and decompress gzipped JSON log files from AWS S3.\n- Forward logs to an HTTP endpoint or write them to files.\n- Support for TLS protocol.\n- Support for different HTTP authentication methods (Token, API Key).\n- Configurable through environment variables.\n- Configurable timeout to exit the program if no messages are found for a specified duration.\n\n## Prerequisites\n\n- Python 3.8 or higher\n- An AWS account with a configured S3 bucket and SQS queue.\n- AWS CLI or AWS Management Console access to set up the necessary infrastructure.\n\n## Installation\n### With internet access:\n```sh\npip install sap-ecs-aws-log-forwarder\npip install sap-ecs-aws-log-forwarder==<version>\n```\n\n### Without internet access:\n- Navigate to the **Download files** section on **pypi.org** for **sap-ecs-aws-log-forwarder** and download the latest .whl (wheel) file. The file will typically have a name that includes details about compatibility (e.g., example_package-1.0-py3-none-any.whl).\n- Navigate to the directory where your **.whl** file is located using the cd command, or provide the full path to the **.whl** file when running the pip command.\n\nRun the following command:\n```sh\npip install /path/to/your_file.whl\n```\n**Example**:\n```sh\npip install /User/Downloads/sap_ecs_aws_log_forwarder-1.0.4-py3-none-any.whl\n```\n\n## Configuration\n\nSet up the following environment variables to configure the AWS Log Forwarder:\n\n- `AWS_ACCESS_KEY_ID`: Your AWS access key ID.\n- `AWS_SECRET_ACCESS_KEY`: Your AWS secret access key.\n- `AWS_REGION`: The AWS region where your resources are located.\n- `SQS_QUEUE_URL`: The URL of the AWS SQS queue to consume events from.\n- `TIMEOUT_DURATION`: The time duration in seconds to wait for messages before exiting.\n- `OUTPUT_METHOD`: The method to forward logs (`http` or `files`).\n- `HTTP_ENDPOINT`: The HTTP endpoint to forward logs to (required if `OUTPUT_METHOD` is `http`).\n- `TLS_CERT_PATH`: Path to the TLS certificate for mutual TLS connections.\n- `TLS_KEY_PATH`: Path to the TLS key for mutual TLS connections.\n- `AUTH_METHOD`: Authentication method (`token`, `api_key`). Default is `token`.\n - **Auth Token**: Set `AUTH_METHOD` to `token` and configure `AUTH_TOKEN`.\n - `AUTH_TOKEN`: Bearer/OAuth token for HTTP endpoint authentication.\n - **API Key**: Set `AUTH_METHOD` to `api_key` and configure `API_KEY`.\n - `API_KEY`: API key for HTTP endpoint API key authentication.\n- `OUTPUT_DIR`: The output directory to write log files to (required if `OUTPUT_METHOD` is `files`).\n\nYou can set these environment variables in your shell or in a `.env` file.\n\n### Example of setting environment variables in a shell:\n\n```sh\nexport AWS_ACCESS_KEY_ID=\"your_access_key_id\"\nexport AWS_SECRET_ACCESS_KEY=\"your_secret_access_key\"\nexport AWS_REGION=\"your_region\"\n\nexport SQS_QUEUE_URL=\"your_sqs_queue_url\"\nexport TIMEOUT_DURATION=120 # Timeout after 120 seconds of inactivity. DO NOT set for indefinite runs.\n\n# For http\nexport OUTPUT_METHOD=\"http\"\nexport HTTP_ENDPOINT=\"https://your-http-endpoint.com\"\n# For TLS certs\nexport TLS_CERT_PATH=\"/path/to/your/tls_cert.pem\"\nexport TLS_KEY_PATH=\"/path/to/your/tls_key.pem\"\n# For Bearer/OAuth Token authentication\nexport AUTH_METHOD=\"token\"\nexport AUTH_TOKEN=\"your_token\"\n# For API Key authentication\nexport AUTH_METHOD=\"api_key\"\nexport API_KEY=\"your_api_key\"\n\n# For file output\nexport OUTPUT_METHOD=\"files\"\nexport OUTPUT_DIR=\"/path/to/your/output/directory/\"\n```\n\n## Usage\n\nTo run the AWS Log Forwarder, use the following command:\n```sh\nsap-ecs-aws-log-forwarder\n```\nThis will start the process of consuming events from the SQS queue, downloading and processing log files, and forwarding them according to the specified method. The program will exit if no messages are found within the specified timeout duration. If no timeout duration is specified, the program will run indefinitely.\n\n## Things to remember\n- If you do not set a **TIMEOUT_DURATION**, the program will run indefinitely.\n- Your IAM user needs to have appropriate permissions to read files from the S3 bucket and messages from the SQS queue. This app will fail otherwise.\n\n## References\n1. [Amazon SQS Documentation](https://docs.aws.amazon.com/sqs/)\n2. [Amazon S3 Documentation](https://docs.aws.amazon.com/s3/)\n3. [Managing access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html)\n\n## License\nThis application and its source code are licensed under the terms of the SAP Developer License Agreement. See the LICENSE file for more information.\n\n## Release Notes\n### 1.0.3\n- First proper release!\n\n### 1.0.4\n- METADATA updates.\n\n### 1.0.5\n- Updated README with diagrams and instructions on installing the package without access to the internet.\n",
"bugtrack_url": null,
"license": "SAP DEVELOPER LICENSE AGREEMENT",
"summary": "A package to consume events from an AWS SQS queue, process log files, and forward them to a HTTP endpoint or file.",
"version": "1.0.5",
"project_urls": {
"Homepage": "https://www.sap.com/"
},
"split_keywords": [
"sap aws log forwarder",
" sap log forwarder"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0359a5348a962eaf0fbdb602b0302566ef585de739d89b2f7ee0d9fac39a1022",
"md5": "e37281437669020a1caa226c139eea1f",
"sha256": "c5c5612bbc086a81eced12dc2ba7022f37f1d8f7e4858650459f98a5d5accac2"
},
"downloads": -1,
"filename": "sap_ecs_aws_log_forwarder-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e37281437669020a1caa226c139eea1f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 12879,
"upload_time": "2024-09-16T23:18:59",
"upload_time_iso_8601": "2024-09-16T23:18:59.002764Z",
"url": "https://files.pythonhosted.org/packages/03/59/a5348a962eaf0fbdb602b0302566ef585de739d89b2f7ee0d9fac39a1022/sap_ecs_aws_log_forwarder-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-16 23:18:59",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "sap-ecs-aws-log-forwarder"
}