fluentd
分散システム全体からログを集約し、フィルタリングや変換を行い、様々な場所に転送するために、Fluentdを設定して統合的なログ収集基盤を構築するSkill。
📜 元の英語説明(参考)
Configure Fluentd for unified log collection, routing, filtering, and forwarding across distributed systems. Use when a user needs to aggregate logs from multiple sources, transform log data with filters, route logs to different destinations, or set up Fluentd as a Kubernetes log collector.
🇯🇵 日本人クリエイター向け解説
分散システム全体からログを集約し、フィルタリングや変換を行い、様々な場所に転送するために、Fluentdを設定して統合的なログ収集基盤を構築するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o fluentd.zip https://jpskill.com/download/14909.zip && unzip -o fluentd.zip && rm fluentd.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14909.zip -OutFile "$d\fluentd.zip"; Expand-Archive "$d\fluentd.zip" -DestinationPath $d -Force; ri "$d\fluentd.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
fluentd.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
fluentdフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Fluentd
概要
Fluentdを統合ロギングレイヤーとして設定し、アプリケーション、コンテナ、およびインフラストラクチャからのログを収集、フィルタリング、変換し、さまざまなバックエンドに転送します。設定、プラグイン、Kubernetes DaemonSetデプロイメント、およびバッファリング戦略について説明します。
手順
タスク A: 基本的な Fluentd 設定
<!-- fluent.conf — アプリケーションログを収集し、Elasticsearch に転送します -->
<source>
@type tail
path /var/log/app/*.log
pos_file /var/log/fluentd/app.log.pos
tag app.logs
<parse>
@type json
time_key timestamp
time_format %Y-%m-%dT%H:%M:%S.%NZ
</parse>
</source>
<source>
@type tail
path /var/log/nginx/access.log
pos_file /var/log/fluentd/nginx.log.pos
tag nginx.access
<parse>
@type regexp
expression /^(?<remote>[^ ]*) - (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+) (?<path>\S+) (?<protocol>\S+)" (?<status>\d+) (?<size>\d+)/
time_format %d/%b/%Y:%H:%M:%S %z
</parse>
</source>
<filter app.logs>
@type record_transformer
<record>
hostname "#{Socket.gethostname}"
environment production
</record>
</filter>
<filter app.logs>
@type grep
<exclude>
key level
pattern /^debug$/
</exclude>
</filter>
<match app.logs nginx.access>
@type elasticsearch
host elasticsearch
port 9200
index_name fluentd-${tag}-%Y.%m.%d
<buffer tag, time>
@type file
path /var/log/fluentd/buffer/es
timekey 1h
timekey_wait 10m
flush_interval 30s
chunk_limit_size 8MB
total_limit_size 2GB
retry_max_interval 30
overflow_action block
</buffer>
</match>
タスク B: 複数出力ルーティング
<!-- fluent.conf — タグに基づいてログを異なる宛先にルーティングします -->
<match error.**>
@type copy
<store>
@type elasticsearch
host elasticsearch
port 9200
index_name errors-%Y.%m.%d
<buffer time>
timekey 1d
flush_interval 10s
</buffer>
</store>
<store>
@type slack
webhook_url https://hooks.slack.com/services/T00/B00/XXXX
channel ops-errors
message "Error from %s: %s"
message_keys tag,message
</store>
</match>
<match audit.**>
@type s3
aws_key_id "#{ENV['AWS_ACCESS_KEY_ID']}"
aws_sec_key "#{ENV['AWS_SECRET_ACCESS_KEY']}"
s3_bucket audit-logs-production
s3_region us-east-1
path logs/%Y/%m/%d/
<buffer time>
@type file
path /var/log/fluentd/buffer/s3
timekey 3600
timekey_wait 10m
chunk_limit_size 256MB
</buffer>
<format>
@type json
</format>
</match>
<match **>
@type elasticsearch
host elasticsearch
port 9200
index_name logs-%Y.%m.%d
</match>
タスク C: Kubernetes DaemonSet デプロイメント
# fluentd-daemonset.yml — Kubernetes ログ収集用の Fluentd DaemonSet
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd
namespace: logging
labels:
app: fluentd
spec:
selector:
matchLabels:
app: fluentd
template:
metadata:
labels:
app: fluentd
spec:
serviceAccountName: fluentd
tolerations:
- key: node-role.kubernetes.io/control-plane
effect: NoSchedule
containers:
- name: fluentd
image: fluent/fluentd-kubernetes-daemonset:v1.16-debian-elasticsearch8-1
env:
- name: FLUENT_ELASTICSEARCH_HOST
value: "elasticsearch.logging.svc.cluster.local"
- name: FLUENT_ELASTICSEARCH_PORT
value: "9200"
- name: FLUENT_ELASTICSEARCH_INDEX_NAME
value: "k8s-logs"
resources:
limits:
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
volumeMounts:
- name: varlog
mountPath: /var/log
- name: containers
mountPath: /var/lib/docker/containers
readOnly: true
- name: config
mountPath: /fluentd/etc/fluent.conf
subPath: fluent.conf
volumes:
- name: varlog
hostPath:
path: /var/log
- name: containers
hostPath:
path: /var/lib/docker/containers
- name: config
configMap:
name: fluentd-config
# fluentd-configmap.yml — Kubernetes 対応の Fluentd 設定
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-config
namespace: logging
data:
fluent.conf: |
<source>
@type tail
path /var/log/containers/*.log
pos_file /var/log/fluentd-containers.log.pos
tag kubernetes.*
<parse>
@type cri
</parse>
</source>
<filter kubernetes.**>
@type kubernetes_metadata
@id filter_kube_metadata
</filter>
<filter kubernetes.**>
@type grep
<exclude>
key $.kubernetes.namespace_name
pattern /^(kube-system|logging)$/
</exclude>
</filter>
<match kubernetes.**>
@type elasticsearch
host "#{ENV['FLUENT_ELASTICSEARCH_HOST']}"
port "#{ENV['FLUENT_ELASTICSEARCH_PORT']}"
index_name k8s-${record['$.kubernetes']['namespace_name']}-%Y.%m.%d
<buffer tag, time>
@type file
path /var/log/fluentd/buffer
timekey 1h
flush_interval 30s
</buffer>
</match>
タスク D: ログの解析と変換
<!-- fluent.conf — 複数行の Java スタックトレースを解析します -->
<source>
@type tail
path /var/log/app/java-app.log
tag java.app
<parse>
@type multiline
format_firstline /^\d{4}-\d{2}-\d{2}/
format1 /^(?<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}) (?<level>\w+) \[(?<thread>[^\]]+)\] (?<class>[^ ]+) - (?<message>.*)/
</parse>
</source>
<filter java.app>
@type record_transformer
enable_ruby true
<record>
severity ${record["level"] == "ERROR" ? "error" : record["level"] == "WARN" ? "warning" : "info"}
service "java-app"
</record>
</filter>
ベストプラクティス
- ログの損失を防ぐために、本番環境ではファイルベースのバッファを使用してください。
(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Fluentd
Overview
Set up Fluentd as a unified logging layer to collect, filter, transform, and forward logs from applications, containers, and infrastructure to various backends. Covers configuration, plugins, Kubernetes DaemonSet deployment, and buffering strategies.
Instructions
Task A: Basic Fluentd Configuration
<!-- fluent.conf — Collect application logs and forward to Elasticsearch -->
<source>
@type tail
path /var/log/app/*.log
pos_file /var/log/fluentd/app.log.pos
tag app.logs
<parse>
@type json
time_key timestamp
time_format %Y-%m-%dT%H:%M:%S.%NZ
</parse>
</source>
<source>
@type tail
path /var/log/nginx/access.log
pos_file /var/log/fluentd/nginx.log.pos
tag nginx.access
<parse>
@type regexp
expression /^(?<remote>[^ ]*) - (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+) (?<path>\S+) (?<protocol>\S+)" (?<status>\d+) (?<size>\d+)/
time_format %d/%b/%Y:%H:%M:%S %z
</parse>
</source>
<filter app.logs>
@type record_transformer
<record>
hostname "#{Socket.gethostname}"
environment production
</record>
</filter>
<filter app.logs>
@type grep
<exclude>
key level
pattern /^debug$/
</exclude>
</filter>
<match app.logs nginx.access>
@type elasticsearch
host elasticsearch
port 9200
index_name fluentd-${tag}-%Y.%m.%d
<buffer tag, time>
@type file
path /var/log/fluentd/buffer/es
timekey 1h
timekey_wait 10m
flush_interval 30s
chunk_limit_size 8MB
total_limit_size 2GB
retry_max_interval 30
overflow_action block
</buffer>
</match>
Task B: Multi-Output Routing
<!-- fluent.conf — Route logs to different destinations based on tag -->
<match error.**>
@type copy
<store>
@type elasticsearch
host elasticsearch
port 9200
index_name errors-%Y.%m.%d
<buffer time>
timekey 1d
flush_interval 10s
</buffer>
</store>
<store>
@type slack
webhook_url https://hooks.slack.com/services/T00/B00/XXXX
channel ops-errors
message "Error from %s: %s"
message_keys tag,message
</store>
</match>
<match audit.**>
@type s3
aws_key_id "#{ENV['AWS_ACCESS_KEY_ID']}"
aws_sec_key "#{ENV['AWS_SECRET_ACCESS_KEY']}"
s3_bucket audit-logs-production
s3_region us-east-1
path logs/%Y/%m/%d/
<buffer time>
@type file
path /var/log/fluentd/buffer/s3
timekey 3600
timekey_wait 10m
chunk_limit_size 256MB
</buffer>
<format>
@type json
</format>
</match>
<match **>
@type elasticsearch
host elasticsearch
port 9200
index_name logs-%Y.%m.%d
</match>
Task C: Kubernetes DaemonSet Deployment
# fluentd-daemonset.yml — Fluentd DaemonSet for Kubernetes log collection
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd
namespace: logging
labels:
app: fluentd
spec:
selector:
matchLabels:
app: fluentd
template:
metadata:
labels:
app: fluentd
spec:
serviceAccountName: fluentd
tolerations:
- key: node-role.kubernetes.io/control-plane
effect: NoSchedule
containers:
- name: fluentd
image: fluent/fluentd-kubernetes-daemonset:v1.16-debian-elasticsearch8-1
env:
- name: FLUENT_ELASTICSEARCH_HOST
value: "elasticsearch.logging.svc.cluster.local"
- name: FLUENT_ELASTICSEARCH_PORT
value: "9200"
- name: FLUENT_ELASTICSEARCH_INDEX_NAME
value: "k8s-logs"
resources:
limits:
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
volumeMounts:
- name: varlog
mountPath: /var/log
- name: containers
mountPath: /var/lib/docker/containers
readOnly: true
- name: config
mountPath: /fluentd/etc/fluent.conf
subPath: fluent.conf
volumes:
- name: varlog
hostPath:
path: /var/log
- name: containers
hostPath:
path: /var/lib/docker/containers
- name: config
configMap:
name: fluentd-config
# fluentd-configmap.yml — Kubernetes-aware Fluentd configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-config
namespace: logging
data:
fluent.conf: |
<source>
@type tail
path /var/log/containers/*.log
pos_file /var/log/fluentd-containers.log.pos
tag kubernetes.*
<parse>
@type cri
</parse>
</source>
<filter kubernetes.**>
@type kubernetes_metadata
@id filter_kube_metadata
</filter>
<filter kubernetes.**>
@type grep
<exclude>
key $.kubernetes.namespace_name
pattern /^(kube-system|logging)$/
</exclude>
</filter>
<match kubernetes.**>
@type elasticsearch
host "#{ENV['FLUENT_ELASTICSEARCH_HOST']}"
port "#{ENV['FLUENT_ELASTICSEARCH_PORT']}"
index_name k8s-${record['$.kubernetes']['namespace_name']}-%Y.%m.%d
<buffer tag, time>
@type file
path /var/log/fluentd/buffer
timekey 1h
flush_interval 30s
</buffer>
</match>
Task D: Log Parsing and Transformation
<!-- fluent.conf — Parse multiline Java stack traces -->
<source>
@type tail
path /var/log/app/java-app.log
tag java.app
<parse>
@type multiline
format_firstline /^\d{4}-\d{2}-\d{2}/
format1 /^(?<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}) (?<level>\w+) \[(?<thread>[^\]]+)\] (?<class>[^ ]+) - (?<message>.*)/
</parse>
</source>
<filter java.app>
@type record_transformer
enable_ruby true
<record>
severity ${record["level"] == "ERROR" ? "error" : record["level"] == "WARN" ? "warning" : "info"}
service "java-app"
</record>
</filter>
Best Practices
- Use file-based buffers in production to prevent log loss during restarts
- Set
overflow_action blockto apply backpressure instead of dropping logs - Exclude debug-level logs early in the pipeline to reduce downstream volume
- Use
@type copyfor critical logs that need multiple destinations - Monitor Fluentd's own metrics via the
@type prometheusplugin - In Kubernetes, use Fluent Bit as a lightweight forwarder and Fluentd as an aggregator