简体   繁体   English

寻找 Kusto 查询语言以从 API 查询端点的响应时间

[英]Looking for Kusto Query Language to query an endpoint for response time from the API

This is my current query that i have in azure logs:这是我在 azure 日志中的当前查询:

let numberOfBuckets = 24;
let interval = toscalar(requests | where url matches regex "courses.*"
| summarize interval = (max(timestamp)-min(timestamp)) / numberOfBuckets
| project floor(interval, 1m));
requests | where url matches regex "courses.*"
| summarize count() by url

It doesn't quite work and I've tried a lot of different ways to do this它不太管用,我尝试了很多不同的方法来做到这一点

like this...像这样...

let under400_course = requests | where url matches regex "/courses.*" | where duration < 400 | count; 
let total_req_course = requests | where url matches regex "/courses.*" | count; 
print under400_apt_SLI = toscalar(under400_course) * 100/toscalar(total_req_course);

just as a query to get information...只是作为获取信息的查询...

how do I actually get each response time for every connection in the last 24 hours for this endpoint?我如何实际获取此端点在过去 24 小时内每个连接的每个响应时间?

how do I actually get each response time for every connection in the last 24 hours for this endpoint?我如何实际获取此端点在过去 24 小时内每个连接的每个响应时间?

I think the query is simpler for this request.我认为这个请求的查询更简单。 Have you tried this?你试过这个吗?

requests
| where timestamp > ago(24h)
| where url matches regex "courses.*"
| project timestamp, url, resultCode, duration

The query timestamp > ago(24h) will filter all requests in the last 24 hours.查询timestamp > ago(24h)将过滤过去 24 小时内的所有请求。 And the response time for request is already presented in requests table.请求的响应时间已经显示在requests表中。

You can refer to Kusto guideline by MS here: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/您可以在此处参考 MS 的 Kusto 指南: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/

let fastResponseTimeMaxMs = 800;
let errorBudgetThresholdForFastResponseTime = 90.0;
//
let startTime = ago(7days);
let endTime = now();
let timeStep = 300m;
//
requests
| where timestamp > startTime and timestamp < endTime
| where success == 'True' | where url matches regex "<URL>.*" 
| summarize TotalCount = count(), ActualCount = countif(duration <= fastResponseTimeMaxMs) by bin(timestamp, timeStep)
| extend Percentage = round(todecimal(ActualCount * 100) / todecimal(TotalCount), 2)
| extend ErrorBudgetMinPercent = errorBudgetThresholdForFastResponseTime
| extend InBudget = case(Percentage >= ErrorBudgetMinPercent, 1, 0)

This works... took a bit but I got it!这行得通……花了一点时间,但我明白了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM