A package to consume events from an Azure storage queue, process log files, and forward them to a HTTP endpoint or file.
Project description
Azure Log Forwarder
Azure Log Forwarder is a Python package that consumes events from an Azure storage queue, processes log files stored in Azure Blob Storage, and forwards the logs either to an HTTP endpoint or writes them to files.
Features
- Consume blob creation events from an Azure storage queue.
- Download and decompress gzipped JSON log files from Azure Blob Storage.
- 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 Azure Storage account with a configured event grid and storage queue.
- Azure CLI or Azure portal access to set up the necessary infrastructure.
Installation
With internet access:
pip install sap-ecs-azure-log-forwarder
pip install sap-ecs-azure-log-forwarder==<version>
Without internet access:
- Navigate to the Download files section on pypi.org for sap-ecs-azure-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:
pip install /path/to/your_file.whl
Example:
pip install /User/Downloads/sap_ecs_azure_log_forwarder-1.0.2-py3-none-any.whl
Configuration
Set up the following environment variables to configure the Azure Log Forwarder:
SAS_TOKEN
: The SAS token for Azure Blob Storage.STORAGE_ACCOUNT_NAME
: The name of your Azure Storage account (required if using SAS token).QUEUE_NAME
: The name of the Azure storage 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
orfiles
).HTTP_ENDPOINT
: The HTTP endpoint to forward logs to (required ifOUTPUT_METHOD
ishttp
).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 istoken
.- Auth Token: Set
AUTH_METHOD
totoken
and configureAUTH_TOKEN
.AUTH_TOKEN
: Bearer/OAuth token for HTTP endpoint authentication.
- API Key: Set
AUTH_METHOD
toapi_key
and configureAPI_KEY
.API_KEY
: API key for HTTP endpoint API key authentication.
- Auth Token: Set
OUTPUT_DIR
: The output directory to write log files to (required ifOUTPUT_METHOD
isfiles
).
You can set these environment variables in your shell or in a .env
file.
Example of setting environment variables in a shell:
export SAS_TOKEN="your_SAS_token"
export STORAGE_ACCOUNT_NAME="your_storage_account_name"
export QUEUE_NAME="your_queue_name"
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 Azure Log Forwarder, use the following command:
sap-ecs-azure-log-forwarder
This will start the process of consuming events from the storage 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 not 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.
References
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.1
- First proper release!
1.0.2
- Updated README with diagrams and instructions on installing the package without access to the internet.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file sap_ecs_azure_log_forwarder-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: sap_ecs_azure_log_forwarder-1.0.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c572222c9c7d7dfb038b34f02af4499c1070f3427bce97d5a3ddca9736678d3 |
|
MD5 | d3db1d3b299e643bd599811c60e29661 |
|
BLAKE2b-256 | 7ad9028d40650a444d155a715c24ee849f1d720c75d9f726c95f091d542c96f4 |