Kibana可视化线性图表,其中x是时间,Y是我的领域

时间:2016-02-25 16:34:26

标签: elasticsearch logstash kibana

我的问题是我不知道如何按字段在Kibana 4.4.1中创建可视化。我已经将日志编入索引。我按路径名搜索此日志,每个日志都有我需要的字段。我的字段已命名为EACH.AlgorithmEACH.TotalCount。我想创建一个带有线性图表的可视化,其中X是时间(当日志进入logstash时),Y显示来自EACH.TotalCount的数字。每个视觉效果仅适用于一个EACH.Algorithm

此图像显示了我的期望。 enter image description here

正如您在TIME中所看到的那样,我将EACH.TotalCount的值设为正值。每个图表仅适用于一种算法。 实际上我可以从unique countEACH.TotalCount获得线性图表。这是错的。

1 个答案:

答案 0 :(得分:0)

要执行此操作,您需要通过logstash将数据导入elasticsearch。如果你不知道如何做到这一点,请澄清你的问题。

我使用以下脚本模拟了您的数据:

curl -XDELETE http://localhost:9200/logstash
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:00-0600",
    "algorithm": "xxx",
    "totalCount": 1000
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:08-0600",
    "algorithm": "xxx",
    "totalCount": 1500
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:09-0600",
    "algorithm": "xxx",
    "totalCount": 546
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:10-0600",
    "algorithm": "xxx",
    "totalCount": 500
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:11-0600",
    "algorithm": "xxx",
    "totalCount": 1500
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:12-0600",
    "algorithm": "yyy",
    "totalCount": 500
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:13-0600",
    "algorithm": "yyy",
    "totalCount": 1000
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:14-0600",
    "algorithm": "yyy",
    "totalCount": 1465
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:15-0600",
    "algorithm": "yyy",
    "totalCount": 412
}'
curl -XPOST http://localhost:9200/logstash/data -d '{
    "@timestamp": "2016-02-26T08:32:16-0600",
    "algorithm": "yyy",
    "totalCount": 354
}'

所以现在我们需要构建可视化。进入可视化部分并创建一个新的折线图。然后选择以下选项:

  • 在Y轴上
    • 选择sum字段
    • totalCount
  • 在X轴上
    • 选择Split Chart
    • 选择Terms
    • 选择Field的{​​{1}}(logstash应该为您创建该字段)
    • 点击底部的algorithm.raw
    • 选择Add sub-buckets
    • 选择Date Histogram
    • Field
    • 选择@timestamp
    • Interval

你最终会得到这样的东西:

enter image description here

您的可视化将如下所示:

enter image description here

如果您想要图像中的曲线,请转到second标签,然后选择options