Docs / Outputs / Elasticsearch

Elasticsearch

Store the entries in an Elasticsearch index.

Overview

PackageReadsPurgeSetup
elasticsearch/elasticsearchYesYesYes

The commands, the EasyAdmin viewer and ReaderInterface can read this output. audit-log:purge and audit-log:setup work with it. See Outputs.

Enable the output

config/packages/symfonycorp_audit_log.yaml
symfonycorp_audit_log:
    outputs:
        elasticsearch:
            client: Elastic\Elasticsearch\Client   # service id. Register this client yourself
            index: audit_log

Create the index

The output does not create its index by default. Without it, a write can fail, and the bundle only logs the failure. Run the setup command when you deploy. It does not change an index that exists:

terminal
$ bin/console audit-log:setup --output=elasticsearch

In development and in tests, you can set auto_setup: true to create the index on the first write. Do not use it in production.

Indexed context - the index has one field for each key of indexed_context. When you change this list, create a new index before you deploy. The context filter does not find the entries written before the change.

Result window

offset + limit cannot be more than index.max_result_window (10000 by default). This applies to audit-log:list, the EasyAdmin list and ReaderInterface. Narrow the read with from, to or context, or raise this setting on the index.