Add a Dummy Row for Each Row in the Table

若如初见. 提交于 2021-01-28 13:41:42

问题


I have below query which returns %CPU of each Computer by every 1 hour

Query

Perf
| where TimeGenerated > ago(1h) 
| where CounterName == "% Processor Time" 
| where Computer endswith "XYZ" 
| summarize avg(CounterValue) by bin(TimeGenerated, 1h), Computer 

Result


I want to append Dummy row for each-row in the table with fixed value except TimeGenerated should be same as previous row in the table. Expecting result should look something like this.

Expected Result


回答1:


you could try something like this (note that you'll need to explicitly order your records as you wish):

let T = 
    Perf
    | where TimeGenerated > ago(1h) 
    | where CounterName == "% Processor Time" 
    | where Computer endswith "XYZ" 
    | summarize avg(CounterValue) by bin(TimeGenerated, 1h), Computer
;
T
| union (T | extend Computer = "Dummy", avg_CounterValue = 10)
| order by TimeGenerated


来源:https://stackoverflow.com/questions/61766644/add-a-dummy-row-for-each-row-in-the-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!