CMRESHandler
Elasticsearch Log handler for the logging library
What it is and what it does
CMRESHandler is a logging handler that bridges Python's standard logging library and Elasticsearch, allowing you to send log records directly to Elasticsearch indices instead of (or in addition to) files or stdout. It wraps log entries as JSON documents and buffers them before flushing to Elasticsearch, supporting optional authentication (basic, Kerberos, AWS IAM) and SSL encryption.
The handler integrates with Django logging configuration and lets you attach custom fields to individual log records for instrumentation—for example, timing metrics or request IDs—which then become queryable fields in Elasticsearch. It preserves standard logging metadata like exception tracebacks, method names, and line numbers, making it useful for centralized log aggregation and analysis.
Use it for:
- Centralize application logs from multiple Python services into a single Elasticsearch cluster for unified search and analysis.
- Instrument Django applications to log database query times and SQL statements alongside application events for performance monitoring.
- Add custom fields to logs on a per-message basis to enable rich filtering and aggregation in Elasticsearch.
- Replace file-based logging with Elasticsearch to avoid log rotation and disk management overhead in containerized environments.
- Combine Elasticsearch logging with other handlers to send critical errors to files while routing all logs to Elasticsearch for analysis.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Python logging handler that sends log records directly to Elasticsearch, integrating with the standard logging library to store structured logs in Elasticsearch indices.
Yes, if you are already running Elasticsearch and need a lightweight Python logging handler to send logs directly to it. No, if you require active maintenance or support for modern Elasticsearch versions—the package is dormant since 2017-10-08 and has not been updated to verify compatibility with current Elasticsearch releases. Consider it a stable but unsupported tool; test thoroughly with your Elasticsearch version before production use.
Install
cmreshandler on PyPI
pip
pip install cmreshandleruv
uv add cmreshandlerpoetry
poetry add cmreshandlerInstalling CMRESHandler
Before you install
Low install friction with pure-Python wheels available for both Python 2 and 3. However, the package is dormant—last release was 2017-10-08 and no commits since 2024-06-06. Elasticsearch client compatibility with modern versions is unverified.
License in practice
Licensed under Apache2 (permissive), so you can use, modify, and distribute the package freely in commercial and open-source projects without restrictive obligations.
Quickstart
pip install CMRESHandler
from cmreslogging.handlers import CMRESHandler
import logging
handler = CMRESHandler(hosts=[{'host': 'localhost', 'port': 9200}],
auth_type=CMRESHandler.AuthType.NO_AUTH,
es_index_name="my_python_index")
log = logging.getLogger("PythonTest")
log.addHandler(handler)
log.info("This is logged to Elasticsearch")
Requires a running Elasticsearch server accessible at the configured host and port; optional dependencies (requests-kerberos, requests-aws4auth) needed only for Kerberos or AWS IAM authentication.
Verify before relying
- Compatibility with modern Elasticsearch versions given the last release was 2017-10-08.
- Whether the elasticsearch dependency pins to a specific major version or accepts current releases.
- Support status for Python versions beyond 2.7 and 3.6 as stated in classifiers.
Package facts
| License | Apache2 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — elasticsearch, enum, requests |
| Maintenance | dormant — 3,232 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 313,416/month — #7,715 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: CMRESHandler-1.0.0-py2-none-any.whl; CMRESHandler-1.0.0-py3-none-any.whl
Keywords: logging, elasticsearch, handler, log, django, instrumentation
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
opensearch-loggerProvides a Python logging handler that sends…
permissive · top 15,000 on PyPI
python3-logstashA Python logging handler that forwards log…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-elasticsearchAdds distributed tracing to Elasticsearch…
permissive · top 5,000 on PyPI
google-cloud-appengine-loggingClient library for Google Cloud AppEngine…
permissive · top 1,000 on PyPI
django-opensearch-dslIndexes Django model instances into OpenSearch…
permissive · top 15,000 on PyPI
elasticsearchOfficial Python client library for connecting…
permissive · top 1,000 on PyPI
elasticsearch8-dslA high-level Python query builder for…
permissive · top 15,000 on PyPI
elasticsearch7Official Python client for Elasticsearch that…
permissive · top 15,000 on PyPI
django-elasticsearch-dsl-drfProvides Django REST framework views,…
copyleft · top 15,000 on PyPI
opentelemetry-instrumentation-loggingIntegrates Python's standard logging module…
permissive · top 1,000 on PyPI