Easysearch 对接 kibanba 创建 Dashboard
Easysearch 目前是国产化替代 Elasticsearch 的最优解决方案无论是全文搜索、聚合查询还是关键字查询使用方式都和 Elasticsearch 完全一致因此替换后不需要额外的学习成本只要有过使用 Elasticsearch 的经验就可以快速上手。目前 Easysearch 有两种可视化界面一种是 Easysearch 内置的 UI 界面另一种是 INFINI Console 组件。其中内置的 UI 界面仅支持对当前集群的内容进行操作Console 组件则可以实现多集群管控功能我后续会出专题专门介绍这两者的使用方式与具体功能。目前无论是使用 Easysearch 内置的 UI 界面还是使用 INFINI Console 组件都无法按照自身需求创建 Dashboard因此本文主要介绍如何使用 Kibana 对接 Easysearch并在 Kibana 上为存储在 Easysearch 中的数据创建 Dashboard 仪表盘。使用过kibana的人都知道kibana和Elasticsearch之间存在严格的版本绑定关系Elasticsearch用哪个版本kibana也必须下载对应版本才能正常使用。而且Elasticsearch的主版本号为7.x、8.x或9.x而Easysearch的主版本号为1.x、2.x因此kibana无法直接对接Easysearch使用需要我们进行一些特定配置才能正常运行。一、环境信息产品版本地址Easysearch2.2.0192.168.31.20:9200kibana7.10.2192.168.31.20:5601二、前置条件kibana 的版本选择 Easysearch 支持的版本查看方式如下Easysearch 内置 UI 界面左下角 About点开 versionkibana 要下在 OSS 类型的下载地址如下https://www.elastic.co/downloads/past-releases?productkibanaossproductkibana-oss注意Kibana 一定要选择 OSS 类型的三、部署 kibana3.1 Easysearch 配置文件修改# 开启 ES API 兼容模式 elasticsearch.api_compatibility: true # 伪装成 ES 7.10.2 版本 elasticsearch.api_compatibility_version: 7.10.23.2 Easysearch 开启了 SSL 认证模式的 kibana 配置创建安装目录解压 kibana 安装包#创建 kibana 安装目录 mkdir /data/kibana tar -zxvf kibana-oss-7.10.2-linux-x86_64.tar.gz -C /data/kibana修改配置文件vim kibana.yml #kibana 端口 server.port: 5601 #kibana 访问地址 server.host: 192.168.31.20 #Easysearch 集群地址 elasticsearch.hosts: [https://192.168.31.20:9200] #用户名、密码 elasticsearch.username: admin elasticsearch.password: your-password #ca.crt 证书路径如果 Easysearch 和 kibana 是不同节点的话把 Easysearch 的 ca.crt 文件拷贝到 kibana 的 config/certs 路径下 elasticsearch.ssl.certificateAuthorities: [/path/to/your/ca.crt] # 只验证证书可信度不验证主机名/IP是否匹配 elasticsearch.ssl.verificationMode: certificate3.3 Easysearch 未开启 SSL 认证模式的 kibana 配置禁用证书验证server.port: 5601 server.host: 192.168.31.20 elasticsearch.hosts: [https://192.168.31.20:9200] elasticsearch.username: admin elasticsearch.password: your-password #禁用 SSL 认证 elasticsearch.ssl.verificationMode: none3.4 启动 kibana#前台启动 ./kibana # 后台运行日志输出到文件 nohup /bin/kibana kibana.log 21 3.5 浏览器访问https://ip:5601输入用户名、密码登录进入 dev tools 尝试查看集群信息到这里 Kibana 就已经部署完成了并且已经成功连接到了 Easysearch 集群后面我们就可以进行 Dashboard 的创建了四、测试数据准备我们先创建 一个测试索引然后写入数据用于创建 Dashboard 界面PUT /ecommerce_orders { settings: { number_of_shards: 1, number_of_replicas: 0 }, mappings: { properties: { order_id: { type: keyword }, customer_name: { type: keyword }, product_name: { type: text, fields: { keyword: { type: keyword } } }, category: { type: keyword }, price: { type: float }, quantity: { type: integer }, amount: { type: float }, order_date: { type: date, format: yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis }, status: { type: keyword }, region: { type: keyword }, payment_method: { type: keyword } } } }批量插入测试数据POST /ecommerce_orders/_bulk {index:{_id:1}} {order_id:ORD2026001,customer_name:张三,product_name:iPhone 16 Pro,category:电子产品,price:8999.00,quantity:1,amount:8999.00,order_date:2026-06-01 10:30:00,status:completed,region:华东,payment_method:支付宝} {index:{_id:2}} {order_id:ORD2026002,customer_name:李四,product_name:Nike 运动鞋,category:服装鞋帽,price:699.00,quantity:2,amount:1398.00,order_date:2026-06-01 14:20:00,status:completed,region:华北,payment_method:微信支付} {index:{_id:3}} {order_id:ORD2026003,customer_name:王五,product_name:Sony WH-1000XM5,category:电子产品,price:2499.00,quantity:1,amount:2499.00,order_date:2026-06-02 09:15:00,status:shipped,region:华南,payment_method:信用卡} {index:{_id:4}} {order_id:ORD2026004,customer_name:赵六,product_name:有机大米 5kg,category:食品生鲜,price:89.00,quantity:3,amount:267.00,order_date:2026-06-02 16:45:00,status:completed,region:西南,payment_method:支付宝} {index:{_id:5}} {order_id:ORD2026005,customer_name:孙七,product_name:Dyson 吸尘器,category:家居家电,price:3299.00,quantity:1,amount:3299.00,order_date:2026-06-03 11:00:00,status:pending,region:华东,payment_method:微信支付} {index:{_id:6}} {order_id:ORD2026006,customer_name:周八,product_name:Adidas T恤,category:服装鞋帽,price:199.00,quantity:4,amount:796.00,order_date:2026-06-03 13:30:00,status:completed,region:华北,payment_method:支付宝} {index:{_id:7}} {order_id:ORD2026007,customer_name:吴九,product_name:MacBook Pro 16,category:电子产品,price:19999.00,quantity:1,amount:19999.00,order_date:2026-06-04 10:00:00,status:completed,region:华南,payment_method:信用卡} {index:{_id:8}} {order_id:ORD2026008,customer_name:郑十,product_name:新鲜草莓 2kg,category:食品生鲜,price:128.00,quantity:2,amount:256.00,order_date:2026-06-04 15:20:00,status:cancelled,region:华东,payment_method:微信支付} {index:{_id:9}} {order_id:ORD2026009,customer_name:钱十一,product_name:小米空气净化器,category:家居家电,price:899.00,quantity:1,amount:899.00,order_date:2026-06-05 09:45:00,status:shipped,region:西南,payment_method:支付宝} {index:{_id:10}} {order_id:ORD2026010,customer_name:陈十二,product_name:优衣库羽绒服,category:服装鞋帽,price:599.00,quantity:1,amount:599.00,order_date:2026-06-05 11:30:00,status:completed,region:华北,payment_method:微信支付} {index:{_id:11}} {order_id:ORD2026011,customer_name:刘十三,product_name:iPad Air 6,category:电子产品,price:4799.00,quantity:1,amount:4799.00,order_date:2026-06-06 14:00:00,status:completed,region:华东,payment_method:信用卡} {index:{_id:12}} {order_id:ORD2026012,customer_name:黄十四,product_name:金龙鱼食用油,category:食品生鲜,price:79.00,quantity:2,amount:158.00,order_date:2026-06-06 16:15:00,status:completed,region:华南,payment_method:支付宝} {index:{_id:13}} {order_id:ORD2026013,customer_name:林十五,product_name:海尔冰箱,category:家居家电,price:4599.00,quantity:1,amount:4599.00,order_date:2026-06-07 10:30:00,status:pending,region:西南,payment_method:微信支付} {index:{_id:14}} {order_id:ORD2026014,customer_name:杨十六,product_name:Nike 篮球鞋,category:服装鞋帽,price:1299.00,quantity:1,amount:1299.00,order_date:2026-06-07 13:00:00,status:shipped,region:华东,payment_method:支付宝} {index:{_id:15}} {order_id:ORD2026015,customer_name:朱十七,product_name:华为 Mate 70,category:电子产品,price:6999.00,quantity:1,amount:6999.00,order_date:2026-06-08 09:00:00,status:completed,region:华北,payment_method:微信支付} {index:{_id:16}} {order_id:ORD2026016,customer_name:秦十八,product_name:进口牛排 1kg,category:食品生鲜,price:268.00,quantity:2,amount:536.00,order_date:2026-06-08 11:45:00,status:completed,region:华南,payment_method:信用卡} {index:{_id:17}} {order_id:ORD2026017,customer_name:尤十九,product_name:美的空调,category:家居家电,price:3699.00,quantity:1,amount:3699.00,order_date:2026-06-09 10:15:00,status:completed,region:西南,payment_method:支付宝} {index:{_id:18}} {order_id:ORD2026018,customer_name:许二十,product_name:Zara 连衣裙,category:服装鞋帽,price:399.00,quantity:2,amount:798.00,order_date:2026-06-09 14:30:00,status:cancelled,region:华东,payment_method:微信支付} {index:{_id:19}} {order_id:ORD2026019,customer_name:何二一,product_name:AirPods Pro 3,category:电子产品,price:1899.00,quantity:1,amount:1899.00,order_date:2026-06-10 09:30:00,status:completed,region:华北,payment_method:支付宝} {index:{_id:20}} {order_id:ORD2026020,customer_name:吕二二,product_name:三只松鼠坚果礼盒,category:食品生鲜,price:168.00,quantity:3,amount:504.00,order_date:2026-06-10 15:00:00,status:shipped,region:华南,payment_method:微信支付}验证数据GET /ecommerce_orders/_count GET /ecommerce_orders/_search { size: 5, sort: [{ order_date: desc }] }五、Kibana Dashboard 可视化操作方案前置条件确认 Kibana 已正常连接 EasySearch左侧菜单可正常打开。5.1 创建 Index Pattern索引模式点击 Kibana 左侧菜单 →Management管理→Index Patterns索引模式点击Create index pattern创建索引模式在Index pattern name输入框中填写ecommerce_orders点击Next step在Time field下拉框中选择order_date点击Create index pattern创建成功后Kibana 会显示该索引的字段列表确认amount、category、status等字段已识别。5.2 各品类销售额柱状图Vertical Bar选择图表类型Vertical Bar垂直柱状图选择数据源选择刚才创建的ecommerce_orders索引模式在右侧配置面板Metrics指标→Y-AxisAggregation聚合SumField字段选择amountCustom Label自定义标签输入销售额Buckets桶→X-AxisAggregation聚合TermsField字段选择category.keywordSize数量10Order by排序Metric: Sum of amount按销售额降序Custom Label自定义标签输入商品品类点击上方▶ Update更新按钮预览图表点击左上角Save保存Title 填写各品类销售额统计点击Save确认5.3 订单状态分布饼图Pie再次点击Visualize→Create new visualization选择图表类型Pie饼图选择数据源ecommerce_orders右侧配置MetricsAggregationCountCustom Label订单数量Buckets→Split Slices切分切片AggregationTermsField选择status.keywordSize10Custom Label订单状态点击▶ Update预览点击SaveTitle 填写订单状态分布保存5.4 日订单趋势折线图LineVisualize→Create new visualization选择图表类型Line折线图选择数据源ecommerce_orders右侧配置Metrics→Y-AxisAggregationCountCustom Label订单数Buckets→X-AxisAggregationDate HistogramField选择order_dateInterval间隔选择Daily1dCustom Label日期点击▶ Update预览点击SaveTitle 填写日订单趋势保存5.5 区域销售数据表格Data TableVisualize→Create new visualization选择图表类型Data Table数据表格选择数据源ecommerce_orders右侧配置MetricsAggregationSumFieldamountCustom Label总销售额Buckets→Split Rows拆分行AggregationTermsFieldregion.keywordSize10Order byMetric: Sum of amountCustom Label区域点击▶ Update预览点击SaveTitle 填写区域销售统计表保存5.6 支付方式占比Horizontal BarVisualize→Create new visualization选择图表类型Horizontal Bar水平条形图选择数据源ecommerce_orders右侧配置Metrics→Y-Axis实际上是水平方向的长度AggregationCountCustom Label支付笔数Buckets→X-AxisAggregationTermsFieldpayment_method.keywordSize10Custom Label支付方式点击▶ Update预览点击SaveTitle 填写支付方式占比保存5.7 组装 Dashboard仪表盘点击 Kibana 左侧菜单 →Dashboard仪表盘点击Create new dashboard创建新仪表盘点击上方Add添加按钮在弹出的面板中依次点击刚才保存的 5 个可视化图表各品类销售额统计订单状态分布日订单趋势区域销售统计表支付方式占比每个图表添加后可以通过拖拽调整位置和大小将日订单趋势放在顶部宽度拉满占一整行将各品类销售额统计和订单状态分布放在第二行左右并排将区域销售统计表和支付方式占比放在第三行左右并排点击上方Save按钮Title 填写电商订单分析看板勾选Store time with dashboard存储时间范围点击Save确认

相关新闻