NQL関数

関数は、データを集約、フォーマット、または抽出し、さらなる分析を可能にする定義済みの操作です。 これには、グループ化されたデータ内での合計、平均、およびカウントのような操作が含まれます。

特定の関数に応じて、以下を使用することができます:

  • compute

  • summarize

  • list

  • sort

  • where

構文

...
... <metric>.<function>.(<optional: function parameters>)

集約関数

sum()

devices during past 7d 
| include device_performance.system_crashes during past 7d 
| compute number_of_crashes = number_of_system_crashes.sum()

countif()

collaboration.sessions during past 24h
| summarize ratio_of_poor_calls = countif(session.audio.quality = poor or session.video.quality = poor) / count() by connection_type

フォーマット関数

as()

devices
| summarize total_cost = count() * 2000
| list total_cost.as(format = currency, code  = USD)

タイムスタンプ関数

time_elapsed()

devices
| where operating_system.last_update.time_elapsed() > 15d

hour()

device_performance.events during past 24h
| where start_time.hour() >= 9 and end_time.hour() <= 17

集計された指標

関数と集計された指標を区別することが重要です。データモデルには情報へのアクセスを簡素化するさまざまな集計指標が含まれています。 これらはデータモデルのフィールドとして定義されています。

フィールド
説明

.avg

バケットに集計された指標の平均値。

where unload_event.avg > 1.0

.sum

バケットに集計された指標のすべての値の合計。

where unload_event.sum == 10

.count

バケット内の集計された値の数。

where unload_event.count <= 4

.min

バケット内の指標の最小値。

where unload_event.min < 1.0

.max

バケット内の指標の最大値。

where unload_event.max > 1.0

スマート集計

スマート集計は、基礎的な計算を抽象化した集計された指標に対する集計です。 これらはデータモデルのフィールドではありません。 クエリの実行中に、パーサーがそれらを即時で計算します。

集計
説明

.avg()

指標の平均値。 これは.sum.sum() / .count.sum()に相当します。

.sum()

指標のすべての値の合計。 これは.sum.sum()に相当します。

.max()

指標の最大値。 これは.max.max()に相当します。

.min()

指標の最小値。 これは.min.min()に相当します。

.count()

集計された値の数。 これは.count.sum()に相当します。

例:

平均で3GB未満の空きメモリを持つデバイスのリストを取得します。 以下のクエリは、compute句でfree_memory.avg()スマート集計を含みます。 これはfree_memory.avg集計指標と同じ基礎となるデータポイントに基づいて空きメモリの平均を計算します。 これはfree_memory.avg.avg().に相当します。

devices during past 7d
| with device_performance.events during past 7d
| compute avg_free_memory = free_memory.avg()
| where avg_free_memory < 3GB

関数の連結

同じフィールドに対して複数の関数を呼び出すことができます。 現在、このシステムはtime_elapsed()関数の連結をサポートしています。

例:

以下のクエリは、最後の高速起動からの経過時間を持つデバイスのリストを返します。

devices
| include device_performance.boots
| where type == fast_startup
| compute time_since_last_fast_startup = time.last().time_elapsed()

次のセクションでは、使用ルールと例を含むすべての利用可能な関数のリストを見つけることができます。

Last updated

Was this helpful?