Skip to content

Prometheus モニタリング ​

EMQX ブローカーは、EMQX ブローカーの主要なメトリクスを簡単にモニタリングできる Prometheus API を提供しています。本ページでは、Prometheus サービスの設定方法、EMQX ブローカー API から主要なメトリクスを取得する方法、および Grafana テンプレートを使用してメトリクスを可視化する方法を紹介します。

注意

この機能は EMQX Dedicated および Dedicated Flex エディションでのみ利用可能です。

API 設定 ​

API アドレスを取得するには、デプロイメントの Overview ページで Deployment API Key を確認してください。+ New Application をクリックして APP ID と APP Secret を取得します。

prometheus_en_api

デプロイメントメトリクス URI ​

GET /deployment_metrics

Prometheus 収集用のクラスターのメトリクスを返します。

クエリパラメータ:

なし

リクエストメッセージ ​

なし

リクエスト例 ​

bash
curl -u app_id:app_secret -X GET {api}/deployment_metrics

レスポンス ​

メトリクス説明タイプ
deployment_emqx_sessions_countクラスターの現在のセッション数Gauge
deployment_emqx_connections_countクラスターの現在の接続数Gauge
deployment_emqx_sent_msg_rate1秒あたりの送信メッセージレートGauge
deployment_emqx_received_msg_rate受信メッセージのレートGauge
deployment_emqx_metrics_cluster_sessions_countクラスター内のセッション数Gauge
deployment_emqx_metrics_cluster_sessions_maxクラスターのセッション数の過去最大値Gauge
deployment_emqx_metrics_delayed_count遅延メッセージ数Gauge
deployment_emqx_metrics_delayed_max遅延メッセージ数の過去最大値Gauge
deployment_emqx_metrics_live_connections_countライブ接続数Gauge
deployment_emqx_metrics_live_connections_maxライブ接続数の過去最大値Gauge
deployment_emqx_disconnected_durable_sessions保持されている切断済みセッション数Gauge
deployment_emqx_dropped_msg_rateドロップされたメッセージのレートGauge
deployment_emqx_license_quotaライセンスで許可されている最大接続数Gauge
deployment_emqx_node_countEMQX クラスターのノード数Gauge
deployment_emqx_persisted_rateストレージに永続化されたメッセージのレートGauge
deployment_emqx_retained_msg_count現在の保持メッセージ数Gauge
deployment_emqx_shared_subscriptions共有サブスクリプション数Gauge
deployment_emqx_subscriptions総サブスクリプション数Gauge
deployment_emqx_subscriptions_durableセッションをまたいで保持される耐久サブスクリプション数Gauge
deployment_emqx_subscriptions_ramRAM に保存されている非耐久サブスクリプション数Gauge
deployment_emqx_topics総トピック数Gauge
deployment_emqx_transformation_failed_rateメッセージ変換失敗のレートGauge
deployment_emqx_transformation_succeeded_rateメッセージ変換成功のレートGauge
deployment_emqx_validation_failed_rateメッセージ検証失敗のレートGauge
deployment_emqx_validation_succeeded_rateメッセージ検証成功のレートGauge
deployment_emqx_metrics_topics_count現在のトピック数Gauge
deployment_emqx_metrics_topics_maxトピック数の最大値Gauge
deployment_emqx_metrics_subscriptions_maxサブスクリプション数の最大値Gauge
deployment_emqx_metrics_subscriptions_count現在のサブスクリプション数Gauge
deployment_emqx_metrics_subscribers_maxサブスクライバー数の最大値Gauge
deployment_emqx_metrics_subscribers_count現在のサブスクライバー数Gauge
deployment_emqx_metrics_connections_count現在の接続数Gauge
deployment_emqx_metrics_connections_max接続数の最大値Gauge
deployment_emqx_metrics_channels_count現在のチャネル数Gauge
deployment_emqx_metrics_channels_maxチャネル数の最大値Gauge
deployment_emqx_metrics_sessions_count現在のセッション数Gauge
deployment_emqx_metrics_sessions_maxセッション数の最大値Gauge
deployment_emqx_metrics_suboptions_count現在のサブスクリプションオプション数Gauge
deployment_emqx_metrics_suboptions_maxサブスクリプションオプション数の最大値Gauge
deployment_emqx_metrics_subscriptions_shared_count現在の共有サブスクリプション数Gauge
deployment_emqx_metrics_subscriptions_shared_max共有サブスクリプション数の最大値Gauge
deployment_emqx_metrics_retained_count現在の保持メッセージ数Gauge
deployment_emqx_metrics_retained_max保持メッセージ数の過去最大値Gauge
deployment_emqx_cluster_statusEMQX クラスターのステータスGauge
deployment_emqx_metrics_durable_subscriptions_max現在のクラスターの耐久サブスクリプション最大数Counter
deployment_emqx_metrics_durable_subscriptions_count現在のクラスターの耐久サブスクリプション数Counter
deployment_emqx_metrics_client_disconnected_reason理由別のリスナーシャットダウン回数Counter
deployment_emqx_metrics_bytes_received受信バイト数Counter
deployment_emqx_metrics_bytes_sent送信バイト数Counter
deployment_emqx_metrics_packets_received受信パケット数Counter
deployment_emqx_metrics_packets_sent送信パケット数Counter
deployment_emqx_metrics_packets_connack_auth_error認証エラーを含む送信済み CONNACK メッセージ数Counter
deployment_emqx_metrics_packets_connack_errorエラーを含む送信済み CONNACK パケット数Counter
deployment_emqx_metrics_packets_connack_sent送信済み CONNACK パケット数Counter
deployment_emqx_metrics_packets_publish_received受信済み PUBLISH パケット数Counter
deployment_emqx_metrics_packets_publish_sent送信済み PUBLISH パケット数Counter
deployment_emqx_metrics_packets_publish_inuse使用中の PUBLISH パケット数Counter
deployment_emqx_metrics_packets_publish_auth_error認証エラーを含む PUBLISH パケット数Counter
deployment_emqx_metrics_packets_publish_errorエラーを含む PUBLISH パケット数Counter
deployment_emqx_metrics_packets_publish_droppedドロップされた PUBLISH パケット数Counter
deployment_emqx_metrics_packets_puback_received受信済み PUBACK パケット数Counter
deployment_emqx_metrics_packets_puback_sent送信済み PUBACK パケット数Counter
deployment_emqx_metrics_packets_puback_inuse使用中の PUBACK パケット数Counter
deployment_emqx_metrics_packets_puback_missed失われた PUBACK パケット数Counter
deployment_emqx_metrics_packets_pubrec_received受信済み PUBREC パケット数Counter
deployment_emqx_metrics_packets_pubrec_sent送信済み PUBREC パケット数Counter
deployment_emqx_metrics_packets_pubrec_inuse使用中の PUBREC パケット数Counter
deployment_emqx_metrics_packets_pubrec_missed失われた PUBREC パケット数Counter
deployment_emqx_metrics_packets_pubrel_received受信済み PUBREL パケット数Counter
deployment_emqx_metrics_packets_pubrel_sent送信済み PUBREL パケット数Counter
deployment_emqx_metrics_packets_pubrel_missed失われた PUBREL パケット数Counter
deployment_emqx_metrics_packets_pubcomp_received受信済み PUBCOMP パケット数Counter
deployment_emqx_metrics_packets_pubcomp_sent送信済み PUBCOMP パケット数Counter
deployment_emqx_metrics_packets_pubcomp_inuse使用中の PUBCOMP パケット数Counter
deployment_emqx_metrics_packets_pubcomp_missed失われた PUBCOMP パケット数Counter
deployment_emqx_metrics_packets_subscribe_received受信済み SUBSCRIBE パケット数Counter
deployment_emqx_metrics_packets_subscribe_errorエラーを含む SUBSCRIBE パケット数Counter
deployment_emqx_metrics_packets_subscribe_auth_error認証エラーを含む SUBSCRIBE パケット数Counter
deployment_emqx_metrics_packets_suback_sent送信済み SUBACK パケット数Counter
deployment_emqx_metrics_packets_unsubscribe_received受信済み UNSUBSCRIBE パケット数Counter
deployment_emqx_metrics_packets_unsubscribe_errorエラーを含む UNSUBSCRIBE パケット数Counter
deployment_emqx_metrics_packets_unsuback_sent送信済み UNSUBACK パケット数Counter
deployment_emqx_metrics_packets_pingreq_received受信済み PINGREQ パケット数Counter
deployment_emqx_metrics_packets_pingresp_sent送信済み PINGRESP パケット数Counter
deployment_emqx_metrics_packets_disconnect_received受信済み DISCONNECT パケット数Counter
deployment_emqx_metrics_packets_disconnect_sent送信済み DISCONNECT パケット数Counter
deployment_emqx_metrics_packets_auth_received受信済み AUTH パケット数Counter
deployment_emqx_metrics_packets_auth_sent送信済み AUTH パケット数Counter
deployment_emqx_metrics_delivery_dropped_too_largeサイズオーバーでドロップされた配信数Counter
deployment_emqx_metrics_delivery_dropped_queue_fullキュー満杯でドロップされた配信数Counter
deployment_emqx_metrics_delivery_dropped_qos0_msgQoS 0 メッセージでドロップされた配信数Counter
deployment_emqx_metrics_delivery_dropped_expired有効期限切れでドロップされた配信数Counter
deployment_emqx_metrics_delivery_dropped_no_localローカルクライアントなしでドロップされた配信数Counter
deployment_emqx_metrics_delivery_droppedドロップされた配信の合計数Counter
deployment_emqx_metrics_messages_delayed遅延メッセージ数Counter
deployment_emqx_metrics_messages_delivered配信済みメッセージ数Counter
deployment_emqx_metrics_messages_droppedドロップされたメッセージ数Counter
deployment_emqx_metrics_messages_dropped_expired有効期限切れでドロップされたメッセージ数Counter
deployment_emqx_metrics_messages_dropped_no_subscribersサブスクライバーなしでドロップされたメッセージ数Counter
deployment_emqx_metrics_messages_forward転送されたメッセージ数Counter
deployment_emqx_metrics_messages_publishパブリッシュされたメッセージ数Counter
deployment_emqx_metrics_messages_qos0_received受信した QoS 0 メッセージ数Counter
deployment_emqx_metrics_messages_qos2_received受信した QoS 2 メッセージ数Counter
deployment_emqx_metrics_messages_qos1_received受信した QoS 1 メッセージ数Counter
deployment_emqx_metrics_messages_qos0_sent送信した QoS 0 メッセージ数Counter
deployment_emqx_metrics_messages_qos1_sent送信した QoS 1 メッセージ数Counter
deployment_emqx_metrics_messages_qos2_sent送信した QoS 2 メッセージ数Counter
deployment_emqx_metrics_messages_received受信したメッセージの合計数Counter
deployment_emqx_metrics_messages_sent送信したメッセージの合計数Counter
deployment_emqx_metrics_messages_retained保持されたメッセージ数Counter
deployment_emqx_metrics_messages_ackedアックされたメッセージ数Counter
deployment_emqx_metrics_client_auth_anonymous匿名クライアント認証数Counter
deployment_emqx_metrics_client_connectクライアント接続数Counter
deployment_emqx_metrics_client_authenticateクライアント認証数Counter
deployment_emqx_metrics_client_connack送信済み CONNACK パケット数Counter
deployment_emqx_metrics_client_connected現在接続中のクライアント数Counter
deployment_emqx_metrics_client_disconnectedクライアント切断数Counter
deployment_emqx_metrics_client_subscribeクライアントサブスクリプション数Counter
deployment_emqx_metrics_client_unsubscribeクライアントのサブスクリプション解除数Counter
deployment_emqx_metrics_session_created作成されたセッション数Counter
deployment_emqx_metrics_session_discarded廃棄されたセッション数Counter
deployment_emqx_metrics_session_resumed再開されたセッション数Counter
deployment_emqx_metrics_session_terminated終了したセッション数Counter
deployment_emqx_metrics_authentication_failure認証失敗数Counter
deployment_emqx_metrics_authentication_success認証成功数Counter
deployment_emqx_metrics_authentication_success_anonymous匿名認証成功数Counter
deployment_emqx_metrics_authorization_allow認可成功数Counter
deployment_emqx_metrics_authorization_cache_hit認可時のキャッシュヒット数Counter
deployment_emqx_metrics_authorization_cache_miss認可時のキャッシュミス数Counter
deployment_emqx_metrics_authorization_deny認可拒否数Counter
deployment_emqx_metrics_authorization_matched_allow認可成功マッチ数Counter
deployment_emqx_metrics_authorization_matched_deny認可拒否マッチ数Counter
deployment_emqx_metrics_authorization_nomatch認可マッチなし数Counter
deployment_emqx_metrics_authorization_superuserスーパーユーザー認可数Counter
deployment_emqx_metrics_client_authorizeclient.authorize フックのトリガー回数Counter
deployment_emqx_metrics_packets_connect送信済み CONNECT パケット数Counter
deployment_emqx_metrics_session_takenoversession.takenover フックのトリガー回数Counter
deployment_emqx_metrics_traffic_total_egress_bytes送信トラフィックの合計バイト数Counter
deployment_emqx_metrics_traffic_total_ingress_bytes受信トラフィックの合計バイト数Counter

データ統合メトリクス URI ​

GET /deployment_metrics/data_integration

Prometheus 収集用のデータ統合メトリクスを返します。

クエリパラメータ:

なし

リクエストメッセージ ​

なし

リクエスト例 ​

bash
curl -u app_id:app_secret -X GET {api}/deployment_metrics/data_integration

レスポンス ​

  • 各リソースのステータス
  • 各ルールのステータス
  • 各ルールの異なるマッチステータス("matched", "passed", "failed", "exception", "no_result")のカウント
  • 各ルール下の全アクション処理ステータス("success", "failed", "taken")のカウント
メトリクス説明タイプ変数ラベル
deployment_emqx_resource_status特定リソースの現在のステータスGaugeresource_id
deployment_emqx_rule_status特定ルールの現在のステータスGaugerule_id
deployment_emqx_rule_matched_count特定ルールのマッチ数Gaugerule_id, match_status
deployment_emqx_rule_action_execution_count特定ルールのアクション実行回数Gaugerule_id, execution_status
deployment_emqx_action_dropped_count特定アクションのドロップイベント数Counterdrop_reason
deployment_emqx_action_enableアクションが有効な emqx ノード数Gaugestatus
deployment_emqx_action_events_count特定アクションのイベント数Counterevent, action_id
deployment_emqx_action_queued_count特定アクションのキューイングされたイベント数Gaugeaction_id, queue_status
deployment_emqx_action_retried_count特定アクションの再試行イベント数Counteraction_id, retry_status
deployment_emqx_action_status特定アクションの現在のステータスGaugeaction_id

認証・認可メトリクス URI ​

GET /deployment_metrics/auth

Prometheus 収集用の認証および認可メトリクスを返します。

クエリパラメータ:

なし

リクエストメッセージ ​

なし

リクエスト例 ​

bash
curl -u app_id:app_secret -X GET {api}/deployment_metrics/auth

レスポンス ​

メトリクス説明タイプ変数ラベル
deployment_emqx_authn_enable指定された認証方式が有効かどうかGaugeid
deployment_emqx_authn_match_count各認証方式の統計Gaugeid, status
deployment_emqx_authn_status各認証方式の稼働状況Gaugeid
deployment_emqx_authz_enable指定された認可方式が有効かどうかGaugeid
deployment_emqx_authz_match_count各認可方式の統計Gaugeid, status
deployment_emqx_authz_status各認可方式の稼働状況Gaugeid

スマートデータハブメトリクス URI ​

GET /deployment_metrics/data_hub

Prometheus 収集用のスマートデータハブメトリクスを返します。

クエリパラメータ:

なし

リクエストメッセージ ​

なし

リクエスト例 ​

bash
curl -u app_id:app_secret -X GET {api}/deployment_metrics/data_hub

レスポンス ​

メトリクス説明タイプ変数ラベル
emqx_message_transformation_enableメッセージ変換の有効状態Gaugevalidation_name
emqx_message_transformation_stats変換統計Counterstats, validation_name
emqx_schema_validation_enableスキーマ検証の有効状態Gaugevalidation_name
emqx_schema_validation_statsスキーマ検証統計Counterstats, validation_name

Prometheus 設定 ​

  1. Prometheus をインストールします。

    bash
    wget -c https://github.com/prometheus/prometheus/releases/download/v2.35.0-rc0/prometheus-2.35.0-rc0.linux-amd64.tar.gz
    tar xvfz prometheus-*.tar.gz
  2. 設定ファイルを編集します。

    Prometheus サービス用に指定されたモニタリングディレクトリに移動し、設定ファイル prometheus.yml の scrape_configs セクションを以下の例のように編集します。

    bash
    scrape_configs:
      - job_name: 'emqx_cloud_deployment_metrics'
        scheme: 'https'
        static_configs:
          - targets: [ 'xxxx:8443' ]
        metrics_path: "/api/v5/deployment_metrics"
        params:
          type: [ "prometheus" ]
        basic_auth:
          username: 'APP ID'
          password: 'APP Secret'
      - job_name: 'emqx_cloud_deployment_data_integration_metrics'
        scheme: 'https'
        static_configs:
          - targets: [ 'xxxx:8443' ]
        metrics_path: "/api/v5/deployment_metrics/data_integration"
        params:
          type: [ "prometheus" ]
        basic_auth:
          username: 'APP ID'
          password: 'APP Secret'
  3. サービスを起動し、状態を確認します。

    Prometheus を起動します。

    bash
     ./prometheus --config.file=prometheus.yml

    ローカル IP と対応するポート(例:x.x.x.x:9090)で Prometheus サービスにアクセスし、Status - Targets を確認して新しい scrape_config ファイルが読み込まれていることを確認します。ステータスに例外が表示される場合は、設定ファイルを確認し、Prometheus サービスを再起動してください。

    Prometheus_service

Grafana 設定 ​

  1. Grafana をインストールして起動します。

    bash
     wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.4.6.linux-amd64.tar.gz
     tar -zxvf grafana-enterprise-8.4.6.linux-amd64.tar.gz
     ./bin/grafana-server
  2. Grafana を設定します。

    ローカル IP と対応するポート(例:x.x.x.x:3000)で Grafana ダッシュボードにアクセスします。初期の ID とパスワードは admin です。初回ログイン時にパスワードを変更できます。

    Grafana

  3. Grafana データテンプレートをインポートします。

    EMQX Cloud は Grafana ダッシュボード用のテンプレートファイルを提供しています。これらのテンプレートには EMQX Cloud のすべてのモニタリングデータの表示が含まれており、ユーザーはこれらを直接 Grafana にインポートして EMQX のモニタリング状況を示すグラフを生成できます。テンプレートファイルはこちらから入手可能です。

    ローカルの grafana_template.json ファイルを「Upload JSON file」からアップロードするか、「Import via panel json」から手動で設定できます。

    Grafana

メトリクス詳細 ​

システムのセットアップ完了後、一定期間稼働させると、EMQX Cloud Prometheus によって収集されたデータが Grafana に表示されます。これにはクライアント数、サブスクリプション数、トピック数、メッセージ数、パケット数などの過去の統計情報が含まれます。各メトリクスに対応するグラフや特定の時点の詳細情報を閲覧できます。

Grafana

Prometheus は EMQX Cloud デプロイメントの以下のメトリクスデータを追跡します:

メトリクスタイプ説明
deployment_emqx_connections_countgaugeクラスター接続数
deployment_emqx_sessions_countgaugeセッション総数
deployment_emqx_messages_rategaugeメッセージ総レート
deployment_emqx_messages_send_rategaugeメッセージ送信レート
deployment_emqx_messages_receive_rategaugeメッセージ受信レート
deployment_emqx_metrics_bytes_receivedgauge受信バイト数
deployment_emqx_metrics_bytes_sentgauge送信バイト数
deployment_emqx_metrics_retained_countgauge保持メッセージ数
deployment_emqx_metrics_messages_receivedcounter受信メッセージ数
deployment_emqx_metrics_messages_qos0_receivedcounter受信した QoS=0 メッセージ数
deployment_emqx_metrics_messages_qos1_receivedcounter受信した QoS=1 メッセージ数
deployment_emqx_metrics_messages_qos2_receivedcounter受信した QoS=2 メッセージ数
deployment_emqx_metrics_messages_droppedcounter受信段階でドロップされたメッセージ数
deployment_emqx_metrics_messages_dropped_expiredcounter有効期限切れでドロップされたメッセージ数
deployment_emqx_metrics_messages_dropped_no_subscriberscounterサブスクライバーなしでドロップされたメッセージ数
deployment_emqx_metrics_messages_sentcounter送信メッセージ数
deployment_emqx_metrics_messages_qos0_sentcounter送信した QoS=0 メッセージ数
deployment_emqx_metrics_messages_qos1_sentcounter送信した QoS=1 メッセージ数
deployment_emqx_metrics_messages_qos2_sentcounter送信した QoS=2 メッセージ数
deployment_emqx_metrics_delivery_droppedcounter配信段階でドロップされたメッセージ数
deployment_emqx_metrics_delivery_dropped_too_largecounterサイズオーバーでドロップされたメッセージ数
deployment_emqx_metrics_delivery_dropped_queue_fullcounterキュー満杯でドロップされたメッセージ数
deployment_emqx_metrics_delivery_dropped_no_localcounterローカルなしでドロップされたメッセージ数
deployment_emqx_metrics_delivery_dropped_expiredcounter有効期限切れでドロップされたメッセージ数
deployment_emqx_metrics_topics_countgaugeトピック数
deployment_emqx_metrics_subscriptions_countgaugeサブスクリプション数
deployment_emqx_metrics_subscriptions_shared_countgauge共有サブスクリプション数
deployment_emqx_metrics_subscribers_countgaugeサブスクライバー数
deployment_emqx_metrics_authentication_successcounter認証成功数
deployment_emqx_metrics_authentication_failurecounter認証失敗数
deployment_emqx_metrics_client_authorizecounterクライアント認可数
deployment_emqx_metrics_authorization_allowcounter認可成功数
deployment_emqx_metrics_authorization_denycounter認可拒否数
deployment_emqx_metrics_authorization_matched_allowcounter認可成功マッチ数
deployment_emqx_metrics_authorization_matched_denycounter認可拒否マッチ数
deployment_emqx_metrics_authorization_nomatchcounter認可マッチなし数
deployment_emqx_metrics_packets_receivedcounter受信パケット数
deployment_emqx_metrics_packets_sentcounter送信パケット数
deployment_emqx_metrics_packets_connect_receivedcounter受信した CONNECT パケット数
deployment_emqx_metrics_packets_connack_sentcounter送信した CONNACK パケット数
deployment_emqx_metrics_packets_disconnect_receivedcounter受信した DISCONNECT パケット数
deployment_emqx_metrics_packets_disconnect_sentcounter送信した DISCONNECT パケット数
deployment_emqx_metrics_packets_publish_receivedcounter受信した PUBLISH パケット数
deployment_emqx_metrics_packets_publish_sentcounter送信した PUBLISH パケット数
deployment_emqx_metrics_packets_subscribe_receivedcounter受信した SUBSCRIBE パケット数
deployment_emqx_metrics_packets_unsubscribe_receivedcounter受信した UNSUBSCRIBE パケット数
deployment_emqx_metrics_packets_pingreq_receivedcounter受信した PINGREQ パケット数
deployment_emqx_metrics_packets_pingresp_sentcounter送信した PINGRESP パケット数
deployment_emqx_metrics_packets_auth_receivedcounter受信した AUTH パケット数
deployment_emqx_metrics_packets_auth_sentcounter送信した AUTH パケット数
deployment_emqx_rule_statusgaugeルールステータス
deployment_emqx_rule_matched_rategaugeルールマッチ率
deployment_emqx_rule_matched_countgaugeルールマッチ数
deployment_emqx_rule_action_execution_countgaugeルールアクション実行回数