从查询语言的角度来看,您正在做的事情是有效的并且应该可以工作。
您应该验证您是否真的打算在对函数-
的调用中使用减号 ( ) 。ago()
如果要将结果放在一行中,也可以使用 ajoin
而不是 aunion
print ago(24h), ago(-24h)
将输出:
| print_0 | print_1 |
|-----------------------------|-----------------------------|
| 2019-04-03 15:04:24.0178923 | 2019-04-05 15:04:24.0178923 |
和:
let requests = datatable(timestamp:datetime, duration:timespan)
[
datetime(2019-03-03 14:00), 123s,
datetime(2019-03-03 15:00), 12s,
datetime(2019-04-03 16:00), 13s,
datetime(2019-04-03 17:00), 456s,
datetime(2019-04-03 18:00), 56s,
datetime(2019-04-03 19:00), 45s,
datetime(2019-04-03 20:00), 43s,
datetime(2019-04-04 16:55), 77s,
]
;
requests
| where timestamp > ago(24h)
| summarize day = avg(duration)
| union (
requests
| where timestamp > ago(10m)
| summarize now = avg(duration)
)
将输出:
| day | now |
|----------|----------|
| 00:01:55 | |
| | 00:01:17 |
和:
let requests = datatable(timestamp:datetime, duration:timespan)
[
datetime(2019-03-03 14:00), 123s,
datetime(2019-03-03 15:00), 12s,
datetime(2019-04-03 16:00), 13s,
datetime(2019-04-03 17:00), 456s,
datetime(2019-04-03 18:00), 56s,
datetime(2019-04-03 19:00), 45s,
datetime(2019-04-03 20:00), 43s,
datetime(2019-04-04 16:55), 77s,
]
;
requests
| where timestamp > ago(24h)
| summarize day = avg(duration) by dummy = 1
| join kind=inner
(
requests
| where timestamp > ago(10m)
| summarize now = avg(duration) by dummy = 1
) on dummy
| project day, now
将输出:
| day | now |
|----------|----------|
| 00:01:55 | 00:01:17 |