Skip to main content

Elasticsearch/OpenSearch ExternalSink for audit-framework — index audit events for search & dashboards.

Project description

audit-framework-elasticsearch

An Elasticsearch / OpenSearch sink for audit-framework: indexes each audit event as a document so you can search, filter, and dashboard your audit log (Kibana / OpenSearch Dashboards) with no custom UI.

One adapter serves both Elasticsearch and OpenSearch — they share the same document-indexing and cluster-health REST API.

Install

pip install audit-framework-elasticsearch          # bring your own transport
pip install audit-framework-elasticsearch[httpx]   # + the convenience httpx transport

Use

from audit_framework_elasticsearch.sink import ElasticsearchSink, httpx_transport
from audit_framework.core.middlewares.sink_fanout import SinkFanOutMiddleware
import httpx

client = httpx.AsyncClient(timeout=10.0)            # pooled, app-lifetime
sink = ElasticsearchSink(
    "https://es.internal:9200",
    index="audit",                                  # → daily index audit-2026.06.26
    api_key="...",                                  # Authorization: ApiKey ...
    transport=httpx_transport(client),
)
pipeline.use(SinkFanOutMiddleware([sink]))

OpenSearch is identical — point base_url at your cluster and (optionally) pass name="opensearch". Via the registry, both names resolve to the same class:

registry.discover_entrypoints()
SinkClass = registry.get("external_sink", "opensearch")   # or "elasticsearch"

No hard HTTP dependency

The sink talks to the cluster through an injected async transport (method, url, json_body, headers) -> HttpResult, so it's fully unit-testable without a network and you control the HTTP client / pooling. httpx_transport() is provided for convenience (the httpx extra); supply a shared httpx.AsyncClient in production.

Behaviour

  • emitPOST {base}/{index}[-YYYY.MM.DD]/_doc with event.to_dict(); a non-2xx response raises ElasticsearchSinkError so SinkFanOutMiddleware records the failure (without aborting other sinks).
  • health_checkGET {base}/_cluster/health, True when reachable and not red.
  • Daily indices (daily=True, the default) map cleanly onto ILM/ISM retention policies — aligning with per-policy retention_days.

Development

pip install -e ".[dev]"
pytest        # 13 stdlib-only tests (fake transport; no httpx/network needed)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audit_framework_elasticsearch-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audit_framework_elasticsearch-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file audit_framework_elasticsearch-0.1.0.tar.gz.

File metadata

File hashes

Hashes for audit_framework_elasticsearch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9fe9879a3ebb45909c56974a5f9d0e2b150c426a860b0fd93b3e2ac3d6119c25
MD5 d8832c8486f49cd40c9c1d8a1fc97f08
BLAKE2b-256 31c8b69266c39e1bc890a8802531f69ce9387990eeae92a225fe053646d1644b

See more details on using hashes here.

Provenance

The following attestation bundles were made for audit_framework_elasticsearch-0.1.0.tar.gz:

Publisher: release.yml on vanmarkic/audit-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file audit_framework_elasticsearch-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for audit_framework_elasticsearch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f011aab39e7679b09df68d2ace633a539fde0deff7986f9d91636921e3176cb0
MD5 091c13d773ec4500da2ac00368305b93
BLAKE2b-256 15f241d0fca73e804268479b63b7b2c891057a3fc8b37bb719b9cde314057af5

See more details on using hashes here.

Provenance

The following attestation bundles were made for audit_framework_elasticsearch-0.1.0-py3-none-any.whl:

Publisher: release.yml on vanmarkic/audit-logger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page