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

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

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

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

<details>

<summary>NQLの構造</summary>

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

</details>

#### 例

<details>

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

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

```
web.errors 過去7日間
| 要約 total_errors = number_of_errors.sum() 
```

{% endcode %}

</details>

<details>

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

{% code overflow="wrap" %}

```
web.page_views 過去7日間
| 要約 
  backend_dur_ratio = page_load_time.backend.sum() /
  page_load_time.overall.sum()
```

{% endcode %}

</details>

<details>

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

```
remote_action.executions 過去30日間
| where status == success
| where purpose == remediation
| 要約 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>
...
要約 <kpi1>, <kpi2>, ... by <time_duration_granularity>
(list <time>, <kpi1>, <kpi2>, ...)
```

</details>

#### 例

<details>

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

```
web.page_views 過去7日間
| 要約 
    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 過去7日間
| 要約 
    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 過去15日間
| where device.operating_system.name != "*server*"
| where 
  (device.hardware.type == laptop 
  or device.hardware.type == desktop)
| where binary.name in ["nxtsvc.exe", "nxtsvc"]
| 要約 
  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>

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

```
...
要約 <kpi1>, <kpi2>, ... by <segmentation1>, <segmentation2>, ...
```

</details>

#### 例

<details>

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

```
device_performance.hard_resets  過去7日間
| 要約
    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 
| 要約 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
| 要約 
  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 過去30日間
| where status == success
| 要約 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>

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

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

</details>

#### 例

<details>

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

[デフォルトのブレークダウンが有効](https://docs.nexthink.com/platform/ja/user-guide/widget-types/bar-chart#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()
| 要約 
   <metric> = temp_bad_number.sum(), 
   <total> = count()
```

</details>

#### 例

<details>

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

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

</details>

<details>

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

```
デバイス
| 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()
| 要約 
    <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() 
| 要約
    poor_quality = num_poor_quality_sessions.sum(), 
    acceptable_quality = num_total_sessions.sum()
```

</details>

### スコアメトリック

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

<details>

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

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

</details>

**例**

<details>

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

```
dex.scores
| 要約 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()
| 要約 
   <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()
| 要約 
    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()
| 要約 
   <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()
| 要約 
   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()
| 要約 
   <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()
| 要約 
   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>
| 要約 
   <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() 
| 要約 
   good = good_cnt.sum(), 
   frustrating = frustrating_cnt.sum()
```

</details>

***

関連トピック:

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


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
