【问题标题】:How to Curl Kibana Dashboard with GET Response to Find All Dashboard IDs and/or Dashboard Content如何使用 GET 响应 Curl Kibana 仪表板以查找所有仪表板 ID 和/或仪表板内容
【发布时间】:2021-04-15 06:55:18
【问题描述】:

因此,我正在尝试从我们的环境中自动抓取我们的内部 Kibana 仪表板,以收集信息。我浏览了以下链接,但 Elasticsearch 似乎并没有真正提供我在这里尝试做或完成的事情的好例子。我有几个限制:1. 命令必须在 BASH 中,2. 我不能使用任何编译器,例如 Python 和 Requests 和/或 Beautifulsoup 模块来获取信息并解析它。

这是我的困境: 我登录到 Kibana 仪表板:

一些 http://:5601/app/kibana#/dashboards?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-1h,mode:quick,到:现在))

如果我正确地进入环境,它将看起来像这样。

我要收集三个仪表板:

  1. API 响应
  2. 日志
  3. 通知

我使用的 curl 命令示例如下来抓取仪表板:

curl -s http://<IP_ADDRESS>:5601/app/kibana#/dashboard/API\ RESPONSES
curl -s http://<IP_ADDRESS>:5601/app/kibana#/dashboard/logs
curl -s http://<IP_ADDRESS>:5601/app/kibana#/dashboard/notifications

现在Elasticsearch Documentation 提到了仪表板 ID,除非我打开网页并在发送 GET 请求的特定元素上使用检查工具,否则我看不到它。我试图通过卷曲主仪表板页面来实现这一点:

curl -s http://<IP_ADDRESS>:5601/app/kibana#/dashboard/_search?pretty

我的输出将返回一个 HTML 输出,但它似乎没有改变,我无法在不知道仪表板 ID 的情况下正确获取仪表板。此外,我正在尝试查看哪些仪表板可用,并根据一个人在环境中设置的内容来抓取所有仪表板,因此这个过程是动态的很重要。我的最终目标是:

  1. 可用的仪表板 ID
  2. 按 ID 抓取仪表板

基本上我想卷曲这个输出以获得返回的 JSON。

任何想法将不胜感激。

【问题讨论】:

    标签: elasticsearch curl kibana


    【解决方案1】:

    显然,我卷曲了错误的位置。 我需要为 Kibana Index 卷曲 VIP 和端口 9200 以拉入可用的仪表板。

    rbarrett@cfg01:~$ curl -s http://<IP_ADDRESS>:9200/.kibana/dashboard/_search?pretty
    {
      "took" : 15,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : 2,
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : ".kibana",
            "_type" : "dashboard",
            "_id" : "logs",
            "_score" : 1.0,
            "_source" : {
              "description" : "",
              "hits" : 0,
              "kibanaSavedObjectMeta" : {
                "searchSourceJSON" : "{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}]}"
              },
              "optionsJSON" : "{\"darkTheme\":true}",
              "panelsJSON" : "[{\"col\":1,\"columns\":[\"Hostname\",\"Logger\",\"programname\",\"severity_label\",\"Payload\",\"environment_label\"],\"id\":\"search-logs\",\"panelIndex\":5,\"row\":13,\"size_x\":12,\"size_y\":12,\"sort\":[\"Timestamp\",\"desc\"],\"type\":\"search\"},{\"col\":1,\"id\":\"NUMBER-OF-LOG-MESSAGES-PER-SEVERITY\",\"panelIndex\":7,\"row\":9,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"},{\"col\":7,\"id\":\"TOP-10-PROGRAMS\",\"panelIndex\":9,\"row\":5,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"},{\"col\":1,\"id\":\"LOG-MESSAGES-OVER-TIME-PER-SOURCE\",\"panelIndex\":10,\"row\":1,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"},{\"col\":7,\"id\":\"TOP-10-HOSTS\",\"panelIndex\":11,\"row\":9,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"},{\"col\":1,\"id\":\"TOP-10-SOURCES\",\"panelIndex\":14,\"row\":5,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"},{\"col\":7,\"id\":\"LOG-MESSAGES-OVER-TIME-PER-SEVERITY\",\"panelIndex\":16,\"row\":1,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"}]",
              "timeFrom" : "now-1h",
              "timeRestore" : true,
              "timeTo" : "now",
              "title" : "Logs",
              "uiStateJSON" : "{\"P-10\":{\"vis\":{\"legendOpen\":true}},\"P-11\":{\"vis\":{\"colors\":{\"Count\":\"#629E51\"},\"legendOpen\":true}},\"P-12\":{\"spy\":{\"mode\":{\"fill\":false,\"name\":null}},\"vis\":{\"colors\":{\"Count\":\"#2F575E\"},\"legendOpen\":false}},\"P-14\":{\"vis\":{\"legendOpen\":true}},\"P-7\":{\"vis\":{\"legendOpen\":false}},\"P-9\":{\"vis\":{\"colors\":{\"Count\":\"#99440A\"},\"legendOpen\":true}}}",
              "version" : 1
            }
          },
          {
            "_index" : ".kibana",
            "_type" : "dashboard",
            "_id" : "notifications",
            "_score" : 1.0,
            "_source" : {
              "description" : "",
              "hits" : 0,
              "kibanaSavedObjectMeta" : {
                "searchSourceJSON" : "{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}]}"
              },
              "optionsJSON" : "{\"darkTheme\":true}",
              "panelsJSON" : "[{\"col\":1,\"columns\":[\"Logger\",\"publisher\",\"severity_label\",\"event_type\",\"old_state\",\"old_task_state\",\"state\",\"new_task_state\",\"environment_label\",\"display_name\"],\"id\":\"search-notifications\",\"panelIndex\":1,\"row\":14,\"size_x\":12,\"size_y\":11,\"sort\":[\"Timestamp\",\"desc\"],\"type\":\"search\"},{\"col\":1,\"id\":\"NOTIFICATIONS-OVER-TIME-PER-SOURCE\",\"panelIndex\":2,\"row\":1,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"},{\"col\":7,\"id\":\"NOTIFICATIONS-OVER-TIME-PER-SEVERITY\",\"panelIndex\":3,\"row\":1,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"},{\"col\":7,\"id\":\"EVENT-TYPE-BREAKDOWN\",\"panelIndex\":4,\"row\":5,\"size_x\":6,\"size_y\":5,\"type\":\"visualization\"},{\"col\":1,\"id\":\"SOURCE-BREAKDOWN\",\"panelIndex\":5,\"row\":5,\"size_x\":6,\"size_y\":5,\"type\":\"visualization\"},{\"col\":1,\"id\":\"HOST-BREAKDOWN\",\"panelIndex\":6,\"row\":10,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"},{\"col\":7,\"id\":\"NOTIFICATIONS-PER-SEVERITY\",\"panelIndex\":7,\"row\":10,\"size_x\":6,\"size_y\":4,\"type\":\"visualization\"}]",
              "timeFrom" : "now-1h",
              "timeRestore" : true,
              "timeTo" : "now",
              "title" : "Notifications",
              "uiStateJSON" : "{\"P-4\":{\"vis\":{\"legendOpen\":true}},\"P-7\":{\"vis\":{\"legendOpen\":false}}}",
              "version" : 1
            }
          }
        ]
      }
    }
    

    之后,我能够使用 JQ 提取现有 ID:

    【讨论】:

    • 您也可以使用 Kibana 的 APi 而不是 Elasticsearch API 来查询仪表板和可视化。
    猜你喜欢
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    • 2015-01-10
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    • 2016-05-17
    相关资源
    最近更新 更多