Skip to content

Network

ネットワーク・プロキシ


📚 情報ソース

このドキュメントは以下の情報源を基に作成されています:

主要ソース

補足ソース

  • ロードバランサー/プロキシのベストプラクティス: メトリクス収集とヘルスチェック
  • 実運用環境の設定例: HA構成とAPI Gateway統合パターン

HAProxy

📚 公式ドキュメント: HAProxy

HAProxyは高性能なロードバランサー・プロキシサーバーです。Instana AgentはHAProxyの統計情報を収集し、フロントエンド/バックエンドのパフォーマンスを監視します。

基本設定

com.instana.plugin.haproxy:
  poll_rate: 10  # 秒単位(デフォルト1秒)

設定項目の詳細

項目 説明 デフォルト値 推奨値 取得方法
poll_rate メトリクス収集間隔 1 10 秒単位
stats_url 統計ページURL http://localhost/haproxy?stats;csv 環境に応じて HAProxy設定から
username Basic認証ユーザー名 - 監視用ユーザー HAProxy設定から
password Basic認証パスワード - Vault推奨 HAProxy設定から

実践的な使用例

1. 基本的なHAProxy監視

1
2
3
com.instana.plugin.haproxy:
  poll_rate: 10
  stats_url: 'http://localhost:8080/haproxy?stats;csv'

HAProxy設定(haproxy.cfg):

1
2
3
4
5
listen stats
    bind *:8080
    stats enable
    stats uri /haproxy?stats
    stats refresh 30s

2. Basic認証付きHAProxy

1
2
3
4
5
com.instana.plugin.haproxy:
  poll_rate: 10
  stats_url: 'http://localhost:8080/haproxy?stats;csv'
  username: 'monitoring'
  password: 'haproxy_password'

HAProxy設定:

1
2
3
4
5
6
listen stats
    bind *:8080
    stats enable
    stats uri /haproxy?stats
    stats auth monitoring:haproxy_password
    stats refresh 30s

3. Vault統合

com.instana.plugin.haproxy:
  poll_rate: 10
  stats_url: 'http://localhost:8080/haproxy?stats;csv'
  username: 'monitoring'
  password:
    configuration_from:
      type: vault
      secret_key:
        path: secret/haproxy
        key: stats_password

4. 複数HAProxyインスタンス

com.instana.plugin.haproxy:
  instances:
    - name: 'haproxy-frontend'
      stats_url: 'http://localhost:8080/haproxy?stats;csv'
      username: 'monitoring'
      password: 'frontend_password'
      poll_rate: 5

    - name: 'haproxy-backend'
      stats_url: 'http://localhost:8081/haproxy?stats;csv'
      username: 'monitoring'
      password: 'backend_password'
      poll_rate: 10

5. SSL/TLS接続

1
2
3
4
5
6
7
com.instana.plugin.haproxy:
  poll_rate: 10
  stats_url: 'https://haproxy.example.com:8443/haproxy?stats;csv'
  username: 'monitoring'
  password: 'haproxy_password'
  ssl_verify: true
  ssl_ca_cert: '/etc/ssl/certs/ca-bundle.crt'

ベストプラクティス

セキュリティ

  1. 専用の統計ポートを使用

    1
    2
    3
    4
    5
    6
    # HAProxy設定
    listen stats
        bind 127.0.0.1:8080  # ローカルホストのみ
        stats enable
        stats uri /haproxy?stats
        stats auth monitoring:secure_password
    

  2. Vault統合

    1
    2
    3
    4
    5
    6
    7
    8
    com.instana.plugin.haproxy:
      username: 'monitoring'
      password:
        configuration_from:
          type: vault
          secret_key:
            path: secret/haproxy
            key: stats_password
    

  3. アクセス制限

    1
    2
    3
    4
    5
    6
    7
    8
    # HAProxy設定
    listen stats
        bind *:8080
        stats enable
        stats uri /haproxy?stats
        stats auth monitoring:password
        acl allowed_ips src 10.0.0.0/8 192.168.0.0/16
        http-request deny unless allowed_ips
    

パフォーマンス

  1. 適切なポーリング間隔

    # 高負荷環境
    com.instana.plugin.haproxy:
      poll_rate: 5  # 5秒
    
    # 通常環境
    com.instana.plugin.haproxy:
      poll_rate: 10  # 10秒
    
    # 低負荷環境
    com.instana.plugin.haproxy:
      poll_rate: 30  # 30秒
    

  2. 統計ページの最適化

    1
    2
    3
    4
    5
    6
    7
    8
    # HAProxy設定
    listen stats
        bind *:8080
        stats enable
        stats uri /haproxy?stats
        stats refresh 30s  # リフレッシュ間隔
        stats show-legends
        stats show-node
    

トラブルシューティング

問題1: 統計情報が取得できない

症状: - HAProxyメトリクスが表示されない - 接続エラー

原因と解決策:

  1. 統計ページの確認

    1
    2
    3
    4
    5
    # 統計ページにアクセスできるか確認
    curl http://localhost:8080/haproxy?stats;csv
    
    # 認証が必要な場合
    curl -u monitoring:password http://localhost:8080/haproxy?stats;csv
    

  2. HAProxy設定の確認

    1
    2
    3
    4
    5
    # HAProxy設定を確認
    cat /etc/haproxy/haproxy.cfg | grep -A 10 "listen stats"
    
    # HAProxyを再起動
    systemctl restart haproxy
    

  3. ファイアウォール設定

    1
    2
    3
    4
    5
    6
    # ポートが開いているか確認
    netstat -tlnp | grep 8080
    
    # ファイアウォールルールを追加
    firewall-cmd --add-port=8080/tcp --permanent
    firewall-cmd --reload
    

問題2: 認証エラー

症状: - 401 Unauthorized エラー - 認証失敗

原因と解決策:

  1. 認証情報の確認

    1
    2
    3
    4
    # 正しい認証情報を設定
    com.instana.plugin.haproxy:
      username: 'monitoring'
      password: 'correct_password'
    

  2. HAProxy設定の確認

    1
    2
    3
    # haproxy.cfg
    listen stats
        stats auth monitoring:correct_password
    

問題3: メトリクスが不完全

症状: - 一部のメトリクスのみ表示される - フロントエンド/バックエンド情報が欠落

原因と解決策:

  1. CSV形式の確認

    1
    2
    3
    4
    # CSV形式で統計情報を取得
    curl -u monitoring:password 'http://localhost:8080/haproxy?stats;csv'
    
    # 出力を確認
    

  2. HAProxy設定の確認

    1
    2
    3
    4
    5
    6
    7
    # すべての統計を有効化
    listen stats
        stats enable
        stats uri /haproxy?stats
        stats show-legends
        stats show-node
        stats show-desc
    

FAQ

Q1: HAProxyのどのバージョンがサポートされていますか?

A: HAProxy 1.5以降がサポートされています。最新バージョンの使用を推奨します。

# バージョン確認
haproxy -v

Q2: 統計ページのURLはどこで確認できますか?

A: HAProxy設定ファイル(haproxy.cfg)のlisten statsセクションで確認できます。

# 設定ファイルを確認
grep -A 5 "listen stats" /etc/haproxy/haproxy.cfg

デフォルトはhttp://localhost/haproxy?statsですが、環境によって異なります。

Q3: 複数のHAProxyインスタンスを監視できますか?

A: はい、複数のインスタンスを監視できます。

1
2
3
4
5
6
7
8
com.instana.plugin.haproxy:
  instances:
    - name: 'haproxy-1'
      stats_url: 'http://haproxy1:8080/haproxy?stats;csv'
      poll_rate: 10
    - name: 'haproxy-2'
      stats_url: 'http://haproxy2:8080/haproxy?stats;csv'
      poll_rate: 10

Q4: Dockerコンテナ内のHAProxyを監視できますか?

A: はい、コンテナのポートをホストにマッピングすれば監視できます。

# Docker Compose例
services:
  haproxy:
    image: haproxy:latest
    ports:
      - "8080:8080"  # 統計ポート

# Instana設定
com.instana.plugin.haproxy:
  stats_url: 'http://localhost:8080/haproxy?stats;csv'

Traefik

📚 公式ドキュメント: Traefik

Traefikは現代的なHTTPリバースプロキシ・ロードバランサーで、特にコンテナ環境で人気があります。

基本設定

1
2
3
com.instana.plugin.traefik:
  enabled: true
  poll_rate: 1  # 秒単位

設定項目の詳細

項目 説明 デフォルト値 推奨値 取得方法
enabled センサーの有効化 false true -
poll_rate メトリクス収集間隔 1 1-10 秒単位
metrics_url メトリクスエンドポイント http://localhost:8080/metrics 環境に応じて Traefik設定から

実践的な使用例

1. 基本的なTraefik監視

1
2
3
4
com.instana.plugin.traefik:
  enabled: true
  poll_rate: 1
  metrics_url: 'http://localhost:8080/metrics'

Traefik設定(traefik.yml):

1
2
3
4
5
6
7
metrics:
  prometheus:
    entryPoint: metrics

entryPoints:
  metrics:
    address: ":8080"

2. Kubernetes環境

1
2
3
4
com.instana.plugin.traefik:
  enabled: true
  poll_rate: 5
  metrics_url: 'http://traefik.kube-system.svc.cluster.local:8080/metrics'

3. Docker Swarm環境

1
2
3
4
com.instana.plugin.traefik:
  enabled: true
  poll_rate: 1
  metrics_url: 'http://traefik:8080/metrics'

Kong API Gateway

📚 公式ドキュメント: Kong API Gateway

KongはマイクロサービスAPI向けの高性能なAPIゲートウェイです。

基本設定

1
2
3
com.instana.plugin.kong:
  enabled: true
  poll_rate: 10  # 秒単位

設定項目の詳細

項目 説明 デフォルト値 推奨値 取得方法
enabled センサーの有効化 false true -
poll_rate メトリクス収集間隔 10 10-30 秒単位
admin_url Admin APIのURL http://localhost:8001 環境に応じて Kong設定から
admin_token Admin API認証トークン - Vault推奨 Kong設定から

実践的な使用例

1. 基本的なKong監視

1
2
3
4
com.instana.plugin.kong:
  enabled: true
  poll_rate: 10
  admin_url: 'http://localhost:8001'

2. 認証付きKong

1
2
3
4
5
com.instana.plugin.kong:
  enabled: true
  poll_rate: 10
  admin_url: 'http://kong-admin:8001'
  admin_token: 'kong_admin_token'

3. Vault統合

com.instana.plugin.kong:
  enabled: true
  poll_rate: 10
  admin_url: 'http://kong-admin:8001'
  admin_token:
    configuration_from:
      type: vault
      secret_key:
        path: secret/kong
        key: admin_token

4. Kubernetes環境

1
2
3
4
com.instana.plugin.kong:
  enabled: true
  poll_rate: 10
  admin_url: 'http://kong-admin.kong-system.svc.cluster.local:8001'

5. Kong Enterprise

1
2
3
4
5
6
7
com.instana.plugin.kong:
  enabled: true
  poll_rate: 10
  admin_url: 'https://kong-admin.example.com:8444'
  admin_token: 'enterprise_token'
  ssl_verify: true
  ssl_ca_cert: '/etc/ssl/certs/ca-bundle.crt'

ベストプラクティス

セキュリティ

  1. Admin APIのアクセス制限

    1
    2
    3
    4
    5
    # Kong設定(kong.conf)
    admin_listen = 127.0.0.1:8001
    
    # または特定のネットワークのみ
    admin_listen = 10.0.0.0/8:8001
    

  2. RBAC(Role-Based Access Control)の使用

    1
    2
    3
    4
    5
    6
    7
    8
    9
    com.instana.plugin.kong:
      enabled: true
      admin_url: 'http://kong-admin:8001'
      admin_token:
        configuration_from:
          type: vault
          secret_key:
            path: secret/kong
            key: readonly_token
    

  3. SSL/TLS接続

    1
    2
    3
    4
    5
    com.instana.plugin.kong:
      enabled: true
      admin_url: 'https://kong-admin:8444'
      admin_token: 'secure_token'
      ssl_verify: true
    

トラブルシューティング

問題1: Admin APIに接続できない

症状: - Kong メトリクスが表示されない - 接続エラー

原因と解決策:

  1. Admin APIの確認

    1
    2
    3
    4
    5
    # Admin APIにアクセスできるか確認
    curl http://localhost:8001/status
    
    # 認証が必要な場合
    curl -H "Kong-Admin-Token: your_token" http://localhost:8001/status
    

  2. Kong設定の確認

    1
    2
    3
    4
    5
    # Kong設定を確認
    cat /etc/kong/kong.conf | grep admin_listen
    
    # Kongを再起動
    kong restart
    

問題2: メトリクスが不完全

症状: - 一部のメトリクスのみ表示される

原因と解決策:

  1. Prometheusプラグインの有効化

    1
    2
    3
    # Prometheusプラグインを有効化
    curl -X POST http://localhost:8001/plugins \
      --data "name=prometheus"
    

  2. メトリクスエンドポイントの確認

    # メトリクスを確認
    curl http://localhost:8001/metrics
    

FAQ

Q1: Kong OSS(オープンソース版)とKong Enterpriseの違いは?

A: 両方とも監視できますが、Kong Enterpriseでは追加のメトリクスとRBAC機能が利用できます。

# Kong OSS
com.instana.plugin.kong:
  enabled: true
  admin_url: 'http://localhost:8001'

# Kong Enterprise
com.instana.plugin.kong:
  enabled: true
  admin_url: 'https://kong-admin:8444'
  admin_token: 'enterprise_token'

Q2: Kubernetes Ingress ControllerとしてのKongを監視できますか?

A: はい、Admin APIにアクセスできれば監視可能です。

1
2
3
4
com.instana.plugin.kong:
  enabled: true
  poll_rate: 10
  admin_url: 'http://kong-admin.kong-system.svc.cluster.local:8001'

関連ドキュメント: - ホスト監視設定 - コンテナ監視設定 - トラブルシューティング