【问题标题】:where can I find ELK version in REST API?我在哪里可以找到 REST API 中的 ELK 版本?
【发布时间】:2019-02-12 10:33:02
【问题描述】:

我想通过 REST API 或者解析 html 获取 ELK 版本。

我在 API 文档中搜索,但没有找到任何东西

重新编辑: 在 python 中......我没有发现比

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

【问题讨论】:

    标签: python rest elastic-stack


    【解决方案1】:

    Elasticsearch 提供 JSON,而不是 HTML。所以,你可以使用jq

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

    在 Python 中,请不要使用 re 模块...使用 json 模块并实际解析该内容

    【讨论】:

      【解决方案2】:

      没有 HTML,但如果您在 Kibana 的控制台中调用 GET /curl -XGET http://localhost:9200/,返回将是:

      {
        "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"
      }
      

      所以您需要做的就是从 JSON 响应中获取 version.number

      【讨论】:

        【解决方案3】:

        如果您已经在使用requests 库,为什么不使用json 方法来解析结果?

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

        【讨论】:

          猜你喜欢
          • 2022-08-09
          • 2016-09-28
          • 2021-04-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-12-18
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多