Skip to content

Emit datadog metric when Elasticsearch index is set to read only/allow delete - #27

Open
gherceg wants to merge 1 commit into
masterfrom
gh/es-readonly-check
Open

Emit datadog metric when Elasticsearch index is set to read only/allow delete#27
gherceg wants to merge 1 commit into
masterfrom
gh/es-readonly-check

Conversation

@gherceg

@gherceg gherceg commented Jul 18, 2026

Copy link
Copy Markdown
Member

Problem

When Elasticsearch disk usage reaches the flood-stage watermark (currently set to 95%), ES sets index.blocks.read_only_allow_delete: true on affected indices. This block is not cleared automatically when disk frees up. It must be reset manually, and until then the index rejects writes. We currently have no good signal for this other than pillow errors which are not monitored closely.

Solution

A new elasticsearch_custom check (modeled on couchdb_custom, PR #25) that queries index settings and emits a per-index gauge elasticsearch.index.read_only_allow_delete = 1, tagged index:<name>, for each index that is blocked.

Nothing is emitted for healthy indices. I figured this would help keep the custom metric count lower since we only care about this signal when it's "on".

Testing

Plan to test manually on staging which will require a related commcare-cloud PR to get the elasticsearch_custom integration onto one of the elasticsearch machines.

@gherceg
gherceg marked this pull request as ready for review July 20, 2026 01:05
Emits elasticsearch.index.read_only_allow_delete=1 per index that has the
index.blocks.read_only_allow_delete block set, which Elasticsearch applies
when disk usage crosses the flood-stage watermark. The block must be cleared
manually, so this surfaces indices stuck rejecting writes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gherceg
gherceg force-pushed the gh/es-readonly-check branch from 35d8b9f to 9f8334c Compare July 20, 2026 01:09
@gherceg
gherceg requested review from AmitPhulera and millerdev July 20, 2026 01:09
@gherceg gherceg changed the title Alert when an Elasticsearch index is stuck read-only from flood stage Emit datadog metric when Elasticsearch index is set to read only/allow delete Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants