> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/zen-firewall/zen-features/playbooks.md).

# プレイブック

Zen がアプリ内で不審な挙動を検知したときに IP を自動的にブロックします。

プレイブックは Zen Firewall の自動化ルールです。各プレイブックはイベントとアクションを 1 つずつ組み合わせます。Zen がそのイベントを検知すると、代わりにそのアクションを実行します。誰かがダッシュボードを見張っている必要はありません。

プレイブックは 1 文で表せます: **攻撃の波を検知 → IP を 30 分間ブロック**.

{% hint style="info" %}
プレイブックは早期アクセス機能です。 [サポートに問い合わせる](/docs/docs-ja/miscellaneous-info/contact-support.md) ワークスペースで有効化してもらうために。
{% endhint %}

## プレイブックを作成

1. Zen Firewall アプリを開き、 **プレイブック** タブを選択します。
2. クリックします **プレイブックを追加**.
3. 次の項目の下で **次の場合**、プレイブックをトリガーするイベントを選択します。
4. 次の項目の下で **設定**、アクションとその継続時間を選択します。
5. クリックします **プレイブックを作成**.

![When トリガーと Configure action を含むプレイブック作成ダイアログ。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-1d4d43c9ef0edb8eb1d2deeed1742faaab6d48a6%2FScreenshot%202026-09-07%20at%2016.55.26.png?alt=media)

プレイブックは作成するとすぐに有効になります。

![Playbooks タブで、攻撃の波の後に IP を 30 分間ブロックする有効なプレイブックが一覧表示されます。](https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-95fc1101681f003fad34e319a6f2395152c7e634%2FScreenshot%202026-09-07%20at%2016.55.18.png?alt=media)

## イベント

プレイブックはイベントに反応します。アプリケーションコードから独自のイベントを送ることも、Zen が標準で検知するイベントを使うこともできます。

### カスタムイベント

アプリケーションコードからイベントを報告するには `track`を使うと、アプリだけが知っていることにもプレイブックが反応できます。例: ログイン失敗、無効なクーポンコード、パスワードリセットのリクエスト、拒否された API キー、支払い失敗。

呼び出す `track` そのイベントがリクエスト処理中に発生する場所ならどこでも、イベント名を付けて

{% tabs %}
{% tab title="Node.js" %}

```javascript
const Zen = require("@aikidosec/firewall");

// Inside any request handler
Zen.track("your.event_name");
```

{% endtab %}

{% tab title="Python" %}

```python
from aikido_zen import track

# 任意のリクエストハンドラ内で
track("your.event_name")
```

{% endtab %}

{% tab title="Go" %}

```go
// Inside any HTTP handler, pass the request context
zen.Track(r.Context(), "your.event_name")
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
# Inside any request, for example a Rails controller action
Aikido::Zen.track("your.event_name")
```

{% endtab %}

{% tab title="PHP" %}

```php
// Inside any request handler
if (extension_loaded('aikido')) {
    \aikido\track('your.event_name');
}
```

{% endtab %}

{% tab title=".NET" %}

```csharp
// ASP.NET Core: Aikido.Zen.DotNetCore を使用;
// ASP.NET Framework: Aikido.Zen.DotNetFramework を使用;

// 任意のコントローラーアクションまたはミドルウェア内で
Zen.Track("your.event_name");
```

{% endtab %}
{% endtabs %}

イベント名はどんな形式でも構いません。小文字でドット区切りの名前を推奨します。たとえば `user.login_failed` または `coupon.invalid`.

を追加した後、 `track`イベントを 1 回発生させます。すると、プレイブック作成時に選べるイベントとして表示されます。 `track` を呼び出しても、単独では何もブロックしません。

Zen はリクエストから IP アドレスを取得するため、渡すのはイベント名だけで構いません。 [現在のユーザーを設定](/docs/docs-ja/zen-firewall/zen-features/blocking-users-with-zen-firewall.md) してから `track`を呼び出すと、Zen はユーザー情報も含めます。そのため、次のようなプレイブックを作成できます **`coupon.invalid` 5 分間に 10 回 → IP を 1 時間ブロック**。カウントはアプリ全体ではなく、IP ごとに行われます。

### 組み込みイベント

**攻撃の波を検知。** IP が体系的にアプリを探査しており、たとえば `.env` ファイルや隠しディレクトリをスキャンしています。Zen がこれをどう検知するかは [攻撃の波への保護](/docs/docs-ja/zen-firewall/zen-features/attack-wave-protection.md) を参照してください。

## アクション

**IP をブロック。** イベントの原因となった IP は、このアプリのブロックリストに追加されます。期間は 30 分、1 時間、24 時間、または永久から選べます。

一時的なブロックは自動的に期限切れになります。ブロックが期限切れになると、Zen はその IP のイベント数もリセットするため、プレイブックは最初からやり直されます。

プレイブックは、あなたの [バイパスリスト](/docs/docs-ja/zen-firewall/zen-features/bypassed-ips.md).

## プレイブックが実行した内容を確認する

次の **アクティビティ** Playbooks タブの表示では、プレイブックが行ったすべてのアクションが記録されます。いつ起きたか、どのプレイブックが発動したか、対象の IP、残りのブロック時間が分かります。ドロップダウンでプレイブックごとに絞り込めます。

プレイブックによるブロックも **プレイブックルール** で [この IP がブロックされているのはなぜですか？](/docs/docs-ja/zen-firewall/zen-features/why-is-this-ip-blocked.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://help.aikido.dev/docs/docs-ja/zen-firewall/zen-features/playbooks.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.
