where can I find ELK version in REST API?

Refresh

February 2019

Views

0 time

1

I would like to get ELK version through REST API or parse html.

I search in API documentation without finding anything

Re-edit: In python ... i'm not found better than

re.findall(r"version":"(\d\.\d\.\d)&quot", requests.get(my_elk).content.decode())[0]

3 answers

1

Elasticsearch gives JSON, not HTML. So, you could use jq

$ curl -s localhost:9200 | jq '.version.number'
6.6.0

In Python, please don't use re module... Use json module and actually parse that content

0

There's no HTML, but if you call GET / in Kibana's Console or curl -XGET http://localhost:9200/, the return will be:

{
  "name" : "instance-0000000039",
  "cluster_name" : "c2edd39f6fa24b0d8e5c34e8d1d19849",
  "cluster_uuid" : "VBkvp8OmTCaVuVvMioS3SA",
  "version" : {
    "number" : "6.6.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "a9861f4",
    "build_date" : "2019-01-24T11:27:09.439740Z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

So all you need to do is get version.number from the JSON response.

0

If you're already using the requests library, why not use the json method to parse the result?

requests.get(my_elk).json()["version"]["number"]