Aliyun Log Python SDK
Official Python SDK for Alibaba Cloud Log Service (SLS), wrapping the full REST API with consumer groups and ETL.
Repository Health
Technical Analysis
aliyun-log-python-sdk is the official Python SDK for Alibaba Cloud Log Service (SLS), the managed log collection, storage, and analytics platform. It wraps the complete SLS REST API — project and logstore management, log ingestion, querying, and shard operations — behind a single LogClient, so Python applications can connect to SLS efficiently.
Beyond the raw API, the SDK ships higher-level building blocks: a consumer-group framework for scalable checkpoint-based consumption, a Python logging handler that streams records directly to SLS, and an ETL engine for transforming and copying data across logstores, including Elasticsearch migration. It supports both Python 2.7 and modern Python 3.
What You Get
- A
LogClientwrapping the full SLS REST API for management and data operations - A consumer-group framework for scalable, checkpoint-based log consumption
- A Python logging handler that ships log records directly to SLS
- ETL utilities to transform and copy data across logstores
- High-level helpers for auto-paging, auto-retry, and resource copying
- Elasticsearch-to-SLS data migration support
Common Use Cases
- Ingesting application logs into Alibaba Cloud Log Service from Python services
- Building consumers that process SLS log streams at scale with checkpoints
- Routing standard Python logging output to SLS via the provided handler
- Running cross-logstore ETL transformations and data copies
- Querying and paging through large SLS result sets programmatically
Under The Hood
Architecture — The SDK is organized around a central LogClient class that encapsulates every Log Service (SLS) REST endpoint — project/logstore management, data ingestion (PutLogs), querying (GetLogs), and shard operations. On top of the raw client sit higher-level abstractions: a consumer-group framework for scalable, checkpoint-based log consumption, a Python logging handler that ships log records straight to SLS, and an ETL subsystem for transforming and copying data across logstores. Request signing and auth are handled by a dedicated auth module supporting AK/SK and STS credentials.
Tech Stack — Pure Python supporting both Python 2.7 and Python 3.7+, built on requests for HTTP, protobuf for the efficient log-group wire format, and standard compression (lz4/zstd) for payloads. It is packaged via setuptools with per-Python-version requirement files and tested through tox.
Code Quality — The repository includes a tests/unit suite of roughly two dozen modules covering auth, the log client (mocked), index/mapping converters, compression, and CLI config, run in CI across multiple Python versions. The wide Python-version support introduces some legacy compatibility shims.
API Design — The public surface mirrors the SLS REST API closely, so each method maps to a documented server operation, while high-level helpers (auto-paging, auto-retry-till-complete, consumer groups, logging handler) reduce boilerplate for common tasks. Extensive ReadTheDocs documentation and a companion CLI round out the developer experience.