Share via


range 演算子

値が含まれる 1 列のテーブルを生成します。

注意

この演算子は表形式の入力を受け取りません。

構文

rangecolumnNamefromstarttostopstepstep

構文規則について詳しく知る。

パラメーター

名前 必須 説明
columnName string ✔️ 出力テーブル内の単一列の名前。
start int、long、real、datetime、または timespan ✔️ 出力の最小値。
stop int、long、real、datetime、または timespan ✔️ 出力で生成される最大値。 ステップ がこの値をステップオーバーした場合は、最大値にバインドされます。
step int、long、real、datetime、または timespan ✔️ 2 つの連続する値の差。

注意

値は、どのテーブルの列も参照できません。 入力テーブルに基づいて範囲を計算する場合は、mv-expand 演算子で範囲関数を使用する可能性があります。

戻り値

columnName という 1 つの列を持つテーブル。その列の値は、StartStart+Step というように続き、Stop までとなります。

次の例では、1 日に 1 回、過去 7 日間に拡張された現在のタイム スタンプのエントリを含むテーブルを作成します。

range LastWeek from ago(7d) to now() step 1d

出力

LastWeek
2015-12-05 09:10:04.627
2015-12-06 09:10:04.627
...
2015-12-12 09:10:04.627

次の例では、 演算子をパラメーターと共に使用 range する方法を示します。この演算子は、テーブルとして拡張および使用されます。

let toUnixTime = (dt:datetime) 
{ 
    (dt - datetime(1970-01-01)) / 1s 
};
let MyMonthStart = startofmonth(now()); //Start of month
let StepBy = 4.534h; //Supported timespans
let nn = 64000; // Row Count parametrized
let MyTimeline = range MyMonthHour from MyMonthStart to now() step StepBy
| extend MyMonthHourinUnixTime = toUnixTime(MyMonthHour), DateOnly = bin(MyMonthHour,1d), TimeOnly = MyMonthHour - bin(MyMonthHour,1d)
; MyTimeline | order by MyMonthHour asc | take nn

出力

MyMonthHour MyMonthHourinUnixTime DateOnly TimeOnly
2023-02-01 00:00:00.0000000 1675209600 2023-02-01 00:00:00.0000000
2023-02-01 04:32:02.4000000 1675225922.4 2023-02-01 00:00:00.0000000
2023-02-01 09:04:04.8000000 1675242244.8 2023-02-01 00:00:00.0000000
2023-02-01 13:36:07.2000000 1675258567.2 2023-02-01 00:00:00.0000000
... ... ... ...

次の例では、 という名前 Steps の 1 つの列を持つテーブルを作成します。この列の型は で long 、値は 14、および 7です。

range Steps from 1 to 8 step 3

次の例では、演算子を range 使用して小さなアドホックディメンション テーブルを作成し、ソース データに値がないゼロを導入するために使用する方法を示します。

range TIMESTAMP from ago(4h) to now() step 1m
| join kind=fullouter
  (Traces
      | where TIMESTAMP > ago(4h)
      | summarize Count=count() by bin(TIMESTAMP, 1m)
  ) on TIMESTAMP
| project Count=iff(isnull(Count), 0, Count), TIMESTAMP
| render timechart