# ワークフローNQLの例

システムはワークフローの実行を保存し、その後でNQLを使ってクエリすることができます。 次に示すのは一般的なNQLクエリの例です：

<details>

<summary>過去7日間のすべてのワークフローの実行</summary>

このクエリは過去7日間にトリガーされたすべてのワークフローの実行を返し、現在のステータスおよびNexthinkによって返されたメッセージの詳細を含みます。

```
workflow.executions during past 7d
|list request_id, request_time, workflow.name,device.name, status, status_details
|sort request_time desc
```

</details>

<details>

<summary>結果を含む過去7日間のすべてのワークフローの実行</summary>

このクエリは、ワークフローの結果情報を含む、過去7日間にトリガーされたすべてのワークフローの実行を返します。

```
workflow.executions during past 7d
|list request_id, request_time, workflow.name,device.name, outcome, outcome_details
|sort request_time desc
```

</details>

<details>

<summary>特定のワークフローのすべての実行</summary>

このクエリは、指定されたRemote Actionの記録されたすべての実行を返します。 以下のクエリで`「ワークフローの名前」`を、クエリしたいワークフローの名前に置き換えてください。

```
workflow.executions
|where workflow.name == "Name of workflow"
|list request_id, request_time, workflow.name, status, status_details
|sort request_time desc
```

あるいは、以下に示すように、より正確な検索を行うために、ワークフローの`nql_id`を使用できます。

```
workflow.executions
|where workflow.nql_id  == "#service_restart_and_repair"
|list request_id, request_time, workflow.name, status, status_details
|sort request_time desc
```

</details>

<details>

<summary>特定のデバイスを対象としたすべてのワークフローの実行</summary>

このクエリは、特定のデバイスがターゲットであったすべてのワークフローの実行を返します。

```
workflow.executions
|where device.name == "devicehostname"
|list request_time, workflow.name,device.name, status
|sort request_time desc
```

</details>

<details>

<summary>過去24時間のすべてのワークフロー実行の失敗</summary>

このクエリは、過去24時間以内に失敗したワークフローの実行リストを返し、実行からの最後に知られているステータスメッセージを含みます。

```
workflow.executions during past 24h
|where status == failure 
|list request_time, workflow.name,device.name, status, status_details
|sort request_time desc
```

</details>

<details>

<summary>特定のワークフローに対するすべての実行失敗と入力を含む</summary>

このクエリは、それらの入力を単一の文字列に含むワークフローのすべての実行を返します。 これはワークフローの失敗をデバッグするのに役立つ場合があります。

```
workflow.executions during past 7d
|where status == failure and workflow.name == "Name of workflow"
|list request_time, workflow.name, inputs, status, status_details
|sort request_time desc
```

</details>


---

# 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/workflows/workflows-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.
