在不同事件中按相同密钥 UUID 进行分组并减去时间戳

问题描述 投票:0回答:1

我有两个或多个具有相同 Id 的事件,例如会话,但具有不同的属性值,我应该查询按 id 分组的所有事件并计算两个时间戳之间的差异。

事件示例

活动一:

{ 类型:'开始', 编号:1 ... }

活动二:

{ 类型:'结束', 编号:1 ... }

伪查询:

选择(结束.timrstamp-开始.时间戳)/1000 按 ID 分组

math facet newrelic nrql
1个回答
0
投票

我认为一种可能的解决方案是

SELECT average(duration) FROM (
SELECT (
  (filter(latest(timestamp), where transitionName = 'STARTED') - 
  filter(latest(timestamp), where transitionName = 'CREATED'))
) AS 'duration'
FROM table 
FACET id AS uniqueId
SINCE last hour 

© www.soinside.com 2019 - 2024. All rights reserved.