在KQL azure监视器中显示今天、昨天和一周的最佳方式

rpppsulh  于 2022-11-25  发布在  其他
关注(0)|答案(1)|浏览(145)

我试图显示今天(连续24小时)与昨天(再次连续)的计数与每周平均值
虽然我已经得到了工作的代码,但我得到了一个错误,以及
错误为(查询成功,但出现警告:处理查询时出现一些错误。错误:“部分查询失败:未指定的错误(消息:“碎片号:5eeb 9282 -0854-4569-a674- 10 f8 daef 9 f7 d,来源:(错误{详细信息:404,“返回qh1kustorageoiprdweu16.blob.core.windows.net/jgtb64673c4e98a07fa116b4e49211-0d2a81b5bf3540e087ff2cc0e4e57c98/13da174e-3951-4b54-9a45-1f9cbe5759b4/426a5a10-4e91-4”
该代码

let Yes_End = ago(24h);
let Yes_Start = ago(48h);
let N = ago(1m);
let LW_end = ago(14d);
let Lw_start = ago(7d);

let Curr = customMetrics
|extend Dec_Reasion = tostring(customDimensions["DeclineReason"])
|extend Type = tostring(customDimensions["AcquiringInstitutionId"])
|extend dw = dayofweek(timestamp)
|where name =='TransactionsDeclined'
|where timestamp between (Yes_End..N)
|summarize CurrentVal=sum(valueCount) by tostring(Dec_Reasion);

let Trend = customMetrics
|extend Dec_Reasion = tostring(customDimensions["DeclineReason"])
|extend Type = tostring(customDimensions["AcquiringInstitutionId"])
|where timestamp between (Yes_Start .. Yes_End)
|where name =='TransactionsDeclined'
|summarize Yesterday_total=sum(valueCount) by tostring(Dec_Reasion);

let weekTrend =customMetrics
|extend Dec_Reasion = tostring(customDimensions["DeclineReason"])
|extend Type = tostring(customDimensions["AcquiringInstitutionId"])
|extend dw = dayofweek(timestamp)
|where toint(dw) <6
|where timestamp between (LW_end .. Lw_start)
|where name =='TransactionsDeclined'
|summarize Week_Avg=sum(valueCount)/5 by tostring(Dec_Reasion) ;

Curr
|join kind=leftouter Trend on Dec_Reasion
|join kind=leftouter weekTrend on Dec_Reasion
|project Dec_Reasion,CurrentVal,Yesterday_total,Week_Avg
pod7payv

pod7payv1#

此查询可以用不需要连接的方式编写。
你也许想试试。

let Yes_End = ago(24h);
let Yes_Start = ago(48h);
let N = ago(1m);
let LW_end = ago(14d);
let Lw_start = ago(7d);
customMetrics
| where     timestamp between (LW_end .. Lw_start) 
        or  timestamp between (Yes_Start .. N)
| where name == 'TransactionsDeclined'
| extend    Dec_Reasion = tostring(customDimensions["DeclineReason"])
           ,Type        = tostring(customDimensions["AcquiringInstitutionId"])
| summarize CurrentVal      = sumif(valueCount, timestamp between (Yes_End .. N)) 
           ,Yesterday_total = sumif(valueCount, timestamp between (Yes_Start .. Yes_End))
           ,Week_Avg        = sumif(valueCount, timestamp between (LW_end .. Lw_start) and where toint(dayofweek(timestamp)) < 6) / 5
            by Dec_Reasion

相关问题