> 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/understanding-key-data-platform-concepts/nexthink-query-language-nql/nql-keywords/nql-summarize-by.md).

# NQLサマライズバイ

`summarize by` ステートメントは、情報をプロパティや時間間隔でグループ化された集約結果に凝縮します。

## プロパティによるグルーピング <a href="#nqlsummarizeby-groupingbyproperty" id="nqlsummarizeby-groupingbyproperty"></a>

`by` の後にフィールド名を入力して、プロパティによる内訳を作成します。 追加のフィールド名をカンマで区切って入力し、さらなる内訳の次元を作成します。

{% hint style="info" %}
`summarize by` 句では、次の数値データ型を持つプロパティによるグループ化はサポートされていません：

* 日時、たとえば `last_seen`
* バイト、たとえば `hardware.memory`
  {% endhint %}

プロパティではなく時間間隔でグループ化するには、[期間によるグループ化](#nqlsummarizeby-groupingbyperiod)を参照してください。

### 構文 <a href="#nqlsummarizeby-syntax" id="nqlsummarizeby-syntax"></a>

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

```

  | summarize <新しいメトリック名> = <メトリック>.<集約関数> by <フィールド_1>, <フィールド_2> ...
```

{% endcode %}

### 例 <a href="#nqlsummarizeby-example" id="nqlsummarizeby-example"></a>

過去7日間のデバイスごとのConfluenceバックエンドページ読み込み時間の平均を表示します。

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

```
web.page_views 過去7d
| where application.name == "Confluence"
| summarize backendTime = page_load_time.backend.avg() by device.name
| list device.name, backendTime
| sort backendTime desc
```

{% endcode %}

<table data-search="false"><thead><tr><th>デバイス名</th><th>backendTime</th></tr></thead><tbody><tr><td>device-10d267d2</td><td>508.2 ms</td></tr><tr><td>device-d1d5abc9</td><td>498.9 ms</td></tr><tr><td>device-5117c4c3</td><td>432.1 ms</td></tr><tr><td>device-16834449</td><td>431.9 ms</td></tr><tr><td>device-b634ce84</td><td>429.4 ms</td></tr><tr><td>device-731db075</td><td>349.8 ms</td></tr><tr><td>device-7fb313ef</td><td>293.9 ms</td></tr><tr><td>device-a834a720</td><td>277.6 ms</td></tr><tr><td>…</td><td>…</td></tr></tbody></table>

最も多くのデバイスで使用されているパブリックIPアドレスを順位付けします。 通常、同じアドレスを共有するデバイスは、企業のファイアウォールやプロキシサービスなど、同じエグレスポイントを経由してインターネットに接続します。 これらのクラスターの変化は、ネットワークの変更を示します。

{% hint style="info" %}
IPアドレスフィールドによるグループ化では、アドレスの完全一致の値でグループ化されます。 IP範囲によるグループ化はサポートされていません。
{% endhint %}

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

```
devices
| summarize total = count() by public_ip.ip_address
| sort total desc
```

{% endcode %}

| パブリックIPアドレス   | total |
| ------------- | ----- |
| 203.0.113.17  | 1,284 |
| 203.0.113.42  | 976   |
| 198.51.100.8  | 412   |
| 198.51.100.63 | 87    |
| …             | …     |

過去7日間に最も多くのWebエラーを生成したURLを、エラーコード別に一覧表示します。 `code` などの整数フィールドでグループ化すると、異なる値ごとに1つの行が返されます。

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

```
web.errors during past 7d
| summarize total = number_of_errors.sum() by code, url
| sort total desc
```

{% endcode %}

| code | url                                  | total |
| ---- | ------------------------------------ | ----- |
| 503  | <https://intranet.example.com/api>   | 2,140 |
| 404  | <https://intranet.example.com/help>  | 1,509 |
| 500  | <https://portal.example.com/login>   | 883   |
| 403  | <https://portal.example.com/reports> | 216   |
| …    | …                                    | …     |

## 期間によるグルーピング <a href="#nqlsummarizeby-groupingbyperiod" id="nqlsummarizeby-groupingbyperiod"></a>

時間期間と組み合わせて使用する場合、`summarize by` ステートメントはメトリック値を時間バケットにグループ化します。

### 構文 <a href="#nqlsummarizeby-syntax.1" id="nqlsummarizeby-syntax.1"></a>

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

```

  | summarize <新しいメトリック名> = <メトリック>.<集約関数> by <時間期間>
```

{% endcode %}

有効な期間値は次のとおりです：

* `15 min` `30 min` `45 min` …\
  値は15の倍数でなければなりません。
* `1 h` `2 h` `3 h` ...\
  値は整数でなければなりません。
* `1 d` `2 d` `3 d` ...\
  値は整数でなければなりません。

### 例 <a href="#nqlsummarizeby-example.1" id="nqlsummarizeby-example.1"></a>

過去7日間のクラッシュの毎日の数を時系列順に表示します。

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

```
execution.crashes 過去7d
  | summarize total_number_of_crashes = count() by 1d
  | sort start_time asc
```

{% endcode %}

<table data-search="false"><thead><tr><th>start_time</th><th>end_time</th><th>bucket_duration</th><th>number_of_crashes</th></tr></thead><tbody><tr><td>2021-03-05<br>00:00:00</td><td>2021-03-06<br>00:00:00</td><td>1 d</td><td>758</td></tr><tr><td>2021-03-06<br>00:00:00</td><td>2021-03-07<br>00:00:00</td><td>1 d</td><td>700</td></tr><tr><td>2021-03-07<br>00:00:00</td><td>2021-03-08<br>00:00:00</td><td>1 d</td><td>954</td></tr><tr><td>2021-03-08<br>00:00:00</td><td>2021-03-09<br>00:00:00</td><td>1 d</td><td>493</td></tr><tr><td>2021-03-09<br>00:00:00</td><td>2021-03-10<br>00:00:00</td><td>1 日</td><td>344</td></tr><tr><td>2021-03-10<br>00:00:00</td><td>2021-03-11<br>00:00:00</td><td>1 d</td><td>765</td></tr><tr><td>2021-03-11<br>00:00:00</td><td>2021-03-12<br>00:00:00</td><td>1 d</td><td>857</td></tr></tbody></table>

## プロパティと期間によるグルーピング <a href="#nqlsummarizeby-groupingbypropertyandperiod" id="nqlsummarizeby-groupingbypropertyandperiod"></a>

プロパティと時間期間を組み合わせて、追加の内訳をもつ時間バケットを生成します。 複数のフィールドを使用できますが、時間期間選択子は1つのみです。 項目の順序は任意ですが、時間期間選択子はフィールドのリスト内の任意の位置に配置できます。

### 構文 <a href="#nqlsummarizeby-syntax.2" id="nqlsummarizeby-syntax.2"></a>

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

```

  | summarize <新しいメトリック名> = <メトリック>.<集約関数> by <フィールド_1>, <フィールド_2>, ... <時間期間>, ...
```

{% endcode %}

### 例 <a href="#nqlsummarizeby-example.2" id="nqlsummarizeby-example.2"></a>

過去30日間のクラッシュ数をオペレーティングシステムプラットフォームで内訳して、クラッシュ数の多い順に並べ替えて表示します。

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

```
execution.crashes 過去30d
  | summarize total_number_of_crashes = count() by 1d, device.operating_system.platform 
  | sort total_number_of_crashes desc
```

{% endcode %}

<table data-search="false"><thead><tr><th>デバイスプラットフォーム</th><th>start_time</th><th>end_time</th><th>bucket_duration</th><th>number_of_crashes</th></tr></thead><tbody><tr><td>Windows</td><td>2021-12-07<br>00:00:00</td><td>2021-12-08<br>00:00:00</td><td>1 d</td><td>690</td></tr><tr><td>Windows</td><td>2021-12-08<br>00:00:00</td><td>2021-12-09<br>00:00:00</td><td>1 d</td><td>533</td></tr><tr><td>macOS</td><td>2021-12-20<br>00:00:00</td><td>2021-12-21<br>00:00:00</td><td>1 d</td><td>511</td></tr><tr><td>Windows</td><td>2021-12-17<br>00:00:00</td><td>2021-12-18<br>00:00:00</td><td>1 d</td><td>493</td></tr><tr><td>Windows</td><td>2021-12-08<br>00:00:00</td><td>2021-12-09<br>00:00:00</td><td>1d</td><td>356</td></tr><tr><td>macOS</td><td>2021-12-20<br>00:00:00</td><td>2021-12-21<br>00:00:00</td><td>1d</td><td>325</td></tr><tr><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td></tr></tbody></table>


---

# 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 dynamically by asking a question.

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

```
GET https://docs.nexthink.com/platform/ja/understanding-key-data-platform-concepts/nexthink-query-language-nql/nql-keywords/nql-summarize-by.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
