0

I know I can query index creation time with curl 'http://localhost:9200/_cat/indices?v&h=index,creation.date.string'.

Is there a similar query which I can check index update time (not creation time)? I need a one-line command to do the same for all indices ...

1 Answer 1

0

For datastreams you can use the following API call to collect the maximum timestamp metrics.

GET _data_stream/_stats

Response:

{
  "_shards": {
    "total": 468,
    "successful": 390,
    "failed": 0
  },
  "data_stream_count": 93,
  "backing_indices": 345,
  "total_store_size_bytes": 41258764754,
  "data_streams": [
    {
      "data_stream": "my-data-stream",
      "backing_indices": 3,
      "store_size_bytes": 20472,
      "maximum_timestamp": 1752188400000 <--- Time unit for milliseconds

    },

enter image description here

  • You can also use kibana UI:

enter image description here

As a workaround for regular indices, you can use sub-aggs with .jq

curl  -u username:password -s -X POST "https://localhost:9200/_all/_search?size=0" -H 'Content-Type: application/json' -d '{
  "aggs": {
    "indices": {
      "terms": { "field": "_index", "size": 1000 },
      "aggs": {
        "last_updated": { "max": { "field": "@timestamp" } }
      }
    }
  }
}' | jq -r '.aggregations.indices.buckets[] | "\(.key) \(.last_updated.value_as_string)"'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.