为此,您需要通过 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 轴上
- 在 X 轴上
- 选择
Split Chart
- 选择
Terms
- 选择
Field of algorithm.raw(logstash 应该为您创建该字段)
- 点击底部的
Add sub-buckets
- 选择
Date Histogram
- 选择
Field 的@timestamp
- 选择
Interval 的second
你会得到这样的结果:
您的可视化将如下所示:
如果您想要图像中的曲线,请转到options 标签并选择smooth lines。