如何为我的数据创建时间序列图表?

时间:2018-01-13 20:53:01

标签: elasticsearch kibana

我正在使用Elasticsearch 6和Kibana 6.这是我的索引:

def user_params
  list_allowed = [:email, :title, :last_name, :first_name, :phone]
  list_allowed << :role << other_param << another_param if current_user.admin?
  params.require(:user).permit(list_allowed)
end

日期时间以ISO时间给出。这是一些示例内容:

PUT /myindex
{
    "mappings": {
      "mydoctype": {
        "properties": {
          "Datetime": {
            "type":"date"
          },
          "Vehicle": {
            "type":"keyword"
          },
          "Producer": {
            "type":"keyword"
          },
          "Price": {
            "type":"double"
          }
        }
      }
    }
}

我想创建一个简单的时间序列图表,该图表应该说明过去24小时内价格的变化情况(平均每小时)。

如何使用Timelion或其他图表进行操作?我应该在Timelion中使用哪种表达方式? 我只看到Y = 0处的直线。但是,我希望在Y轴上看{ "took": 9, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 240, "max_score": 1, "hits": [ { "_index": "myindex", "_type": "mydoctype", "_id": "1515874730_31", "_score": 1, "_source": { "Datetime": "2018-01-13T21:18:26.953748", "Vehicle": "M1", "Producer": "XXX", "Price": 20000.00 } }, { "_index": "myindex", "_type": "mydoctype", "_id": "1515874730_67", "_score": 1, "_source": { "Datetime": "2018-01-13T22:10:00.346799", "Vehicle": "M1", "Producer": "XXX", "Price": 21000.00 } } ] } } ,在X轴看到小时(0..24)。

1 个答案:

答案 0 :(得分:0)

在可视化中尝试。 Y轴聚合应为平均值,字段应为Price,然后添加具有日期直方图聚合的X轴桶。如果不使用Timelion,那应该可以满足您的需求 在Timelion中我使用了这个:

.es(q=*, metric='avg:Price')

我在右上角设置了时间窗口,但我确定您可以在查询中设置它。

相关问题