Skip to content

Monitoring & logging: Clean up & disk

Monitoring & logging commands for clean up & disk (tags: #cleanup #disk #backup).

Index
4 items

Grafana1

Grafana: Export a dashboard as JSON

Safe

Back up or version a dashboard. The uid is in the dashboard URL.

curl -s -H "Authorization: Bearer $GRAFANA_TOKEN" <grafana-url>/api/dashboards/uid/<dashboard-uid> | jq '.dashboard' > <dashboard-uid>.json
What each part does
  1. curl -sHTTP request, quiet
  2. -H "Authorization: Bearer $GRAFANA_TOKEN"authenticate with a service account token from an env var
  3. <grafana-url>/api/dashboards/uid/<dashboard-uid>the dashboard (UID is in the dashboard URL)
  4. | jq '.dashboard'keep the dashboard model, drop the meta block
  5. > <dashboard-uid>.jsonsave it to a file
  • #grafana
  • #backup

Also known as: dashboard json · dashboards as code

Elasticsearch3

Elasticsearch: List indices by size

Safe

Biggest indices first, with doc count and health.

curl -s "<es-url>/_cat/indices?v&s=store.size:desc" | head -20
What each part does
  1. curl -sHTTP request, quiet
  2. /_cat/indicesone line per index: health, status, docs, size
  3. ?vadd a header row
  4. &s=store.size:descsort by size, biggest first
  5. | head -20keep the header + top 19

Also known as: _cat/indices · index size

Elasticsearch: Clear read-only block after disk full

Caution

Re-enables writes once you've freed disk space below the flood-stage watermark.

curl -X PUT "<es-url>/_all/_settings" -H 'Content-Type: application/json' -d '{"index.blocks.read_only_allow_delete": null}'
What each part does
  1. curl -X PUTHTTP PUT: update settings
  2. "<es-url>/_all/_settings"the settings of every index
  3. -H 'Content-Type: application/json'tell ES the body is JSON
  4. -d '{"index.blocks.read_only_allow_delete": null}'body: reset the block ES set when disk hit the flood-stage watermark

My note Recent versions clear the block automatically once disk drops under the high watermark.

Also known as: FORBIDDEN/12/index read-only / allow delete (api) · flood stage disk watermark · read_only_allow_delete

Elasticsearch: Delete old indices

Destructive

Drop an index to free disk. Prefer ILM policies for routine retention.

curl -X DELETE "<es-url>/<index-name>"
What each part does
  1. curl -X DELETEHTTP DELETE
  2. "<es-url>/<index-name>"the index to delete for good; wildcards may be blocked by action.destructive_requires_name

My note Wildcard deletes are blocked by default (action.destructive_requires_name). Keep it that way.

Also known as: delete index · free disk elasticsearch

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…