Skip to main content

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

  • emit → POST {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_check → GET {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

For AI agents & coding assistants

This package ships its agent guide — AGENTS.md — inside the wheel (installed at <site-packages>/audit_framework_elasticsearch/AGENTS.md). Read it offline, with no docs site and no network, even from an airgapped Nexus PyPI mirror:

python -m audit_framework_elasticsearch
python -c "import audit_framework_elasticsearch; print(audit_framework_elasticsearch.overview())"

AGENTS.md is the single source of truth: mental model, one runnable quickstart, and the exact public API. audit_framework_elasticsearch.overview() returns it, and tests/guide_test.py compiles its examples so the guide can't drift from the code.

Metadata

Release files for audit-framework-elasticsearch 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for audit-framework-elasticsearch 0.1.1
File Size Uploaded Provenance
audit_framework_elasticsearch-0.1.1.tar.gz 10.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for audit-framework-elasticsearch 0.1.1
File Interpreter ABI Platform
audit_framework_elasticsearch-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / audit_framework_elasticsearch-0.1.1.tar.gz

Download URL audit_framework_elasticsearch-0.1.1.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cf4bae68841dc2ae2c3ca5cfac54e9960991b01a627e111774c094593e17dc33
BLAKE2b-256 checksum
How to use checksums
b6c08ec223e01bc02fba8748e17143d024f75a71a040651f7eca80e5bc57b8cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.

Transparency log

Release files / audit_framework_elasticsearch-0.1.1-py3-none-any.whl

Download URL audit_framework_elasticsearch-0.1.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13efba57af61af5e30927aee1884b64d228c9a85984bc41449aeeaf1594c0c0f
BLAKE2b-256 checksum
How to use checksums
58f6528cd0dd7bba1b3113204a02475c012e4611832c2b4cfaaa61f7138620a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.

Transparency log

Security for audit-framework-elasticsearch 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for audit_framework_elasticsearch-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page