This page describes webpatser/fledge-pulse-elasticsearch 0.3.0. Options live under pulse.storage.elasticsearch in config/pulse.php. Only list the keys you change; the defaults are:
'storage' => [ 'driver' => env('PULSE_STORAGE_DRIVER', 'database'), 'elasticsearch' => [ 'connection' => env('PULSE_ES_CONNECTION', 'elasticsearch'), // database.connections.<name> 'prefix' => env('PULSE_ES_PREFIX', 'pulse'), 'shards' => (int) env('PULSE_ES_SHARDS', 1), 'replicas' => (int) env('PULSE_ES_REPLICAS', 0), 'ilm' => (bool) env('PULSE_ES_ILM', true), 'bulk_chunk' => (int) env('PULSE_ES_BULK_CHUNK', 1000), 'bulk_retries' => (int) env('PULSE_ES_BULK_RETRIES', 3), 'bulk_backoff_ms' => (int) env('PULSE_ES_BULK_BACKOFF_MS', 500), 'deduplicate_entries' => env('PULSE_ES_DEDUPLICATE_ENTRIES'), // null: only with the redis ingest 'terms_shard_size' => env('PULSE_ES_TERMS_SHARD_SIZE'), // null: max(10000, limit * 50) 'timeout' => (float) env('PULSE_ES_TIMEOUT', 10), 'connect_timeout' => (float) env('PULSE_ES_CONNECT_TIMEOUT', 2), 'retries' => env('PULSE_ES_RETRIES'), // null: one per extra host ],],
A key set to null in your config (for example env('PULSE_ES_ILM') with the variable unset) keeps the package default.
The connection block uses the familiar database.connections.elasticsearch shape: hosts, username/password, api_key/api_id, auth_type + cloud_id, ssl_cert and options.ssl_verification.
Timeouts and failed hosts
Every request has a timeout (whole request and inactivity, default 10 seconds) and a connect_timeout (TCP connect and TLS handshake, default 2 seconds), so an unreachable cluster cannot hold a PHP-FPM worker, a queue worker or pulse:work for long.
The client uses its own node pool: a host that failed (a timeout, a refused connection) is skipped for 5 seconds and then tried again, and when every host has failed the one that failed first is retried. The elasticsearch/elasticsearch default marks a host dead on the first network error and never tries it again, so a single-host process would refuse every request with "No alive nodes" until it restarts. retries is the number of times a request that failed on the network is resent to another host (default: one per extra host, none for a single host).
Writes
Entries and values are sent in separate _bulk requests of at most bulk_chunk documents. Entry requests set require_data_stream, so writing before pulse:elasticsearch:install fails with a message that says to run it, instead of creating a plain {prefix}-entries index with dynamic mappings. A values-only batch before the install still auto-creates {prefix}-values; delete it and run the install command.
Documents rejected with 429 (es_rejected_execution_exception, the cluster's write queue is full) are resent up to bulk_retries times, waiting bulk_backoff_ms and then twice as long each time, before store() throws. The wait suspends only the current fiber.
Deduplication
With entry deduplication every entry gets a deterministic _id (a hash chain over the batch: its own content and every entry before it) and is written with create. When store() throws halfway, the Redis ingest keeps the batch and stores it again later; the entries that already made it in come back as version conflicts and are skipped, so nothing counts twice.
deduplicate_entries unset (null, the default) turns deduplication on only when pulse.ingest.driver is redis. With the storage ingest every request is stored on its own and Pulse never stores a failed batch again, so Elasticsearch generates the ids and identical requests never collapse. true or false forces it either way; pulse:elasticsearch:install warns when it is forced on with the storage ingest.
Warning: The Elasticsearch transport resends a
_bulkrequest that timed out when several hosts are configured or the client'sretriesoption is set, and without ids such a resend can count entries twice. If your setup retries, or a custom ingest driver redelivers batches, setPULSE_ES_DEDUPLICATE_ENTRIES=true.
Residual risks with deduplication on:
- ids are unique per backing index, so a retried batch that lands in a newer backing index (after a daily rollover in between) is not deduplicated;
- two separately stored batches that start with an identical run of entries in the same second share those ids, and the second run is dropped.
Deletes and ILM
With ilm disabled (clusters without ILM, such as serverless) no policy is installed and trim() deletes old entries by query instead. Entry deletions (trim() without ILM, purge()) run as background delete_by_query tasks with conflicts=proceed; values are deleted with one request. trim() does not wait for its task; purge() polls the tasks API until its task is done (up to 10 minutes), so pulse:clear is complete on return. ElasticsearchStorage::awaitDeletes() waits for pending tasks and refreshes the entries.
Upgrading from 0.1.x
Version 0.2.0 changed the deduplicate_entries default from true to null. No reindex or migration is needed. If you published the config earlier, it still contains the old default, which forces deduplication on whatever the ingest driver is:
'deduplicate_entries' => (bool) env('PULSE_ES_DEDUPLICATE_ENTRIES', true),
Change that line to get the driver-dependent default:
'deduplicate_entries' => env('PULSE_ES_DEDUPLICATE_ENTRIES'),
Or set PULSE_ES_DEDUPLICATE_ENTRIES=true to keep the old behaviour. Entries collapsed before the upgrade stay collapsed. Version 0.3.0 requires PHP 8.6 (breaking) and webpatser/fledge-pulse ^1.8.1.4.