【问题标题】:How to create time series chart for my data?如何为我的数据创建时间序列图表?
【发布时间】:2018-01-16 01:01:38
【问题描述】:

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

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

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

{
  "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
        }
      }
    ]
  }
}

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

我如何使用 Timelion 或其他图表来做到这一点?我应该在 Timelion 中使用哪个表达式? 我只在 Y=0 处看到一条直线。但是,我希望在 Y 轴上看到 Price,在 X 轴上看到小时数 (0..24)。

【问题讨论】:

    标签: elasticsearch kibana


    【解决方案1】:

    在可视化中尝试一下。 Y轴聚合应该是Average,Field应该是Price,然后添加一个带有Date histogram聚合的X轴bucket。如果可以不使用 Timelion,那应该可以满足您的需求。
    在 Timelion 中,我使用了这个:

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

    我在右上角设置了时间窗口,但我相信你可以在查询中设置它。

    【讨论】:

      猜你喜欢
      • 2020-05-27
      • 2013-06-13
      • 2020-03-17
      • 2016-02-20
      • 2011-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-03
      相关资源
      最近更新 更多