当前位置:  开发笔记 > 数据库 > 正文

从ElasticSearch在Kibana中显示不同的文档类型

如何解决《从ElasticSearch在Kibana中显示不同的文档类型》经验,为你挑选了1个好方法。

我正在尝试设置Kibana仪表板.此仪表板正在访问ElasticSearch索引.我的索引具有以下映射:

"myindex": {
  "mappings": {
    "animals": {
      "properties": {
        "@timestamp": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "@version": {
          "type": "string"
        },
        "Class": {
          "type": "string"
        },
        "Order": {
          "type": "string"
        },
        "Family": {
          "type": "string"
        },
        "Genus": {
          "type": "string"
        },
        "Species": {
          "type": "string"
        }
      }
    },
    "elements" : {
      "properties": {
        "@timestamp": {
          "type": "date",
          "format": "dateOptionalTime"
        },
        "@version": {
          "type": "string"
        },
        "Symbol": {
          "type": "string"
        },
        "Name": {
          "type": "string"
        },
        "Group": {
          "type": "string"
        },
        "Period": {
          "type": "string"
        }             
      }
    }
  }
}

正如映射所示,我的索引有两种不同类型的信息.我的挑战是,我不知道如何设置我的kibana仪表板只列出每种类型的信息.我已经确认我的elasticsearch实例中的数据是正确的数据.

在我的仪表板中,我试图显示两个表格.一个表格将显示与"动物"相关的所有文件.另一个表将显示与"元素"相关的所有文档.不幸的是,我无法弄清楚如何将表格的结果集中到特定类型.我基本上试图弄清楚如何为特定面板设置查询或过滤器(不确定kibana世界中两者之间的差异).目前,我的仪表板如下所示:

{
  "title": "Research",
  "services": {
    "query": {
      "list": {
        "0": {
          "query": "*",
          "alias": "",
          "color": "#7EB26D",
          "id": 0,
          "pin": false,
          "type": "lucene"
        }
      },
      "ids": [
        0
      ]
    },
    "filter": {
      "list": {
        "0": {
          "type": "time",
          "field": "@timestamp",
          "from": "now-{{ARGS.from || '24h'}}",
          "to": "now",
          "mandate": "must",
          "active": true,
          "alias": "",
          "id": 0
        }
      },
      "ids": [
        0
      ]
    }
  },
  "rows": [
    {
      "title": "Animals",
      "height": "350px",
      "editable": true,
      "collapse": false,
      "collapsable": true,
      "panels": [
        {
          "title": "Animals",
          "error": false,
          "span": 12,
          "editable": true,
          "group": [
            "default"
          ],
          "type": "table",
          "size": 100,
          "pages": 5,
          "offset": 0,
          "sort": [
            "@timestamp",
            "desc"
          ],
          "style": {
            "font-size": "9pt"
          },
          "overflow": "min-height",
          "fields": [
            "Class",
            "Order",
            "Family",
            "Genus",
            "Species"
          ],
          "localTime": true,
          "timeField": "@timestamp",
          "highlight": [],
          "sortable": true,
          "header": true,
          "paging": true,
          "spyable": true,
          "queries": {
            "mode": "all",
            "ids": [
              0
            ]
          },
          "field_list": true,
          "status": "Stable",
          "trimFactor": 300,
          "normTimes": true
        }
      ],
      "notice": false
    },
    {
      "title": "",
      "height": "350px",
      "editable": true,
      "collapse": false,
      "collapsable": true,
      "panels": [
        {
          "title": "Elements",
          "error": false,
          "span": 12,
          "editable": true,
          "group": [
            "default"
          ],
          "type": "table",
          "size": 100,
          "pages": 5,
          "offset": 0,
          "sort": [
            "@timestamp",
            "desc"
          ],
          "style": {
            "font-size": "9pt"
          },
          "overflow": "min-height",
          "fields": [
            "Symbol",
            "Name",
            "Group",
            "Period"
          ],
          "localTime": true,
          "timeField": "@timestamp",
          "highlight": [],
          "sortable": true,
          "header": true,
          "paging": true,
          "spyable": true,
          "queries": {
            "mode": "all",
            "ids": [
              0
            ]
          },
          "field_list": true,
          "trimFactor": 300,
          "normTimes": true
        }
      ],
      "notice": false
    }    
  ],
  "editable": true,
  "failover": false,
  "index": {
    "interval": "none",
    "default": "myindex"
  },
  "style": "dark",
  "panel_hints": true,
  "pulldowns": [
    {
      "type": "query",
      "collapse": false,
      "notice": false,
      "query": "*",
      "pinned": true,
      "history": [],
      "remember": 10
    },
    {
      "type": "filtering",
      "collapse": true,
      "notice": false
    }
  ],
  "loader": {
    "save_gist": false,
    "save_elasticsearch": true,
    "save_local": true,
    "save_default": true,
    "save_temp": true,
    "save_temp_ttl_enable": true,
    "save_temp_ttl": "30d",
    "load_gist": true,
    "load_elasticsearch": true,
    "load_elasticsearch_size": 20,
    "load_local": true,
    "hide": false
  },
  "refresh": "30s"
}

有人能告诉我如何在Kibana中显示两种不同类型的文件吗?我在表格面板上看到了一个查询对象.但是,我不知道如何使用它.

非常感谢



1> 小智..:

您可以使用_type字段将结果缩小到特定的弹性搜索类型(例如动物).

因此,当您为表定义查询(或过滤器)时,只需确保指定相关_type(即_type: animals)

推荐阅读
ifx0448363
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有