gpt4 book ai didi

Azure KQL - 在时间表之上创建总平均线

转载 作者:行者123 更新时间:2023-12-02 08:16:12 25 4
gpt4 key购买 nike

我有一些从我们的内部标签打印系统记录的数据。我想在时间表中查看每个请求的持续时间,但也希望在另一个请求之上有一条总平均线。无论如何,这可以在 KQL 中实现吗?

Red line

注意红线。这就是我想要的。

我目前正在使用以下 KQL:

requests
| where url has "api/FileHandover"
| project Duration = duration, Timestamp = timestamp
| summarize Average = avg(Duration) by Timestamp
| render timechart

最佳答案

建议不要按timestamp分组,而是按请求的bin分组,例如bin(timestamp, 1h)

// Data sample generation. Not part of the solution
let requests = range i from 1 to 1000 step 1 | extend url= "api/FileHandover", duration = 1d * rand() / 1m, timestamp = ago(rand() * 7d);
// Solution starts here
let raw_data = requests | where url has "api/FileHandover";
let total_avg = toscalar(raw_data | summarize avg(duration));
raw_data
| summarize Average = avg(duration) by bin(timestamp, 1h)
| extend total_avg
| render timechart

// Data sample generation. Not part of the solution
let requests = range i from 1 to 1000 step 1 | extend url= "api/FileHandover", duration = 1d * rand() / 1m, timestamp = ago(rand() * 7d);
// Solution starts here
requests
| where url has "api/FileHandover"
| as raw_data;
raw_data
| summarize avg(duration)
| as total_avg;
raw_data
| summarize Average = avg(duration) by bin(timestamp, 1h)
| extend total_avg = toscalar(total_avg)
| render timechart

Results

关于Azure KQL - 在时间表之上创建总平均线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73454497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com