Skip to main content

Module elasticsearch_logger

Module elasticsearch_logger 

Source
Expand description

Elasticsearch access-logger (elasticsearch-logger).

Ships access-log entries to Elasticsearch via its _bulk API. Each request builds one log entry (the shared build_entry shape, or a custom log_format) that is handed to a fire-and-forget BatchSink; a background task POSTs batches as newline-delimited JSON (NDJSON) to <endpoint>/_bulk.

Ports APISIX’s elasticsearch-logger: the bulk envelope pairs an {"index":{"_index":<name>}} action line with each entry line, exactly as get_logger_entry does in the Lua plugin.

§Deviations from APISIX

  • No Elasticsearch version probe. APISIX issues a GET / to detect the ES major version and, for ES 5/6, adds _type: "_doc" to the action line. featherbit targets ES 7+ and never emits _type, so it performs no version-probe callout.
  • Static index name. APISIX resolves {time} strftime tokens and $var references in field.index per request against ctx.var. Because entries are flushed in batches without a request context, featherbit uses field.index as a literal string.

Structs§

ElasticsearchLoggerPlugin
Node that batches access-log entries and ships them to Elasticsearch.
EsFlusher 🔒
Delivers batches to Elasticsearch’s _bulk endpoint.

Functions§

build_bulk_body 🔒
Builds the NDJSON _bulk body: for every entry an action line {"index":{"_index":<index>}} followed by the entry, each terminated by a newline (APISIX get_logger_entry). Pure and network-free for testing.
collect_endpoints 🔒
Reads endpoint_addr (string) and/or endpoint_addrs (array), trims trailing slashes, and errors when none are present.