Messaging
メッセージングシステム
📚 情報ソース
このドキュメントは以下の情報源を基に作成されています:
主要ソース
補足ソース
- メッセージングシステムのベストプラクティス: パフォーマンスチューニングとHA構成
- 実運用環境の設定例: クラスター構成とモニタリングパターン
Apache Kafka
📚 公式ドキュメント: Apache Kafka
基本設定
| com.instana.plugin.kafka:
enabled: true
poll_rate: 5 # 秒単位
|
設定項目の詳細
| 設定項目 |
説明 |
デフォルト値 |
推奨値 |
enabled |
Kafkaセンサーの有効化 |
true |
true |
poll_rate |
メトリクス収集間隔(秒) |
5 |
5-15秒 |
bootstrap_servers |
Kafkaブローカーのリスト |
- |
環境に応じて |
consumer_groups |
監視対象のコンシューマーグループ |
[] |
重要なグループを指定 |
topics |
監視対象のトピック |
[] |
重要なトピックを指定 |
高度な設定
| com.instana.plugin.kafka:
enabled: true
poll_rate: 10
# Kafkaブローカー接続
bootstrap_servers:
- "kafka-1.example.com:9092"
- "kafka-2.example.com:9092"
- "kafka-3.example.com:9092"
# 認証設定
security:
protocol: "SASL_SSL"
sasl_mechanism: "PLAIN"
sasl_username: "kafka-monitor"
sasl_password: "${KAFKA_PASSWORD}"
ssl_truststore_location: "/etc/kafka/truststore.jks"
ssl_truststore_password: "${TRUSTSTORE_PASSWORD}"
# 監視対象の指定
topics:
include:
- "orders.*"
- "payments.*"
- "notifications.*"
exclude:
- "*.test"
- "*.debug"
consumer_groups:
include:
- "order-processor"
- "payment-service"
exclude:
- "test-*"
# メトリクス設定
metrics:
lag_threshold: 1000 # ラグ閾値
collect_offsets: true
collect_consumer_metrics: true
|
認証情報の作成方法:
SASL/PLAIN認証の場合:
| # Kafka server.properties に追加
listener.security.protocol.map=SASL_SSL:SASL_SSL
sasl.enabled.mechanisms=PLAIN
sasl.mechanism.inter.broker.protocol=PLAIN
# JAAS設定ファイル作成 (/etc/kafka/kafka_server_jaas.conf)
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret"
user_admin="admin-secret"
user_kafka-monitor="monitor-password";
};
|
監視ユーザーの作成(SASL/SCRAM):
| # Zookeeperで実行
kafka-configs.sh --zookeeper localhost:2181 \
--alter --add-config 'SCRAM-SHA-256=[password=monitor-password]' \
--entity-type users --entity-name kafka-monitor
# 必要な権限を付与
kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 \
--add --allow-principal User:kafka-monitor \
--operation Read --operation Describe --topic '*'
kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 \
--add --allow-principal User:kafka-monitor \
--operation Read --operation Describe --group '*'
|
SSL証明書の作成:
| # Truststoreの作成
keytool -keystore /etc/kafka/truststore.jks \
-alias CARoot -import -file ca-cert \
-storepass truststore-password -noprompt
# ファイル権限設定
chmod 600 /etc/kafka/truststore.jks
chown instana:instana /etc/kafka/truststore.jks
|
設定値の取得方法:
| 項目 |
取得方法 |
bootstrap_servers |
Kafkaブローカーのホスト名とポート(通常9092) |
sasl_username |
上記で作成した監視ユーザー名 |
sasl_password |
監視ユーザーのパスワード(secrets.mdのVault統合推奨) |
ssl_truststore_location |
Truststoreファイルのパス |
ssl_truststore_password |
Truststoreのパスワード |
セキュリティのベストプラクティス:
- パスワードは環境変数またはVaultから取得
- 監視ユーザーには読み取り権限のみを付与
- SSL/TLS通信を有効化(本番環境必須)
- Truststoreファイルのパーミッションを600に設定
RabbitMQ
📚 公式ドキュメント: RabbitMQ
基本設定
| com.instana.plugin.rabbitmq:
enabled: true
hostname: "localhost"
port: 15672 # Management API port
username: "guest"
password: "guest"
poll_rate: 5
|
設定項目の詳細
| 設定項目 |
説明 |
デフォルト値 |
推奨値 |
enabled |
RabbitMQセンサーの有効化 |
true |
true |
hostname |
RabbitMQホスト |
localhost |
環境に応じて |
port |
Management APIポート |
15672 |
15672 |
username |
管理ユーザー名 |
guest |
専用ユーザー推奨 |
poll_rate |
メトリクス収集間隔(秒) |
5 |
5-15秒 |
認証情報の作成方法:
監視ユーザーの作成:
| # RabbitMQ Management UIまたはCLIで実行
rabbitmqctl add_user instana-monitor monitor-password
# monitoring タグを付与(読み取り専用)
rabbitmqctl set_user_tags instana-monitor monitoring
# 全てのvhostへの読み取り権限を付与
rabbitmqctl set_permissions -p / instana-monitor "^$" "^$" ".*"
# 他のvhostがある場合も同様に設定
rabbitmqctl set_permissions -p /production instana-monitor "^$" "^$" ".*"
|
Management Plugin の有効化:
| # Management Pluginが無効の場合は有効化
rabbitmq-plugins enable rabbitmq_management
# Management APIが利用可能か確認
curl -u instana-monitor:monitor-password http://localhost:15672/api/overview
|
設定値の取得方法:
| 項目 |
取得方法 |
hostname |
RabbitMQサーバーのホスト名またはIPアドレス |
port |
Management APIポート(デフォルト15672、rabbitmq.confで確認) |
username |
上記で作成した監視ユーザー名 |
password |
監視ユーザーのパスワード(secrets.mdのVault統合推奨) |
必要な権限:
- monitoring タグ: Management UIへのアクセスと統計情報の閲覧
- 読み取り権限: キュー、エクスチェンジ、バインディングの情報取得
- 設定権限は不要("^$"で拒否)
セキュリティのベストプラクティス:
- guestユーザーは使用しない(デフォルトで外部アクセス不可)
- 専用の監視ユーザーを作成し、最小権限を付与
- パスワードは環境変数またはVaultから取得
- SSL/TLS通信を有効化(本番環境推奨)
| password | パスワード | - | Vaultから取得 |
| poll_rate | メトリクス収集間隔(秒) | 5 | 5-15秒 |
| vhosts | 監視対象のvhost | ["/"] | 環境に応じて |
| use_ssl | SSL/TLS使用 | false | 本番環境ではtrue |
高度な設定
| com.instana.plugin.rabbitmq:
enabled: true
# 接続設定
hostname: "rabbitmq.example.com"
port: 15672
# 認証(Vault統合)
username: "monitoring"
password: "${vault:secret/rabbitmq#password}"
# SSL/TLS設定
use_ssl: true
ssl_verify: true
ssl_ca_cert: "/etc/ssl/certs/ca.pem"
# 監視設定
poll_rate: 10
# vhost設定
vhosts:
include:
- "/"
- "/production"
- "/staging"
exclude:
- "/test"
# キュー監視
queues:
include:
- "orders.*"
- "payments.*"
exclude:
- "*.test"
# アラート閾値
thresholds:
messages: 10000 # メッセージ数
consumers: 0 # コンシューマー数(0で警告)
memory: 1073741824 # 1GB
|
ActiveMQ Artemis
📚 公式ドキュメント: ActiveMQ Artemis
基本設定
| com.instana.plugin.activemqartemis:
enabled: true
monitorQueues: # 最大100キュー
- 'DLQ'
- 'test-queue-1'
- 'production-queue'
poll_rate: 1 # 秒単位(デフォルト1秒)
|
設定項目の詳細
| 設定項目 |
説明 |
デフォルト値 |
推奨値 |
enabled |
Artemisセンサーの有効化 |
true |
true |
monitorQueues |
監視対象キューのリスト |
[] |
重要なキューを指定 |
poll_rate |
メトリクス収集間隔(秒) |
1 |
1-5秒 |
jmx_host |
JMXホスト |
localhost |
環境に応じて |
jmx_port |
JMXポート |
1099 |
環境に応じて |
Amazon SQS
📚 公式ドキュメント: Amazon SQS
基本設定
| com.instana.plugin.aws.sqs:
enabled: true
region: "us-east-1"
poll_rate: 60 # 秒単位
|
設定項目の詳細
| 設定項目 |
説明 |
デフォルト値 |
推奨値 |
enabled |
SQSセンサーの有効化 |
true |
true |
region |
AWSリージョン |
- |
環境に応じて |
poll_rate |
メトリクス収集間隔(秒) |
60 |
60-300秒 |
queues |
監視対象キュー |
[] |
重要なキューを指定 |
access_key_id |
AWSアクセスキー |
- |
IAMロール推奨 |
secret_access_key |
AWSシークレットキー |
- |
IAMロール推奨 |
Azure Service Bus
📚 公式ドキュメント: Azure Service Bus
基本設定
| com.instana.plugin.azure.servicebus:
enabled: true
namespace: "myservicebus"
poll_rate: 60
|
Google Cloud Pub/Sub
📚 公式ドキュメント: Google Cloud Pub/Sub
基本設定
| com.instana.plugin.gcp.pubsub:
enabled: true
project_id: "my-project"
poll_rate: 60
|
TibcoEMS
📚 公式ドキュメント: TibcoEMS
基本設定
| com.instana.plugin.tibcoems:
enabled: true
hostname: '127.0.0.1'
port: '7222'
user: 'admin'
password: ''
poll_rate: 5
topicsRegex: '.*'
queuesRegex: '.*'
|
設定項目の詳細
| 設定項目 |
説明 |
デフォルト値 |
推奨値 |
enabled |
TibcoEMSセンサーの有効化 |
true |
true |
hostname |
EMSサーバーホスト |
127.0.0.1 |
環境に応じて |
port |
EMSサーバーポート |
7222 |
7222 |
user |
管理ユーザー名 |
admin |
専用ユーザー推奨 |
password |
パスワード |
- |
Vaultから取得 |
poll_rate |
メトリクス収集間隔(秒) |
5 |
5-15秒 |
topicsRegex |
監視対象トピックの正規表現 |
.* |
環境に応じて |
queuesRegex |
監視対象キューの正規表現 |
.* |
環境に応じて |
設定例:
| # 本番環境のキューのみ監視
topicsRegex: 'prod\..*'
queuesRegex: 'prod\..*'
|
Tibco ActiveSpaces
📚 公式ドキュメント: Tibco ActiveSpaces
基本設定
| com.instana.plugin.tibcoas:
enabled: true
applicationName: 'default'
user: 'admin'
password: 'admin_password'
poll_rate: 10
trustFile: '/path/to/ftl-trust.pem'
libPath: '/path/to/lib'
|
必要なファイル:
- FTL信頼証明書(trustFile)
- FTLネイティブライブラリ(libPath)
実践的な使用例
1. 本番環境のKafkaクラスタ監視
シナリオ: 3ノードのKafkaクラスタで、重要なトピックとコンシューマーグループを監視
| com.instana.plugin.kafka:
enabled: true
poll_rate: 10
# Kafkaクラスタ接続
bootstrap_servers:
- "kafka-1.prod.example.com:9092"
- "kafka-2.prod.example.com:9092"
- "kafka-3.prod.example.com:9092"
# SASL/SSL認証
security:
protocol: "SASL_SSL"
sasl_mechanism: "SCRAM-SHA-512"
sasl_username: "instana-monitor"
sasl_password: "${vault:secret/kafka#password}"
ssl_truststore_location: "/etc/kafka/truststore.jks"
ssl_truststore_password: "${vault:secret/kafka#truststore_password}"
# 重要なトピックのみ監視
topics:
include:
- "orders"
- "payments"
- "inventory"
- "notifications"
exclude:
- "*.test"
- "*.debug"
- "__consumer_offsets"
# 重要なコンシューマーグループ
consumer_groups:
include:
- "order-processor"
- "payment-service"
- "inventory-updater"
- "notification-sender"
# メトリクスとアラート
metrics:
lag_threshold: 5000
collect_offsets: true
collect_consumer_metrics: true
collect_producer_metrics: true
# タグ設定
com.instana.plugin.host:
tags:
environment: "production"
cluster: "kafka-main"
datacenter: "us-east-1"
|
2. RabbitMQクラスタのHA構成監視
シナリオ: 3ノードのRabbitMQクラスタで、ミラーキューとクラスタ状態を監視
| com.instana.plugin.rabbitmq:
enabled: true
poll_rate: 15
# クラスタノード
nodes:
- hostname: "rabbitmq-1.prod.example.com"
port: 15672
- hostname: "rabbitmq-2.prod.example.com"
port: 15672
- hostname: "rabbitmq-3.prod.example.com"
port: 15672
# 認証
username: "monitoring"
password: "${vault:secret/rabbitmq#password}"
# SSL/TLS
use_ssl: true
ssl_verify: true
ssl_ca_cert: "/etc/rabbitmq/ca.pem"
# キュー監視
queues:
include:
- "orders"
- "payments"
- "notifications"
- "*.dlq"
thresholds:
messages: 50000
consumers: 0
memory: 2147483648 # 2GB
|
3. マルチクラウドメッセージング統合監視
シナリオ: AWS SQS、Azure Service Bus、GCP Pub/Subを統合的に監視
| # AWS SQS
com.instana.plugin.aws.sqs:
enabled: true
region: "us-east-1"
poll_rate: 120
use_iam_role: true
queues:
include:
- "production-orders-*"
- "production-events-*"
tags:
Environment: "production"
Cloud: "aws"
# Azure Service Bus
com.instana.plugin.azure.servicebus:
enabled: true
poll_rate: 120
namespace: "production-servicebus"
resource_group: "production-rg"
queues:
include:
- "payments"
- "notifications"
# GCP Pub/Sub
com.instana.plugin.gcp.pubsub:
enabled: true
poll_rate: 120
project_id: "production-project"
topics:
include:
- "inventory"
- "analytics"
|
ベストプラクティス
1. パフォーマンス最適化
ポーリング間隔の最適化
| メッセージングシステム |
推奨ポーリング間隔 |
理由 |
| Kafka |
5-15秒 |
リアルタイム性が重要 |
| RabbitMQ |
5-15秒 |
キュー状態の変化が速い |
| ActiveMQ Artemis |
1-5秒 |
JMXメトリクスは軽量 |
| AWS SQS |
60-300秒 |
API呼び出しコストを考慮 |
| Azure Service Bus |
60-300秒 |
API制限を考慮 |
| GCP Pub/Sub |
60-300秒 |
API割り当てを考慮 |
2. セキュリティ
認証情報の管理
| # Vault統合(推奨)
com.instana.plugin.kafka:
security:
sasl_username: "instana-monitor"
sasl_password: "${vault:secret/kafka#password}"
ssl_truststore_password: "${vault:secret/kafka#truststore_password}"
|
最小権限の原則
Kafka ACL設定:
| # 監視用ユーザーのACL設定
kafka-acls --authorizer-properties zookeeper.connect=localhost:2181 \
--add --allow-principal User:instana-monitor \
--operation Read --topic '*'
|
RabbitMQ権限設定:
| # 監視用ユーザーの作成
rabbitmqctl add_user instana-monitor <password>
rabbitmqctl set_user_tags instana-monitor monitoring
rabbitmqctl set_permissions -p / instana-monitor "^$" "^$" ".*"
|
3. フィルタリング戦略
| # 本番環境のみ監視
com.instana.plugin.kafka:
topics:
include:
- "prod.*"
- "production.*"
exclude:
- "*.test"
- "*.dev"
- "__consumer_offsets"
|
4. アラート設定
| com.instana.plugin.kafka:
metrics:
lag_threshold: 5000
lag_alerts:
warning: 1000
critical: 5000
emergency: 10000
com.instana.plugin.rabbitmq:
queues:
thresholds:
messages:
warning: 10000
critical: 50000
consumers:
warning: 1
critical: 0
|
トラブルシューティング
問題1: Kafka接続エラー
症状:
| ERROR: Cannot connect to Kafka broker
Connection refused
|
解決方法:
| # 1. ブローカーの状態確認
kafka-broker-api-versions --bootstrap-server kafka-1:9092
# 2. ネットワーク接続確認
telnet kafka-1 9092
# 3. 認証情報確認
cat /opt/instana/agent/etc/instana/configuration.yaml | grep -A 10 kafka
|
問題2: RabbitMQ Management APIエラー
症状:
| ERROR: Failed to connect to RabbitMQ Management API
401 Unauthorized
|
解決方法:
| # 1. Management APIの有効化確認
rabbitmq-plugins list | grep management
# 2. ユーザー権限確認
rabbitmqctl list_users
# 3. Management APIテスト
curl -u monitoring:password http://localhost:15672/api/overview
|
問題3: メッセージラグが増加
症状:
- Kafkaコンシューマーラグが増加し続ける
- メッセージ処理が追いつかない
解決方法:
| # コンシューマーグループの確認
kafka-consumer-groups --bootstrap-server kafka-1:9092 \
--group order-processor --describe
# 設定の最適化
com.instana.plugin.kafka:
consumer_groups:
- "order-processor"
metrics:
lag_threshold: 5000
lag_alerts:
critical: 5000
|
問題4: クラウドメッセージングのAPI制限
症状:
| ERROR: AWS SQS API rate limit exceeded
ThrottlingException
|
解決方法:
| # ポーリング間隔を延ばす
com.instana.plugin.aws.sqs:
poll_rate: 300 # 5分に延長
# バッチ処理を有効化
batch:
enabled: true
size: 10
|
FAQ
Q1: Kafkaの全トピックを監視すべきですか?
A: いいえ、重要なトピックのみを監視することを推奨します。
| com.instana.plugin.kafka:
topics:
include:
- "orders"
- "payments"
- "critical-*"
exclude:
- "*.test"
- "__consumer_offsets"
|
Q2: メッセージラグの適切な閾値は?
A: アプリケーションの要件に依存しますが、一般的な目安:
| システムタイプ |
推奨閾値 |
| リアルタイム処理 |
100-1000 |
| 準リアルタイム |
1000-5000 |
| バッチ処理 |
5000-10000 |
Q3: クラウドメッセージングサービスのコスト最適化は?
A: ポーリング間隔を調整してAPI呼び出しを削減:
| # コスト最適化設定
com.instana.plugin.aws.sqs:
poll_rate: 300 # 5分
com.instana.plugin.azure.servicebus:
poll_rate: 300
com.instana.plugin.gcp.pubsub:
poll_rate: 300
|
Q4: RabbitMQのDead Letter Queueを監視すべきですか?
A: はい、DLQは必ず監視すべきです:
| com.instana.plugin.rabbitmq:
queues:
include:
- "*.dlq"
- "DLQ"
thresholds:
messages: 1 # 1メッセージでもアラート
|
参考リンク
公式ドキュメント