UGA Boxxx

つぶやきの延長のつもりで、知ったこと思ったこと書いてます

【Elasticsearch】Reindexの進捗が知りたい

Reindex実行後、Reindexが終わったのかどうかがわかないので進捗が知りたい

下のドキュメントによると_tasks/で確認することができる

www.elastic.co

基本的には_tasks/で実行中のタスク一覧を確認すればよさそう

{
    "nodes": {
        ...
        "bgQV-2YaTymKCzT4bI29dg": {
            "name": "elasticsearch-6ph9",
            "transport_address": "xx.xx.xx.xx:9300",
            "host": "xx.xx.xx.xx",
            "ip": "xx.xx.xx.xx:9300",
            "roles": [
                "data",
                "master"
            ],
            "attributes": {
                "xpack.installed": "true",
                "transform.node": "false"
            },
            "tasks": {
                "bgQV-2YaTymKCzT4bI29dg:15675836": {
                    "node": "bgQV-2YaTymKCzT4bI29dg",
                    "id": 15675836,
                    "type": "transport",
                    "action": "indices:data/write/reindex",
                    "start_time_in_millis": 1637207909753,
                    "running_time_in_nanos": 7402297917828,
                    "cancellable": true,
                    "headers": {}
                },
                ...
            }
        }
    }
}

一覧からReindexタスクがあれば完了していないことになる

詳細を知りたければidをみつけて、以下を実行する

_tasks/bgQV-2YaTymKCzT4bI29dg:15675836

{
    "completed": false,
    "task": {
        "node": "bgQV-2YaTymKCzT4bI29dg",
        "id": 15675836,
        "type": "transport",
        "action": "indices:data/write/reindex",
        "status": {
            "total": 11975115,
            "updated": 0,
            "created": 7742000,
            "deleted": 0,
            "batches": 7743,
            "version_conflicts": 0,
            "noops": 0,
            "retries": {
                "bulk": 0,
                "search": 0
            },
            "throttled_millis": 0,
            "requests_per_second": -1.0,
            "throttled_until_millis": 0
        },
        "description": "...",
        "start_time_in_millis": 1637207909753,
        "running_time_in_nanos": 7431142447875,
        "cancellable": true,
        "headers": {}
    }
}