From c4c2f570ff06ae0d1942781e8e1b3af3fd45f084 Mon Sep 17 00:00:00 2001 From: Erik Timan Date: Tue, 7 Feb 2023 14:23:04 +0100 Subject: [PATCH 1/3] feat(emqx_prometheus): expose live_connections stats to prometheus --- apps/emqx_prometheus/src/emqx_prometheus.erl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/emqx_prometheus/src/emqx_prometheus.erl b/apps/emqx_prometheus/src/emqx_prometheus.erl index b58c4cc5f..5342a6d71 100644 --- a/apps/emqx_prometheus/src/emqx_prometheus.erl +++ b/apps/emqx_prometheus/src/emqx_prometheus.erl @@ -185,6 +185,10 @@ emqx_collect(emqx_connections_count, Stats) -> gauge_metric(?C('connections.count', Stats)); emqx_collect(emqx_connections_max, Stats) -> gauge_metric(?C('connections.max', Stats)); +emqx_collect(emqx_live_connections_count, Stats) -> + gauge_metric(?C('live_connections.count', Stats)); +emqx_collect(emqx_live_connections_max, Stats) -> + gauge_metric(?C('live_connections.max', Stats)); %% sessions emqx_collect(emqx_sessions_count, Stats) -> @@ -471,6 +475,8 @@ emqx_collect(emqx_cluster_nodes_stopped, ClusterData) -> emqx_stats() -> [ emqx_connections_count , emqx_connections_max + , emqx_live_connections_count + , emqx_live_connections_max , emqx_sessions_count , emqx_sessions_max , emqx_topics_count From 8f4e3908404be41ab3d3ac28de845f29e2a880da Mon Sep 17 00:00:00 2001 From: Erik Timan Date: Tue, 7 Feb 2023 15:17:37 +0100 Subject: [PATCH 2/3] chore: bump VSN and appup --- apps/emqx_prometheus/src/emqx_prometheus.app.src | 2 +- apps/emqx_prometheus/src/emqx_prometheus.appup.src | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/emqx_prometheus/src/emqx_prometheus.app.src b/apps/emqx_prometheus/src/emqx_prometheus.app.src index ded1bf46d..6e7d7400f 100644 --- a/apps/emqx_prometheus/src/emqx_prometheus.app.src +++ b/apps/emqx_prometheus/src/emqx_prometheus.app.src @@ -1,6 +1,6 @@ {application, emqx_prometheus, [{description, "Prometheus for EMQ X"}, - {vsn, "4.3.1"}, % strict semver, bump manually! + {vsn, "4.3.2"}, % strict semver, bump manually! {modules, []}, {registered, [emqx_prometheus_sup]}, {applications, [kernel,stdlib,prometheus]}, diff --git a/apps/emqx_prometheus/src/emqx_prometheus.appup.src b/apps/emqx_prometheus/src/emqx_prometheus.appup.src index a06d65fe1..1234d5395 100644 --- a/apps/emqx_prometheus/src/emqx_prometheus.appup.src +++ b/apps/emqx_prometheus/src/emqx_prometheus.appup.src @@ -1,9 +1,9 @@ %% -*- mode: erlang -*- %% Unless you know what you are doing, DO NOT edit manually!! {VSN, - [{"4.3.0", - [{load_module,emqx_prometheus,brutal_purge,soft_purge,[]}]}, + [{"4.3.1",[{load_module,emqx_prometheus,brutal_purge,soft_purge,[]}]}, + {"4.3.0",[{load_module,emqx_prometheus,brutal_purge,soft_purge,[]}]}, {<<".*">>,[]}], - [{"4.3.0", - [{load_module,emqx_prometheus,brutal_purge,soft_purge,[]}]}, + [{"4.3.1",[{load_module,emqx_prometheus,brutal_purge,soft_purge,[]}]}, + {"4.3.0",[{load_module,emqx_prometheus,brutal_purge,soft_purge,[]}]}, {<<".*">>,[]}]}. From 3d41e58d80f0c6c74bc08c3d93cd8a7b155dd876 Mon Sep 17 00:00:00 2001 From: Erik Timan Date: Tue, 7 Feb 2023 15:05:09 +0100 Subject: [PATCH 3/3] chore: update changes --- changes/v4.4.15-en.md | 2 ++ changes/v4.4.15-zh.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/changes/v4.4.15-en.md b/changes/v4.4.15-en.md index 260166da2..d8ccfefdd 100644 --- a/changes/v4.4.15-en.md +++ b/changes/v4.4.15-en.md @@ -16,6 +16,8 @@ - Add more debug logs for authentication and ACL [#9943](https://github.com/emqx/emqx/pull/9943). +- Expose the stats `live_connections.count` and `live_connections.max` to Prometheus [#9929](https://github.com/emqx/emqx/pull/9929). + ## Bug fixes - Fixed an error when forward MQTT messages with User-Property using the `republish` action [#9942](https://github.com/emqx/emqx/pull/9942). diff --git a/changes/v4.4.15-zh.md b/changes/v4.4.15-zh.md index a382e0c94..03eb31522 100644 --- a/changes/v4.4.15-zh.md +++ b/changes/v4.4.15-zh.md @@ -16,6 +16,8 @@ - 为认证和授权添加了更多调试日志 [#9943](https://github.com/emqx/emqx/pull/9943)。 +- 将统计数据 `live_connections.count` 和 `live_connections.max` 公开给 Prometheus [#9929](https://github.com/emqx/emqx/pull/9929). + ## 修复 - 修复使用 `消息重发布` 动作转发带 User-Property 的 MQTT 消息时出错的问题 [#9942](https://github.com/emqx/emqx/pull/9942)。