【问题标题】:multiple words visualization in a field字段中的多个单词可视化
【发布时间】:2016-03-08 03:58:23
【问题描述】:

我正在尝试以某种方式可视化 kibana,我可以绘制图表,其中哪些客户添加了一些东西到购物车 VS 哪些客户从购物车中删除了一些东西。我正在从错误日志中获取这些数据。

这里是

的数据的 json 示例
{
  "_index": "filebeat-2016.03.08",
  "_type": "php-error",
  "_id": "AVNUOptErt39_iTb3Riw",
  "_score": null,
  "_source": {
    "message": "[Mon Mar 07 20:15:35.571673 2016] [:error] [pid 13829] [client 24.220.167.100:56888] {\"email\":null,\"name\":\" \",\"message\":\"remove from cart\",\"remaining_cart_items\":\"{\\\\\"total\\\\\":\\\\\"1 item(s) - $16.26\\\\\"}\"}, referer: https://exsite.com/",
    "@version": "1",
    "@timestamp": "2016-03-08T03:15:36.786Z",
    "beat": {
      "hostname": "ip-110-0-0-154",
      "name": "ip-110-0-0-154"
    },
    "count": 1,
    "fields": null,
    "input_type": "log",
    "source": "/var/log/apache2/error.log",
    "type": "log_format_error",
    "host": "ip-10-0-0-154"
  },
  "fields": {
    "@timestamp": [
      1457406936786
    ]
  },
  "sort": [
    1457406936786
  ]
}

您可以看到有一个“从购物车中删除”,我可以使用它在 dicover 中进行搜索,然后从中创建视觉效果。这是添加到购物车的数据

{
  "_index": "filebeat-2016.03.08",
  "_type": "php-error",
  "_id": "AVNUOhKOrt39_iTb3Riv",
  "_score": null,
  "_source": {
    "message": "[Mon Mar 07 20:14:56.377612 2016] [:error] [pid 13839] [client 24.220.167.100:56882] {\"email\":null,\"name\":\" \",\"message\":\"Added to cart\",\"add_to_cart\":\"{\\\\\"success\\\\\":\\\\\"Success: You have added <a href=\\\\\\\\\\\\\"https:\\\\\\\\\\\\/\\\\\\\\\\\\/site.com\\\\\\\\\\\\/whitesting\\\\\\\\\\\\\">My Test<\\\\\\\\\\\\/a> to your <a href=\\\\\\\\\\\\\"https:\\\\\\\\\\\\/\\\\\\\\\\\\/site.com\\\\\\\\\\\\/index.php?route=checkout\\\\\\\\\\\\/cart\\\\\\\\\\\\\">shopping cart<\\\\\\\\\\\\/a>!\\\\\",\\\\\"total\\\\\":\\\\\"2 item(s) - $32.51\\\\\"}\"}, referer: https://exsite.com/dtesting",
    "@version": "1",
    "@timestamp": "2016-03-08T03:15:01.767Z",
    "beat": {
      "hostname": "ip-110-0-0-154",
      "name": "ip-110-0-0-154"
    },
    "count": 1,
    "fields": null,
    "input_type": "log",
    "source": "/var/log/apache2/error.log",
    "type": "log_format_error",
    "host": "ip-10-0-0-154"
  },
  "fields": {
    "@timestamp": [
      1457406901767
    ]
  } 
}

那么现在我如何绘制这些数据,我可以看到有多少删除计数以及有多少已添加到购物车。

我在发现中的查询是

"remove from cart" OR "Added to cart"

谢谢

【问题讨论】:

  • 为什么不使用 Logstash 解析 message 字段以便将这些 JSON 字段放入您的事件中?查询它们并在可视化中使用它们会更容易。

标签: elasticsearch logstash kibana kibana-4


【解决方案1】:

理想情况下,您可以使用类似 logstash 的东西来解析日志行,因此不必像您一样求助于查询,但如果您必须始终使用过滤器聚合。

当您构建可视化(假设您正在使用条形图)时,您将创建以下聚合来可视化这些数据:

  1. 统计每个存储桶中文档的指标(默认情况下存在)
  2. x 轴的存储桶,它是时间字段上的日期直方图
  3. 使用过滤器聚合拆分条形的存储桶。然后给这个 agg 两个过滤器,一个带有“从购物车中删除”,另一个带有“添加到购物车”

【讨论】:

    猜你喜欢
    • 2017-10-15
    • 1970-01-01
    • 1970-01-01
    • 2019-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-11
    相关资源
    最近更新 更多