> For the complete documentation index, see [llms.txt](https://docs.nexthink.com/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexthink.com/platform/ja/user-guide/live-dashboards/live-dashboards-nql-examples.md).

# ライブダッシュボードNQLの例

{% hint style="warning" %}
NQLを使用してウィジェットを構成する際には、[絶対的な時間値をハードコードしない](/platform/ja/user-guide/live-dashboards/managing-live-dashboards.md#caution-on-using-hardcoded-time-values-in-widgets)か、静的なタイムスタンプを使用しないでください。
{% endhint %}

このNQLクエリの例のリストは、ライブダッシュボードウィジェットを作成するのに役立ちます。

## KPIウィジェット <a href="#livedashboardsnqlexamples-kpiwidget" id="livedashboardsnqlexamples-kpiwidget"></a>

<details>

<summary>NQLの構造</summary>

```
...
summarize <kpi> = <sum() | count() | avg() | max() | min()>
```

</details>

#### 例

<details>

<summary>過去7日間の全webアプリケーションエラーを表示します。</summary>

{% code overflow="wrap" lineNumbers="true" %}

```
web.errors during past 7d
| summarize total_errors = number_of_errors.sum() 
```

{% endcode %}

</details>

<details>

<summary>過去7日間のバックエンドページロード時間の比率を表示します。</summary>

{% code overflow="wrap" %}

```
web.page_views during past 7d
| summarize 
  backend_dur_ratio = page_load_time.backend.sum() /
  page_load_time.overall.sum()
```

{% endcode %}

</details>

<details>

<summary>リモートアクションの修正による推定節約額(USD)を表示します。</summary>

```
remote_action.executions during past 30d
| where status == success
| where purpose == remediation
| summarize amt_saved = (number_of_executions.sum()) * (20)
| list amt_saved.as(format = currency,code = usd)
```

</details>

***

## 折れ線グラフ <a href="#livedashboardsnqlexamples-linechart" id="livedashboardsnqlexamples-linechart"></a>

<details>

<summary>NQLの構造</summary>

```
<event table> <time_duration>
...
summarize <kpi1>, <kpi2>, ... by <time_duration_granularity>
(list <time>, <kpi1>, <kpi2>, ...)
```

</details>

#### 例

<details>

<summary>過去7日間の平均日次バックエンドページロード時間、クライアントページロード時間、ネットワーク時間を表示します。リスト行は指定しません。</summary>

```
web.page_views during past 7d
| summarize 
    backend_duration = page_load_time.backend.avg() , 
    client_duration = page_load_time.client.avg() , 
    network_duration = page_load_time.network.avg() by 1d
 
```

</details>

<details>

<summary>過去7日間の平均日次バックエンドページロード時間、クライアントページロード時間、ネットワーク時間を表示します。リスト行を使用して含めるパラメータを指定します。</summary>

```
web.page_views during past 7d
| summarize 
    backend_duration = page_load_time.backend.avg() , 
    client_duration = page_load_time.client.avg() , 
    network_duration = page_load_time.network.avg() by 1d
| list end_time, backend_duration, client_duration, network_duration
```

</details>

<details>

<summary>推定日次総エネルギー消費量（kWh）を表示します。</summary>

{% code overflow="wrap" %}

```nql_/apigateway/nql-editor
execution.events during past 15d
| where device.operating_system.name != "*server*"
| where 
  (device.hardware.type == laptop 
  or device.hardware.type == desktop)
| where binary.name in ["nxtsvc.exe", "nxtsvc"]
| summarize 
  Total_energy_consumption = 
  (((execution_duration.sum()) ^ (1)) / (3600)) * (30) 
  by 1d
| list 
  start_time, 
  Total_energy_consumption.as(format = energy)
```

{% endcode %}

</details>

***

## デフォルトのブレークダウンが無効になっている棒グラフ <a href="#livedashboardsnqlexamples-barchart-disabled-breakdown" id="livedashboardsnqlexamples-barchart-disabled-breakdown"></a>

<details>

<summary>NQLの構造</summary>

この場合、[デフォルトのブレークダウンが無効](/platform/ja/user-guide/live-dashboards/widget-types/bar-chart.md#barcharts-without-breakdowns)なので、クエリでは常に`by <segmentation1>,...`を指定する必要があります。

```
...
summarize <kpi1>, <kpi2>, ... by <segmentation1>, <segmentation2>, ...
```

</details>

#### 例

<details>

<summary>過去7日間の設置プラットフォーム、ハードウェアの製造元、モデルごとのデバイスのハードリセット数の比率を表示します。</summary>

```
device_performance.hard_resets  during past 7d
| summarize
    num_hard_resets = number_of_hard_resets.sum() ,
    num_devices = device.count()
   by
    device.operating_system.platform ,
    device.hardware.manufacturer ,
    device.hardware.model
| sort num_hard_resets desc
```

</details>

<details>

<summary>アプリケーションごとのwebトランザクション数を表示します。</summary>

```
web.transactions 
| summarize nb_transactions = number_of_transactions.sum() 
   by application.name 
| sort nb_transactions desc
```

</details>

<details>

<summary>不明なISPを除くInternet Service Provider (ISP)の数を表示します。</summary>

```
devices
| where device.public_ip.isp != null
| summarize 
  devices = device.name.count() 
  by device.public_ip.isp
| sort devices desc
```

</details>

<details>

<summary>各トリガーメソッドによるワークフローを通じて達成されたUSDの推定節約額を表示します。</summary>

{% code overflow="wrap" %}

```nql_/apigateway/nql-editor
workflow.executions during past 30d
| where status == success
| summarize amt_saved = (number_of_executions.sum()) * (100) 
  by trigger_method
| list trigger_method, amt_saved.as(format = currency,code = usd)
| sort amt_saved desc
```

{% endcode %}

</details>

## デフォルトのブレークダウンが有効になっている棒グラフ <a href="#livedashboardsnqlexamples-barchart-enabled-breakdown" id="livedashboardsnqlexamples-barchart-enabled-breakdown"></a>

<details>

<summary>NQLの構造</summary>

この場合、[デフォルトのブレークダウンが有効](/platform/ja/user-guide/live-dashboards/widget-types/bar-chart.md#barcharts-with-breakdowns)なので、クエリから`by <segmentation1>,...`を省略することができます。システムはブレークダウンのドロップダウンにあるオプションをデフォルトとして使用します。

```
...
summarize <kpi1>, <kpi2>, ...
```

</details>

#### 例

<details>

<summary>デフォルトのブレークダウンオプションによるウェブページビュー数</summary>

[デフォルトのブレークダウンが有効](/platform/ja/user-guide/live-dashboards/widget-types/bar-chart.md#barcharts-with-breakdowns)なので、システムは`web.page_views`をブレークダウンドロップダウンにあるデフォルトオプションに基づいて表示します。\
この場合、**URL**、**適応型タイプ**、**アクティブタブ数**、**大きなリソースの数**、**経験レベル**による。

```
web.page_views
| summarize web.page_views = number_of_page_view.sum() 
```

</details>

***

## 単一指標ゲージチャート <a href="#livedashboardsnqlexamples-single-metricgaugechart" id="livedashboardsnqlexamples-single-metricgaugechart"></a>

### 悪いイベントが発生している場合のデバイスまたはユーザーの比率；

クラッシュのような悪いイベントが発生した場合のデバイスまたはユーザーの比率を表示する単一指標ゲージチャートを作成します。これにより、問題がデバイスやユーザーにどのように影響するかを確認できます。

<details>

<summary>NQLの構造</summary>

```
<devices|users>
| include <event table>
| compute temp_bad_number = <device|user>.count()
| summarize 
   <metric> = temp_bad_number.sum(), 
   <total> = count()
```

</details>

#### 例

<details>

<summary>会社内の全デバイス中で、実行クラッシュが発生しているデバイスの比率を表示します。</summary>

```
devices
| include execution.crashes
| compute crash_cnt = device.count()
| summarize 
   devices_with_crashes = crash_cnt.sum(), 
   total_devices = count()
```

</details>

<details>

<summary>アプリケーションがフォアグラウンドで実行されている時に発生したクラッシュだけを表示します。</summary>

```
devices
| include execution.crashes
| compute crash_cnt = device.countif(process_visibility == foreground)
| summarize
   devices_with_crashes = crash_cnt.sum(),
   total_devices = count()
```

</details>

### イベントの比率

クラッシュ、フリーズ、ハードリセット、システムリセットなどのイベント発生時のイベントの比率を表示します。

<details>

<summary>NQL構造</summary>

```
<devices|users>
| include <bad event table>
| compute temp_metric_number = count()
| include <total event table>
| compute temp_total_number = count()
| summarize 
    <metric> = temp_metric_number.sum(), 
    <total> = temp_total_number.sum()
```

</details>

#### 例

<details>

<summary>全セッション中で低品質のコラボレーションセッションの比率を表示します。</summary>

```
devices 
| include collaboration.sessions 
| where video.quality == poor or audio.quality == poor 
| compute num_poor_quality_sessions = id.count() 
| include collaboration.sessions 
| compute num_total_sessions = id.count() 
| summarize
    poor_quality = num_poor_quality_sessions.sum(), 
    acceptable_quality = num_total_sessions.sum()
```

</details>

### スコアメトリック

DEXスコアメトリックを表示します。

<details>

<summary><strong>NQLの構造</strong></summary>

```
<score table>
| summarize <metric> = <score_field>.avg(), <total> = <total>
```

</details>

**例**

<details>

<summary>DEXスコアメトリックを表示します</summary>

```
dex.scores
| summarize score = value.avg() , total = 100
```

</details>

***

## 複数指標ゲージチャート <a href="#livedashboardsnqlexamples-multi-metricgaugechart" id="livedashboardsnqlexamples-multi-metricgaugechart"></a>

### 悪いイベントが発生しているオブジェクトに対し、正常な状態のオブジェクトのデバイスまたはユーザーの比率

<details>

<summary><strong>NQLの構造</strong></summary>

```
<devices|users>
| include <event table>
| compute temp_bad_number = <device|user>.count()
| summarize 
   <good_label> = count() - temp_bad_number.sum(), 
   <bad_label> = temp_bad_number.sum()
```

</details>

**例**

<details>

<summary>クラッシュしているデバイスに対する、クラッシュしていないデバイスの比率を表示します。</summary>

```
devices
| include execution.crashes
| compute crash_cnt = device.count()
| summarize 
    without_crashes = count() - crash_cnt.sum(), 
    with_crashes = crash_cnt.sum()
```

</details>

### 悪い出来事を持つデバイスに対する、持たないデバイスの比率

<details>

<summary><strong>NQLの構造</strong></summary>

```
devices
| include <bad event table>
| compute temp_bad_number = count()
| include <total event table>
| compute temp_total_number = count()
| summarize 
   <good_label> = temp_total_number.sum() - temp_bad_number.sum(), 
   <bad_label> = temp_bad_number.sum()
```

</details>

**例**

<details>

<summary>ハードリセットを持っているデバイスと持っていないデバイスの比率を表示します。</summary>

```
devices
| include device_performance.hard_resets
| compute hard_reset_cnt = number_of_hard_resets.sum()
| include device_performance.events
| compute total_cnt = count()
| summarize 
   no_hard_resets = total_cnt.sum() - hard_reset_cnt.sum(), 
   hard_resets = hard_reset_cnt.sum()
```

</details>

### 良い状態のユーザーまたはデバイスと悪い状態のユーザーまたはデバイスの比率

<details>

<summary><strong>NQLの構造</strong></summary>

```
<devices|users>
| include <event table>
| where <condition is bad>
| compute temp_bad_number = <device|user>.count()
| include <event table>
| where <condition is good>
| compute temp_good_number = <device|user>.count()
| summarize 
   <good_label> = temp_good_number.sum(), 
   <bad_label> = temp_bad_number.sum()
```

</details>

**例**

<details>

<summary>良好なページビュー体験を持つユーザーと不満のある体験を持つユーザーの比率を表示します。</summary>

```
users
| include web.page_views
| where experience_level == frustrating
| compute frustrating_cnt = user.count()
| include web.page_views
| where experience_level == good 
| compute good_cnt = user.count()
| summarize 
   good = good_cnt.sum(), 
   frustrating = frustrating_cnt.sum()
```

</details>

### 良い状態のイベントと悪い状態のイベントの比率\&#x20

<details>

<summary><strong>NQLの構造</strong></summary>

```
<devices|users>
| include <event table>
| where <condition is bad>
| compute temp_bad_number = <sum|count>
| include <event table>
| where <condition is good>
| compute temp_good_number = <sum|count>
| summarize 
   <good_label> = temp_good_number.sum(), 
  <bad_label> = temp_bad_number.sum()
```

</details>

**例**

<details>

<summary>良好な体験を持つページビューと不満のある体験を持つページビューの比率を表示します。</summary>

```
users
| include web.page_views
| where experience_level == frustrating
| compute frustrating_cnt = number_of_page_views.sum() 
| include web.page_views
| where experience_level == good 
| compute good_cnt = number_of_page_views.sum() 
| summarize 
   good = good_cnt.sum(), 
   frustrating = frustrating_cnt.sum()
```

</details>

***

関連トピック:

[ウィジェットの種類](/platform/ja/user-guide/live-dashboards/widget-types.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nexthink.com/platform/ja/user-guide/live-dashboards/live-dashboards-nql-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
