ElasticSearch - acehippo/slowmotion GitHub Wiki

Monitoring

https://www.elastic.co/guide/en/elasticsearch/guide/current/cluster-admin.html

Monitoring through Kibana

  • A variety of APIs let you manage and monitor the cluster itself, rather than interact with the data stored within the cluster.
  • a single HTTP API call is often simpler than pushing new configurations to hundreds of physical machines.

Marvel

  • Elasticsearch monitoring through Kibana.
  • queries and aggregates the metrics so you can visualize your cluster’s behavior over time, which makes it easy to spot trends.
  • cluster’s health and performance in real time as well as analyze past cluster, index, and node metrics.

APIs

  • GET _cluster/health
  • options : ?level={indices or shards}
$ curl -XGET 'http://localhost:9200/_cluster/health'
{
  "cluster_name": "elasticsearch",
  "status": "yellow",
  "timed_out": false,
  "number_of_nodes": 1,
  "number_of_data_nodes": 1,
  "active_primary_shards": 10,
  "active_shards": 10,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 10,
  "delayed_unassigned_shards": 0,
  "number_of_pending_tasks": 0,
  "number_of_in_flight_fetch": 0,
  "task_max_waiting_in_queue_millis": 0,
  "active_shards_percent_as_number": 50
}
  • GET _nodes/stats
$ curl -XGET 'http://localhost:9200/_nodes/stats'
{
  "cluster_name": "elasticsearch",
  "nodes": {
    "-B_sYD-MTmCJ8vUrd2bHeg": {
      "timestamp": 1456293171093,
      "name": "Behemoth",
      "transport_address": "172.17.0.2:9300",
      "host": "172.17.0.2",
      "ip": [
        "172.17.0.2:9300",
        "NONE"
      ],
      "indices": {
        "docs": {
          "count": 176009,
          "deleted": 257
        },
        "store": {
          "size_in_bytes": 44420211,
          "throttle_time_in_millis": 0
        },
        "indexing": {
          "index_total": 263132,
          "index_time_in_millis": 80478,
          "index_current": 0,
          "index_failed": 0,
          "delete_total": 0,
          "delete_time_in_millis": 0,
          "delete_current": 0,
          "noop_update_total": 0,
          "is_throttled": false,
          "throttle_time_in_millis": 0
        },
        "get": {
          "total": 181,
          "time_in_millis": 27,
          "exists_total": 166,
          "exists_time_in_millis": 26,
          "missing_total": 15,
          "missing_time_in_millis": 1,
          "current": 0
        },
        "search": {
          "open_contexts": 0,
          "query_total": 35327,
          "query_time_in_millis": 5784,
          "query_current": 0,
          "fetch_total": 34020,
          "fetch_time_in_millis": 4111,
          "fetch_current": 0,
          "scroll_total": 0,
          "scroll_time_in_millis": 0,
          "scroll_current": 0
        },
        ...
      }
    }
  }
}
  • GET _cluster/stats
$ curl -XGET 'http://localhost:9200/_cluster/stats'
{
  "timestamp": 1456363018718,
  "cluster_name": "elasticsearch",
  "status": "yellow",
  "indices": {
    "count": 7,
    "shards": {
      "total": 11,
      "primaries": 11,
      "replication": 0,
      "index": {
        "shards": {
          "min": 1,
          "max": 5,
          "avg": 1.5714285714285714
        },
        "primaries": {
          "min": 1,
          "max": 5,
          "avg": 1.5714285714285714
        },
        "replication": {
          "min": 0,
          "max": 0,
          "avg": 0
        }
      }
    },
    "docs": {
      "count": 260018,
      "deleted": 279
    },
    "store": {
      "size_in_bytes": 67188187,
      "throttle_time_in_millis": 0
    },
    "fielddata": {
      "memory_size_in_bytes": 2472,
      "evictions": 0
    },
    "query_cache": {
      "memory_size_in_bytes": 521824,
      "total_count": 7806490,
      "hit_count": 353661,
      "miss_count": 7452829,
      "cache_size": 1016,
      "cache_count": 32275,
      "evictions": 31259
    },
    "completion": {
      "size_in_bytes": 0
    },
    "segments": {
      "count": 27,
      "memory_in_bytes": 771155,
      "terms_memory_in_bytes": 667855,
      "stored_fields_memory_in_bytes": 16232,
      "term_vectors_memory_in_bytes": 0,
      "norms_memory_in_bytes": 2368,
      "doc_values_memory_in_bytes": 84700,
      "index_writer_memory_in_bytes": 0,
      "index_writer_max_memory_in_bytes": 108403916,
      "version_map_memory_in_bytes": 0,
      "fixed_bit_set_memory_in_bytes": 0
    },
    "percolate": {
      "total": 0,
      "time_in_millis": 0,
      "current": 0,
      "memory_size_in_bytes": -1,
      "memory_size": "-1b",
      "queries": 0
    }
  },
  "nodes": {
    "count": {
      "total": 1,
      "master_only": 0,
      "data_only": 0,
      "master_data": 1,
      "client": 0
    },
    "versions": [
      "2.2.0"
    ],
    "os": {
      "available_processors": 8,
      "allocated_processors": 8,
      "mem": {
        "total_in_bytes": 0
      },
      "names": [
        {
          "name": "Linux",
          "count": 1
        }
      ]
    },
    "process": {
      "cpu": {
        "percent": 0
      },
      "open_file_descriptors": {
        "min": 296,
        "max": 296,
        "avg": 296
      }
    },
    "jvm": {
      "max_uptime_in_millis": 152990308,
      "versions": [
        {
          "version": "1.8.0_72-internal",
          "vm_name": "OpenJDK 64-Bit Server VM",
          "vm_version": "25.72-b15",
          "vm_vendor": "Oracle Corporation",
          "count": 1
        }
      ],
      "mem": {
        "heap_used_in_bytes": 199157304,
        "heap_max_in_bytes": 1037959168
      },
      "threads": 115
    },
    "fs": {
      "total_in_bytes": 109025763328,
      "free_in_bytes": 57844142080,
      "available_in_bytes": 52282286080,
      "spins": "true"
    },
    "plugins": [
      {
        "name": "license",
        "version": "2.2.0",
        "description": "Internal Elasticsearch Licensing Plugin",
        "jvm": true,
        "classname": "org.elasticsearch.license.plugin.LicensePlugin",
        "isolated": false,
        "site": false
      },
      {
        "name": "marvel-agent",
        "version": "2.2.0",
        "description": "Elasticsearch Marvel Agent",
        "jvm": true,
        "classname": "org.elasticsearch.marvel.MarvelPlugin",
        "isolated": false,
        "site": false
      }
    ]
  }
}
  • GET my_index/_stats
  • GET _all/_stats
  • GET _cluster/pending_tasks
{
   "tasks": [
      {
         "insert_order": 101,
         "priority": "URGENT",
         "source": "create-index [foo_9], cause [api]",
         "time_in_queue_millis": 86,
         "time_in_queue": "86ms"
      },
      {
         "insert_order": 46,
         "priority": "HIGH",
         "source": "shard-started ([foo_2][1], node[tMTocMvQQgGCkj7QDHl3OA], [P],
         s[INITIALIZING]), reason [after recovery from gateway]",
         "time_in_queue_millis": 842,
         "time_in_queue": "842ms"
      },
      {
         "insert_order": 45,
         "priority": "HIGH",
         "source": "shard-started ([foo_2][0], node[tMTocMvQQgGCkj7QDHl3OA], [P],
         s[INITIALIZING]), reason [after recovery from gateway]",
         "time_in_queue_millis": 858,
         "time_in_queue": "858ms"
      }
  ]
}
  • GET /_cat/health
  • GET /_cat/nodes
$ curl -XGET 'http://localhost:9200/_cat/health?v'
epoch      timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent 
1456922749 12:45:49  es_test yellow          1         1     12  12    0    0       12             0                  -                 50.0%

$ curl -XGET 'http://localhost:9200/_cat/nodes?v'
host       ip         heap.percent ram.percent load node.role master name  
172.17.0.2 172.17.0.2           13          20 0.05 d         *      Milan

$ curl -XGET 'localhost:9200/_cat/nodes?v&h=ip,port,heapPercent,heapMax'
ip         port heapPercent heapMax 
172.17.0.2 9300          11 989.8mb
  • PUT /_cluster/settings
{
    "persistent" : {
        "discovery.zen.minimum_master_nodes" : 2 
    },
    "transient" : {
        "indices.store.throttle.max_bytes_per_sec" : "50mb" 
    }
}
* Disable/Enable shard allocation
{
    "transient" : {
        "cluster.routing.allocation.enable" : "none"
    }
}

{
    "transient" : {
        "cluster.routing.allocation.enable" : "all"
    }
}
  • PUT _snapshot/my_backup
{
    "type": "fs",
    "settings": {
        "location": "/mount/backups/my_backup",
        "max_snapshot_bytes_per_sec" : "50mb", 
        "max_restore_bytes_per_sec" : "50mb"
    }
}