Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View Completed Elasticsearch Tasks

I am trying to run daily tasks using Elasticsearch's update by query API. I can find currently running tasks but need a way to view all tasks, including completed.

I've reviewed the ES docs for the Update By Query API:

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html#docs-update-by-query

And the Task API: https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html#tasks

Task API shows how to get the status of a currently running task with GET _tasks/[taskId], or all running tasks - GET _tasks. But I need to see a history of all tasks ran.

How do I see a list of all completed tasks?

like image 577
Travis Roberts Avatar asked Mar 04 '23 09:03

Travis Roberts


1 Answers

A bit late to the party, but you can check the tasks in the .tasks system index.

You can query this index, as any other regular index. For the updateByQuery task you can do:

curl -XPOST -sS "elastic:9200/.tasks/_search" -H 'Content-Type: application/json' -d '{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "completed": true
          }
        },
        {
          "term": {
            "task.action": "indices:data/write/update/byquery"
          }
        }
      ]
    }
  }
}'
like image 132
tpopov Avatar answered Mar 24 '23 23:03

tpopov