# Fastly

### **Fastly から S3 へのログストリーミング**

Fastly からリアルタイムのアクセスログを Amazon S3 バケットに送信するには、Amazon S3 を送信先として **Fastly ログストリーミング**を設定します。以下は、Fastly のログ機能と Netacea の要件を満たすカスタムログフォーマットを使用して、Netacea がホストする S3 バケットへのリアルタイムストリーミングを設定するために必要な手順です。

### **前提条件**

Netacea へのウェブトラフィックログのストリーミングを正常に行うには、以下の点をご確認ください：

* Fastly コントロールパネルへのアクセス権を持つアクティブな Fastly アカウントがあること。
* 本番トラフィックを処理するよう設定された Fastly サービスが利用可能であること。
* Netacea から必要な AWS S3 バケットの詳細（バケット名、リージョン、パス、認証情報）を受け取っていること。これらは[こちら](https://netacea.gitbook.io/portal-docs/user-guides-and-videos/portal-setup-and-log-shipping-guide)で確認できます。
* ログ分析に Netacea が必要とする[最小限の必須データセット](#netacea-minimum-dataset)フィールドを把握していること。

### データ送信：リアルタイムストリーミング

このオプションはすべてのリクエストを記録し、ログをバッチで配信します。POV の要件に合わせて設定可能です。

### **実装手順**

1. [Fastly コントロールパネル](https://manage.fastly.com/)にログインします。
2. [ホーム](https://manage.fastly.com/home)ページから、適切なサービスを選択します。検索ボックスを使用して ID、名前、またはドメインで検索できます。
3. **Edit configuration** をクリックし、アクティブなバージョンをクローンするオプションを選択します。

<figure><img src="/files/otMdlDFXXSQwcl4W39ue" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/cCDrV1rKiZSLx0juiQ3O" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
以下のすべての設定変更は、**新しくクローンされたバージョン**に対して行われます。
{% endhint %}

### **ログストリーミングの設定**

1. **Logging** エリアに移動します。
2. Amazon S3 の '**Create endpoint'** ボタンをクリックします

<figure><img src="/files/7gAe7tVGzn19saWkiT77" alt=""><figcaption></figcaption></figure>

3. 以下の表の詳細を入力します：

XLOCKX109![](/files/cCDrV1rKiZSLx0juiQ3O)110XLOCKX

<table><thead><tr><th width="196">フィールド</th><th>値</th></tr></thead><tbody><tr><td>Name</td><td>エンドポイントの覚えやすい人間が読める名前を入力します（例：<strong>Netacea_Logging</strong>）</td></tr><tr><td>Placement</td><td>Format Version Default</td></tr><tr><td>Log Format</td><td>[こちらにある <strong>Log Format</strong> を貼り付けます</td></tr><tr><td>Timestamp</td><td>[こちらにある <strong>Timestamp Format</strong> を貼り付けます</td></tr><tr><td>Bucket Name</td><td>Netacea の <a href="https://portal.netacea.com/">admin portal</a> 内で提供された Amazon S3 バケットの名前</td></tr><tr><td>Domain</td><td>s3.eu-west-1.amazonaws.com</td></tr><tr><td>Access Method</td><td><strong>'User Credentials'</strong> を選択</td></tr><tr><td>Access Key</td><td>Netacea の <a href="https://portal.netacea.com/">admin portal</a> からコピー</td></tr><tr><td>Secret Key</td><td>Netacea の <a href="https://portal.netacea.com/">admin portal</a> からコピー</td></tr><tr><td>Period</td><td></td></tr></tbody></table>

4. '**Advanced options'** セクションを展開し、以下の表に記載されている特定の値を適用します：

| オプション                  | 値        |
| ---------------------- | -------- |
| Path                   | /        |
| PGP Public Key         | 空白       |
| Select Log line Format | 空白       |
| Compression            | Gzip     |
| Redundancy Level       | Standard |
| ACL                    | None     |
| Server Side Encryption | None     |
| Maximum Bytes          | 0        |

5. **'Create'** をクリックしてログエンドポイントを保存します。

### ログフォーマット

{% code overflow="wrap" %}

```
{"@timestamp": "%{%Y-%m-%dT%H:%M:%S%z}t","bc_type": %{if(req.http.netacea_bctype_string, "%u0022" + json.escape(req.http.netacea_bctype_string) + "%u0022", "null")}V,"bytes_sent": "%B","cookie_session_status": %{if(req.http.x-netacea:cookie_session_status, "%u0022" + json.escape(req.http.x-netacea:cookie_session_status) + "%u0022", "null")}V,"client": "%{json.escape(client.ip)}V","domain": %{if(req.http.host, "%u0022" + json.escape(req.http.host) + "%u0022", "null")}V,"integration_mode": %{"%u0022" + json.escape(req.http.x-netacea:integration_mode) + "%u0022"}V,"integration_type": %{if(req.http.integration_type, "%u0022" + json.escape(req.http.integration_type) + "%u0022", "null")}V,"integration_version": %{if(req.http.integration_version, "%u0022" + json.escape(req.http.integration_version) + "%u0022", "null")}V,"method": "%{json.escape(req.method)}V","path": "%{json.escape(req.url.path)}V","mit_svc_latency":%{if(req.http.x-netacea:mit_svc_latency, "%u0022" + json.escape(req.http.x-netacea:mit_svc_latency) + "%u0022", "0")}V,"mit_status":%{if(req.http.x-netacea:mit_status, "%u0022" + json.escape(req.http.x-netacea:mit_status) + "%u0022", "0")}V,"protocol": "%{json.escape(req.proto)}V","query": "%{json.escape(req.url.qs)}V","referrer": %{if(req.http.referer, "%u0022" + json.escape(req.http.referer) + "%u0022", "null")}V,"request_time": %{time.elapsed}V,"status": "%{json.escape(resp.status)}V","user_agent": %{if(req.http.user-agent, "%u0022" + json.escape(req.http.user-agent) + "%u0022", "null")}V,"user_id": %{if(req.http.x-netacea-userid, "%u0022" + json.escape(req.http.x-netacea-userid) + "%u0022", "null")}V,"client_ja3_md5": %{if(tls.client.ja3_md5, "%u0022" + json.escape(tls.client.ja3_md5) + "%u0022", "null")}V,"x_forwarded_for": %{if(req.http.X-Forwarded-For, "%u0022" + json.escape(req.http.X-Forwarded-For) + "%u0022", "null")}V}
```

{% endcode %}

### タイムスタンプフォーマット

```
%Y-%m-%dT%H:%M:%S.000
```

### Netacea 最小データセット

上記のログフォーマットにより、Netacea は分析のために以下の最小データセットを収集できます

<table><thead><tr><th width="215">必須フィールド</th><th>説明</th></tr></thead><tbody><tr><td>Timestamp</td><td>リクエストが受信された時刻</td></tr><tr><td>IP Address</td><td>リクエストが行われた IP アドレス</td></tr><tr><td>User Agent</td><td>クライアントがヘッダーで送信したユーザーエージェント文字列</td></tr><tr><td>Method</td><td>リクエストの HTTP メソッド</td></tr><tr><td>Path</td><td>リクエストされたリソースのパス</td></tr><tr><td>Query</td><td>リクエストのクエリ文字列</td></tr><tr><td>Status</td><td>サーバーが返した HTTP ステータスコード</td></tr><tr><td>Referrer</td><td>ユーザーがリンクをたどってきた元のウェブページ</td></tr><tr><td>Bytes Sent</td><td>サーバーのレスポンスの一部として送信されたバイト数</td></tr><tr><td>Client JA3</td><td>クライアントの JA3 フィンガープリント</td></tr><tr><td>X-Forwarded-For*</td><td>クライアントリクエストの元の IP アドレス</td></tr><tr><td>Host</td><td>リクエストの宛先ホスト</td></tr><tr><td>Protocol</td><td>リクエストのプロトコル</td></tr><tr><td>Request Time</td><td>リクエストの処理にかかった合計時間</td></tr></tbody></table>

\* クライアントからオリジンへのトラフィック経路にプロキシがある場合に有用

### ログに関する考慮事項

Fastly のログ配信を設定する際、デフォルトでは静的コンテンツやメディアコンテンツを含むすべてのリクエストが S3 バケットに送信されます。このデータは Netacea には必要ありません。これを解決するには、サービスにログ条件を追加し、上記の手順で作成したログサービスにアタッチする必要があります。

#### ログ条件の追加

1. 新しく作成したログエンドポイントに移動します：

<figure><img src="/files/cUAYPDl82Q8wrEEZ3aio" alt=""><figcaption></figcaption></figure>

2. **'Create a new response condition'** をクリックします

<figure><img src="/files/qoCPpyFZnTIs6jqIj5wZ" alt=""><figcaption></figcaption></figure>

3. ポップアップウィンドウに以下の詳細を入力します

| フィールド    | 値                                                                                         |
| -------- | ----------------------------------------------------------------------------------------- |
| Name     | 例：Netacea\_Log\_Visit                                                                     |
| Apply If | (req.url !\~ "/media/" && req.url !\~ "/static/") && fastly.ff.visits\_this\_service == 0 |
| Priority | 10                                                                                        |

{% hint style="warning" %}
**'Advanced option'** セクションを展開して Priority を設定します
{% endhint %}

<figure><img src="/files/Y2DTYci89mgXsLnmifsu" alt=""><figcaption></figcaption></figure>

4. **'Save and apply'** をクリックします

### 完了

* 設定にエラーメッセージや警告がないか確認します。
* 確認後、**Activate** をクリックして変更をデプロイします。

<figure><img src="/files/9LlSo4JO0ZWSv6U6CY3u" alt=""><figcaption></figcaption></figure>

Fastly ログストリーミングの設定が有効になり、Netacea S3 バケットへのデータ送信が開始されます。

### 最終手順

ログ配信が有効になったら、**Netacea ソリューションエンジニアに通知してください**。これにより、以下のことが可能になります：

* データの受信確認
* データセットの形式と完全性の検証
* 十分な量のデータが収集された後の分析開始


---

# 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.netacea.com/jp/fastly.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.
