Process
プロセス管理
📚 情報ソース
このドキュメントは以下の情報源を基に作成されています:
主要ソース
補足ソース
- プロセス管理のベストプラクティス: 除外パターンとカスタム監視
- 実運用環境の設定例: 大規模環境でのプロセスフィルタリング戦略
プロセスの除外
📚 公式ドキュメント: プロセスの除外
基本設定
| com.instana.ignore:
processes:
- 'java'
- 'httpd'
- 'backup_script'
- 'temp_worker'
arguments:
- '-batch-file=/tmp/batch.def'
- '--maintenance-mode'
- '/opt/scripts/cleanup.sh'
|
設定項目の詳細
| 項目 |
説明 |
使用例 |
processes |
除外するプロセス名のリスト |
プロセス名を完全一致で指定 |
arguments |
除外する引数のリスト |
特定の引数を持つプロセスのみ除外 |
高度な設定
| com.instana.ignore:
# プロセス名で除外
processes:
- 'java'
- 'python'
- 'node'
- 'bash'
- 'sh'
# 引数で除外(より詳細な制御)
arguments:
# バッチジョブ
- '-Dapp.name=batch-processor'
- '-Dapp.type=scheduled-job'
# スクリプト
- '/opt/backup/daily-backup.sh'
- '/opt/maintenance/cleanup.sh'
# 一時プロセス
- '--temp-worker'
- '--one-time-task'
# 正規表現で除外
regex:
processes:
- '^test-.*'
- '.*-temp$'
- '.*backup.*'
arguments:
- '.*\.test\..*'
- '/tmp/.*'
|
設定値の取得方法:
| 項目 |
取得方法 |
processes |
Linux: ps aux または top、Windows: タスクマネージャー |
arguments |
Linux: ps aux | grep <プロセス名>、Windows: wmic process get commandline |
重要な注意点:
- ⚠️ Windows環境ではプロセス名は大文字小文字を区別します
- プロセス名だけでは不十分な場合、argumentsで引数を指定
- 同じコマンドでも引数が異なれば別プロセスとして扱える
カスタムプロセス監視
📚 公式ドキュメント: カスタムプロセス監視
基本設定
| com.instana.plugin.process:
env_vars_enabled: true
poll_rate: 3
processes:
- 'sshd'
- 'custom_daemon'
arguments:
- '/opt/script.sh'
services:
- 'nginx'
- 'windows-service'
|
設定項目の詳細
| 項目 |
説明 |
デフォルト値 |
推奨値 |
env_vars_enabled |
環境変数の収集 |
false |
true |
poll_rate |
メトリクス収集間隔(秒) |
3 |
3-10秒 |
processes |
監視対象プロセス名 |
[] |
重要なプロセスを指定 |
arguments |
監視対象引数 |
[] |
必要に応じて |
services |
監視対象サービス |
[] |
重要なサービスを指定 |
高度な設定
| com.instana.plugin.process:
# 基本設定
enabled: true
env_vars_enabled: true
poll_rate: 5
# プロセス監視
processes:
- name: 'nginx'
cmdline: '.*nginx: master process.*'
collect_cpu: true
collect_memory: true
collect_io: true
collect_threads: true
collect_file_descriptors: true
- name: 'postgresql'
cmdline: '.*postgres.*'
collect_cpu: true
collect_memory: true
collect_io: true
- name: 'redis'
cmdline: '.*redis-server.*'
collect_cpu: true
collect_memory: true
# 引数ベースの監視
arguments:
- pattern: '/opt/myapp/bin/server'
name: 'MyApp Server'
collect_all: true
# サービス監視
services:
- name: 'nginx'
check_status: true
restart_on_failure: false
- name: 'postgresql'
check_status: true
restart_on_failure: false
# アラート設定
alerts:
process_down:
enabled: true
critical_processes:
- 'nginx'
- 'postgresql'
- 'redis'
high_cpu:
threshold: 80 # %
duration: 300 # 秒
high_memory:
threshold: 80 # %
duration: 300
high_file_descriptors:
threshold: 90 # %
duration: 60
# フィルタリング
filters:
exclude:
- cmdline: '.*grep.*'
- cmdline: '.*ps aux.*'
- name: 'systemd'
|
設定値の取得方法:
| 項目 |
取得方法 |
processes |
監視したいプロセス名をps auxで確認 |
services |
Linux: systemctl list-units --type=service、Windows: services.msc |
実践的な使用例
1. Webサーバーのプロセス監視
シナリオ: Nginx、PHP-FPM、Redisのプロセスを詳細に監視
| com.instana.plugin.process:
enabled: true
env_vars_enabled: true
poll_rate: 5
# Nginxマスタープロセス
processes:
- name: 'nginx-master'
cmdline: '.*nginx: master process.*'
collect_cpu: true
collect_memory: true
collect_threads: true
collect_file_descriptors: true
# アラート設定
alerts:
high_cpu:
threshold: 70
duration: 300
high_memory:
threshold: 80
duration: 300
high_file_descriptors:
threshold: 85
duration: 60
# PHP-FPMマスタープロセス
- name: 'php-fpm-master'
cmdline: '.*php-fpm: master process.*'
collect_cpu: true
collect_memory: true
collect_threads: true
alerts:
high_memory:
threshold: 85
duration: 300
# Redisサーバー
- name: 'redis-server'
cmdline: '.*redis-server.*'
collect_cpu: true
collect_memory: true
collect_io: true
alerts:
high_memory:
threshold: 90
duration: 300
# サービス監視
services:
- name: 'nginx'
check_status: true
- name: 'php-fpm'
check_status: true
- name: 'redis'
check_status: true
# プロセスダウンアラート
alerts:
process_down:
enabled: true
critical_processes:
- 'nginx-master'
- 'php-fpm-master'
- 'redis-server'
# 不要なプロセスを除外
com.instana.ignore:
processes:
- 'grep'
- 'ps'
arguments:
- '/tmp/.*'
|
2. データベースサーバーのプロセス監視
シナリオ: PostgreSQL、pgBouncer、Patroniのプロセスを監視
| com.instana.plugin.process:
enabled: true
env_vars_enabled: true
poll_rate: 5
# PostgreSQLメインプロセス
processes:
- name: 'postgresql'
cmdline: '.*postgres -D.*'
collect_cpu: true
collect_memory: true
collect_io: true
collect_threads: true
collect_file_descriptors: true
# データベース特有のアラート
alerts:
high_cpu:
threshold: 85
duration: 600 # 10分
high_memory:
threshold: 95 # データベースは高メモリ使用が正常
duration: 600
high_io:
threshold: 1000 # MB/s
duration: 300
high_file_descriptors:
threshold: 90
duration: 60
# pgBouncer(コネクションプーラー)
- name: 'pgbouncer'
cmdline: '.*pgbouncer.*'
collect_cpu: true
collect_memory: true
collect_threads: true
alerts:
high_connections:
threshold: 900 # max_client_conn の90%
duration: 60
# Patroni(HAクラスタ管理)
- name: 'patroni'
cmdline: '.*patroni.*'
collect_cpu: true
collect_memory: true
# サービス監視
services:
- name: 'postgresql'
check_status: true
- name: 'pgbouncer'
check_status: true
- name: 'patroni'
check_status: true
# プロセスダウンアラート
alerts:
process_down:
enabled: true
critical_processes:
- 'postgresql'
- 'pgbouncer'
- 'patroni'
# バックアップスクリプトを除外
com.instana.ignore:
processes:
- 'bash'
- 'sh'
arguments:
- '/opt/backup/pg_dump.sh'
- '/opt/backup/pg_basebackup.sh'
|
3. Javaアプリケーションのプロセス監視
シナリオ: 複数のJavaアプリケーションを個別に監視
| com.instana.plugin.process:
enabled: true
env_vars_enabled: true
poll_rate: 5
# アプリケーション1: Webアプリ
processes:
- name: 'webapp'
cmdline: '.*java.*-Dapp.name=webapp.*'
collect_cpu: true
collect_memory: true
collect_threads: true
collect_gc: true
# JVM特有のメトリクス
jvm:
collect_heap: true
collect_non_heap: true
collect_gc_time: true
collect_thread_count: true
alerts:
high_cpu:
threshold: 80
duration: 300
high_memory:
threshold: 85
duration: 300
high_gc_time:
threshold: 30 # %
duration: 60
# アプリケーション2: バッチ処理
- name: 'batch-processor'
cmdline: '.*java.*-Dapp.name=batch-processor.*'
collect_cpu: true
collect_memory: true
collect_threads: true
# バッチ処理は高CPU使用が正常
alerts:
high_cpu:
threshold: 95
duration: 600
# アプリケーション3: APIサーバー
- name: 'api-server'
cmdline: '.*java.*-Dapp.name=api-server.*'
collect_cpu: true
collect_memory: true
collect_threads: true
collect_file_descriptors: true
alerts:
high_threads:
threshold: 500
duration: 300
high_file_descriptors:
threshold: 90
duration: 60
# テストアプリケーションを除外
com.instana.ignore:
processes:
- 'java'
arguments:
- '-Dapp.name=test-.*'
- '-Dapp.env=development'
|
4. Kubernetesノードのプロセス監視
シナリオ: Kubernetesコンポーネントとコンテナランタイムを監視
| com.instana.plugin.process:
enabled: true
env_vars_enabled: true
poll_rate: 5
# Kubeletプロセス
processes:
- name: 'kubelet'
cmdline: '.*kubelet.*'
collect_cpu: true
collect_memory: true
collect_threads: true
collect_file_descriptors: true
alerts:
high_cpu:
threshold: 80
duration: 300
high_memory:
threshold: 85
duration: 300
# kube-proxy
- name: 'kube-proxy'
cmdline: '.*kube-proxy.*'
collect_cpu: true
collect_memory: true
# containerd
- name: 'containerd'
cmdline: '.*containerd.*'
collect_cpu: true
collect_memory: true
collect_io: true
collect_file_descriptors: true
alerts:
high_file_descriptors:
threshold: 85
duration: 60
# containerd-shim(コンテナごと)
- name: 'containerd-shim'
cmdline: '.*containerd-shim.*'
collect_cpu: true
collect_memory: true
# 多数のshimプロセスが存在するため、集計のみ
aggregate: true
# サービス監視
services:
- name: 'kubelet'
check_status: true
- name: 'containerd'
check_status: true
# プロセスダウンアラート
alerts:
process_down:
enabled: true
critical_processes:
- 'kubelet'
- 'containerd'
# 一時的なコンテナプロセスを除外
com.instana.ignore:
regex:
processes:
- '^pause$'
arguments:
- '/pause'
|
5. Windowsサーバーのプロセス監視
シナリオ: IIS、SQL Server、カスタムWindowsサービスを監視
| com.instana.plugin.process:
enabled: true
env_vars_enabled: true
poll_rate: 5
# IISワーカープロセス
processes:
- name: 'w3wp.exe'
cmdline: '.*w3wp.exe.*'
collect_cpu: true
collect_memory: true
collect_threads: true
collect_handles: true # Windows特有
alerts:
high_cpu:
threshold: 80
duration: 300
high_memory:
threshold: 85
duration: 300
high_handles:
threshold: 10000
duration: 60
# SQL Serverプロセス
- name: 'sqlservr.exe'
cmdline: '.*sqlservr.exe.*'
collect_cpu: true
collect_memory: true
collect_threads: true
collect_io: true
alerts:
high_cpu:
threshold: 90
duration: 600
high_memory:
threshold: 95
duration: 600
# カスタムWindowsサービス
- name: 'MyService.exe'
cmdline: '.*MyService.exe.*'
collect_cpu: true
collect_memory: true
# Windowsサービス監視
services:
- name: 'W3SVC' # IIS
check_status: true
- name: 'MSSQLSERVER' # SQL Server
check_status: true
- name: 'MyCustomService'
check_status: true
# プロセスダウンアラート
alerts:
process_down:
enabled: true
critical_processes:
- 'w3wp.exe'
- 'sqlservr.exe'
- 'MyService.exe'
# PowerShellスクリプトを除外
com.instana.ignore:
processes:
- 'powershell.exe'
- 'cmd.exe'
arguments:
- 'C:\\Scripts\\maintenance.ps1'
- 'C:\\Scripts\\backup.bat'
|
ベストプラクティス
1. プロセス監視の優先順位
重要度別の監視設定
Critical(必須監視):
| com.instana.plugin.process:
processes:
# データベース
- name: 'postgresql'
cmdline: '.*postgres.*'
collect_all: true
alerts:
process_down:
severity: 'critical'
# Webサーバー
- name: 'nginx'
cmdline: '.*nginx: master.*'
collect_all: true
alerts:
process_down:
severity: 'critical'
|
High(重要監視):
| com.instana.plugin.process:
processes:
# キャッシュ
- name: 'redis'
cmdline: '.*redis-server.*'
collect_cpu: true
collect_memory: true
alerts:
process_down:
severity: 'high'
|
Medium(標準監視):
| com.instana.plugin.process:
processes:
# バックグラウンドワーカー
- name: 'worker'
cmdline: '.*worker.*'
collect_cpu: true
collect_memory: true
alerts:
process_down:
severity: 'medium'
|
2. メトリクス収集の最適化
収集間隔の調整
| プロセスタイプ |
推奨間隔 |
理由 |
| Webサーバー |
3-5秒 |
リアルタイム性が重要 |
| データベース |
5-10秒 |
安定した監視 |
| バッチジョブ |
10-30秒 |
変動が緩やか |
| バックグラウンドワーカー |
10-30秒 |
変動が緩やか |
| # 高頻度監視(Webサーバー)
com.instana.plugin.process:
poll_rate: 3
processes:
- name: 'nginx'
cmdline: '.*nginx.*'
# 標準監視(データベース)
com.instana.plugin.process:
poll_rate: 5
processes:
- name: 'postgresql'
cmdline: '.*postgres.*'
# 低頻度監視(バッチジョブ)
com.instana.plugin.process:
poll_rate: 30
processes:
- name: 'batch-job'
cmdline: '.*batch.*'
|
3. プロセス除外戦略
除外すべきプロセス
| com.instana.ignore:
# システムプロセス
processes:
- 'systemd'
- 'init'
- 'kthreadd'
# 一時プロセス
regex:
processes:
- '^grep$'
- '^ps$'
- '^top$'
- '.*-temp$'
# スクリプト
arguments:
- '/tmp/.*'
- '.*\.test\..*'
- '/opt/backup/.*'
|
4. アラート閾値の設定
プロセスタイプ別の推奨閾値
Webサーバー(Nginx):
| com.instana.plugin.process:
processes:
- name: 'nginx'
alerts:
high_cpu:
threshold: 70
duration: 300
high_memory:
threshold: 80
duration: 300
high_file_descriptors:
threshold: 85
duration: 60
|
データベース(PostgreSQL):
| com.instana.plugin.process:
processes:
- name: 'postgresql'
alerts:
high_cpu:
threshold: 85
duration: 600
high_memory:
threshold: 95
duration: 600
high_io:
threshold: 1000 # MB/s
duration: 300
|
Javaアプリケーション:
| com.instana.plugin.process:
processes:
- name: 'java-app'
alerts:
high_cpu:
threshold: 80
duration: 300
high_memory:
threshold: 85
duration: 300
high_gc_time:
threshold: 30 # %
duration: 60
high_threads:
threshold: 500
duration: 300
|
5. 環境変数の収集
重要な環境変数のみ収集
| com.instana.plugin.process:
env_vars_enabled: true
# 収集する環境変数
env_vars:
include:
- 'PATH'
- 'JAVA_HOME'
- 'NODE_ENV'
- 'APP_ENV'
- 'DATABASE_URL'
# 機密情報を除外
exclude:
- '*PASSWORD*'
- '*SECRET*'
- '*TOKEN*'
- '*API_KEY*'
|
トラブルシューティング
問題1: プロセスが検出されない
症状:
- 実行中のプロセスがInstanaに表示されない
- プロセスメトリクスが収集されない
原因:
- プロセス名が間違っている
- 正規表現が間違っている
- プロセスが除外されている
解決方法:
| # 1. プロセスを確認
ps aux | grep nginx
ps -eo pid,cmd | grep nginx
# 2. プロセスのコマンドラインを確認
cat /proc/<PID>/cmdline
# 3. 設定を更新
cat > /opt/instana/agent/etc/instana/configuration.yaml <<EOF
com.instana.plugin.process:
enabled: true
processes:
- name: 'nginx'
cmdline: '.*nginx: master process.*'
collect_cpu: true
collect_memory: true
EOF
# 4. エージェントを再起動
systemctl restart instana-agent
# 5. プロセスメトリクスを確認
curl http://localhost:42699/com.instana.plugin.process/processes
|
問題2: プロセスメトリクスが不完全
症状:
- CPUメトリクスは表示されるがメモリメトリクスが表示されない
- 一部のメトリクスが欠落している
原因:
- メトリクス収集が無効化されている
- 権限が不足している
解決方法:
| # 1. 権限を確認
ls -l /proc/<PID>/
# 2. 設定を更新
cat > /opt/instana/agent/etc/instana/configuration.yaml <<EOF
com.instana.plugin.process:
enabled: true
processes:
- name: 'nginx'
cmdline: '.*nginx.*'
collect_cpu: true
collect_memory: true
collect_io: true
collect_threads: true
collect_file_descriptors: true
EOF
# 3. エージェントを再起動
systemctl restart instana-agent
# 4. ログを確認
tail -f /opt/instana/agent/data/log/agent.log | grep -i process
|
問題3: プロセスダウンアラートが発生しない
症状:
- プロセスが停止してもアラートが発生しない
- プロセス監視が動作していない
原因:
- アラート設定が無効化されている
- プロセス名が間違っている
解決方法:
| # 設定を更新
com.instana.plugin.process:
enabled: true
processes:
- name: 'nginx'
cmdline: '.*nginx: master process.*'
collect_cpu: true
collect_memory: true
# プロセスダウンアラート
alerts:
process_down:
enabled: true
critical_processes:
- 'nginx'
# アラート設定
check_interval: 30 # 秒
grace_period: 60 # 秒
|
問題4: 除外設定が効かない
症状:
- 除外したプロセスが表示される
- 不要なプロセスが監視されている
原因:
- 除外パターンが間違っている
- 設定の優先順位が間違っている
解決方法:
| # 1. プロセスのコマンドラインを確認
ps aux | grep backup
# 2. 設定を更新
cat > /opt/instana/agent/etc/instana/configuration.yaml <<EOF
com.instana.ignore:
# プロセス名で除外
processes:
- 'bash'
- 'sh'
# 引数で除外
arguments:
- '/opt/backup/daily-backup.sh'
- '/opt/backup/weekly-backup.sh'
# 正規表現で除外
regex:
processes:
- '^test-.*'
- '.*-temp$'
arguments:
- '/tmp/.*'
- '.*\.test\..*'
EOF
# 3. エージェントを再起動
systemctl restart instana-agent
# 4. 除外されたプロセスを確認
curl http://localhost:42699/com.instana.ignore/processes
|
問題5: 環境変数が収集されない
症状:
- プロセスの環境変数が表示されない
- 環境変数メトリクスが欠落している
原因:
- 環境変数収集が無効化されている
- 権限が不足している
解決方法:
| # 1. 環境変数を確認
cat /proc/<PID>/environ | tr '\0' '\n'
# 2. 権限を確認
ls -l /proc/<PID>/environ
# 3. 設定を更新
cat > /opt/instana/agent/etc/instana/configuration.yaml <<EOF
com.instana.plugin.process:
enabled: true
env_vars_enabled: true
# 収集する環境変数
env_vars:
include:
- 'PATH'
- 'JAVA_HOME'
- 'NODE_ENV'
# 機密情報を除外
exclude:
- '*PASSWORD*'
- '*SECRET*'
- '*TOKEN*'
EOF
# 4. エージェントを再起動
systemctl restart instana-agent
|
FAQ
Q1: 全てのプロセスを監視すべきですか?
A: いいえ、重要なプロセスのみを監視すべきです。
| # 推奨設定
com.instana.plugin.process:
processes:
- 'nginx'
- 'postgresql'
- 'redis'
# 除外
com.instana.ignore:
processes:
- 'grep'
- 'ps'
- 'systemd'
|
Q2: プロセス監視のオーバーヘッドは?
A: 一般的に1-2%のCPUオーバーヘッドです。
| 監視対象プロセス数 |
オーバーヘッド |
| <10 |
<1% |
| 10-50 |
1-2% |
| 50-100 |
2-3% |
| >100 |
3-5% |
Q3: Javaプロセスの個別監視は?
A: 引数で区別できます。
| com.instana.plugin.process:
processes:
- name: 'webapp'
cmdline: '.*java.*-Dapp.name=webapp.*'
- name: 'batch'
cmdline: '.*java.*-Dapp.name=batch.*'
|
Q4: コンテナ内のプロセスも監視できますか?
A: はい、ホストから見えるプロセスは全て監視できます。
| com.instana.plugin.process:
processes:
- name: 'nginx'
cmdline: '.*nginx.*' # コンテナ内のnginxも含む
|
Q5: プロセスダウンアラートの遅延は?
A: check_intervalとgrace_periodで調整できます。
| com.instana.plugin.process:
alerts:
process_down:
check_interval: 30 # 30秒ごとにチェック
grace_period: 60 # 60秒後にアラート
|
Q6: Windowsサービスの監視は?
A: はい、サービス名で監視できます。
| com.instana.plugin.process:
services:
- 'W3SVC' # IIS
- 'MSSQLSERVER' # SQL Server
|
Q7: 環境変数の機密情報を除外できますか?
A: はい、除外パターンを設定できます。
| com.instana.plugin.process:
env_vars:
exclude:
- '*PASSWORD*'
- '*SECRET*'
- '*TOKEN*'
- '*API_KEY*'
|
参考リンク
公式ドキュメント