Skip to content

ElasticSearch Kibana API Documentation

Dennis Christilaw edited this page Nov 18, 2019 · 1 revision

DRAFT NOTICE

This document is in Draft and being developed, as long as this status is here, do not consider this document completed!! Use at your own risk!!

Purpose

This document will walk through several of the API's for the AWS ElasticSearch Serice that you can use to quickly check the status, health and other parts of the ElasticSearch Stack. This document will focus mainly on using the Kibana Tools (API Query Console) to view the information. You can use CURL and the section below will show you how to use these API commands via CURL.

Usage Information

Using CURL

If you plan to use CURL for querying ElastiSearch instead of the Kibana Tools Console, you will need to prepend all of the commands with:

curl -XGET "https://<elasticsearch_url>/"

Example:

If the document states that the API comand is:

GET _cat/shards

You will use the following CURL command:

curl -XGET "https://<elasticsearch_url>/_cat/shards"

Formatting Output (CURL/Kibana Tools)

ALL output from these commands are formatted in JSON format. When using the the Kibana Dev tools, the format will always show up in standard JSON format. However, with CURL, you will just get a JSON blob that is nor formatted. Use the following to format the output:

CURL formatting output to "pretty" JSON output

When you use CURL to query the stack, you will get back a JSON text block like:

{   "_nodes" : {     "total" : 2,     "successful" : 2,     "failed" : 0   },   "cluster_name" : "<scrubbed>:<scrubbed>",   "nodes" : {     "<scrubbed>" : {       "name" : "<scrubbed>",       "version" : "7.1.1",       "build_flavor" : "oss",       "build_type" : "tar",       "build_hash" : "7a013de",       "roles" : [ "master", "data", "ingest" ],       "jvm" : {         "pid" : 10854,         "bundled_jdk" : false,         "using_bundled_jdk" : null,         "start_time_in_millis" : 1573838022608,         "mem" : {           "heap_init_in_bytes" : 8589934592,           "heap_max_in_bytes" : 8572502016,           "non_heap_init_in_bytes" : 2555904,           "non_heap_max_in_bytes" : 0,           "direct_max_in_bytes" : 8572502016         },         "using_compressed_ordinary_object_pointers" : "true"       }     },     "<scrubbed>" : {       "name" : "<scrubbed>",       "version" : "7.1.1",       "build_flavor" : "oss",       "build_type" : "tar",       "build_hash" : "7a013de",       "roles" : [ "master", "data", "ingest" ],       "jvm" : {         "pid" : 11131,         "bundled_jdk" : false,         "using_bundled_jdk" : null,         "start_time_in_millis" : 1573838070142,         "mem" : {           "heap_init_in_bytes" : 8589934592,           "heap_max_in_bytes" : 8572502016,           "non_heap_init_in_bytes" : 2555904,           "non_heap_max_in_bytes" : 0,           "direct_max_in_bytes" : 8572502016         },         "using_compressed_ordinary_object_pointers" : "true"       }     }   } }

If you append the following to the end of your query, you will see the above output in a "pretty" readable JSON format:

?pretty

"Pretty" output:

{
  "_nodes" : {
    "total" : 2,
    "successful" : 2,
    "failed" : 0
  },
  "cluster_name" : "<scrubbed>:<scrubbed>",
  "nodes" : {
    "<scrubbed>" : {
      "name" : "<scrubbed>",
      "version" : "7.1.1",
      "build_flavor" : "oss",
      "build_type" : "tar",
      "build_hash" : "7a013de",
      "roles" : [ "master", "data", "ingest" ],
      "jvm" : {
        "pid" : 10854,
        "bundled_jdk" : false,
        "using_bundled_jdk" : null,
        "start_time_in_millis" : 1573838022608,
        "mem" : {
          "heap_init_in_bytes" : 8589934592,
          "heap_max_in_bytes" : 8572502016,
          "non_heap_init_in_bytes" : 2555904,
          "non_heap_max_in_bytes" : 0,
          "direct_max_in_bytes" : 8572502016
        },
        "using_compressed_ordinary_object_pointers" : "true"
      }
    },
    "<scrubbed>" : {
      "name" : "<scrubbed>",
      "version" : "7.1.1",
      "build_flavor" : "oss",
      "build_type" : "tar",
      "build_hash" : "7a013de",
      "roles" : [ "master", "data", "ingest" ],
      "jvm" : {
        "pid" : 11131,
        "bundled_jdk" : false,
        "using_bundled_jdk" : null,
        "start_time_in_millis" : 1573838070142,
        "mem" : {
          "heap_init_in_bytes" : 8589934592,
          "heap_max_in_bytes" : 8572502016,
          "non_heap_init_in_bytes" : 2555904,
          "non_heap_max_in_bytes" : 0,
          "direct_max_in_bytes" : 8572502016
        },
        "using_compressed_ordinary_object_pointers" : "true"
      }
    }
  }
}

CURL/Kibana Table Results

For BOTH of the tools, when you get results back in Table format, it would be helpful to get the table headers. By, default, these are not returned with the results. In order to get the data, you need to append the following to the end of your queries:

?v

Example:

GET _cat/health

1574095817 16:50:17 <scrubbed>:<scrubbed> green 2 2 true 42 21 0 0 0 0 - 100.0%

Add the "?v" to get:

GET _cat/health?v

epoch      timestamp cluster                            status node.total node.data discovered_master shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1574095899 16:51:39  <scrubbed>:<scrubbed> green           2         2              true     42  21    0    0        0             0                  -                100.0%