【问题标题】:aws Timestream: get empty intervalsaws Timestream:获取空间隔
【发布时间】:2021-06-04 16:15:48
【问题描述】:

我想使用 aws timestream 来跟踪用户对我们 API 的请求。在第一步中,我只是将每个请求的用户 ID 存储到 API。 对于图表,我想获取用户在特定时间间隔内的请求数。 此 SQL 以 10 分钟为间隔,在过去两小时内从用户 2 获取请求:

SELECT user_id, COUNT(user_id) AS n, bin(time, 10m) AS btime
FROM db_api.t_access
WHERE time > ago(2h) AND user_id IN ('2')
GROUP BY user_id, bin(time, 10m)
ORDER BY btime DESC

结果是:

2021-03-06 00:20:00.000000000 user_id:2 Count:1
2021-03-06 00:10:00.000000000 user_id:2 Count:4
2021-03-05 23:40:00.000000000 user_id:2 Count:2

没有请求的时间间隔不会返回,这里是 00:00 和 23:50。 有没有办法在 SQL 中使用 Count = 0 来获得这个空间隔? 还是我必须编写自己的代码才能从结果集中获取所有间隔(我使用 aws PHP API)?

【问题讨论】:

    标签: sql amazon-web-services amazon-timestream


    【解决方案1】:

    你可以使用:

     interpolate_fill(timeseries, array[timestamp], double) 
    

    参考链接:https://docs.aws.amazon.com/timestream/latest/developerguide/timeseries-specific-constructs.functions.interpolation.html

    【讨论】:

      猜你喜欢
      • 2021-01-20
      • 2021-02-22
      • 1970-01-01
      • 2021-07-14
      • 2022-08-03
      • 2021-06-23
      • 1970-01-01
      • 2011-09-13
      • 1970-01-01
      相关资源
      最近更新 更多