Просмотр исходного кода

Merge pull request #9881 from olcai/log-influxdb-is-alive-reason

fix(emqx_ee_connector): log reason for failure when starting influxdb connector
Ivan Dyachkov 3 лет назад
Родитель
Сommit
6ce5029d79

+ 4 - 0
changes/ee/feat-9881.en.md

@@ -0,0 +1,4 @@
+In this pull request, we have enhanced the error logs related to InfluxDB connectivity health checks.
+Previously, if InfluxDB failed to pass the health checks using the specified parameters, the only message provided was "timed out waiting for it to become healthy".
+With the updated implementation, the error message will be displayed in both the logs and the dashboard, enabling easier identification and resolution of the issue.
+

+ 3 - 0
changes/ee/feat-9881.zh.md

@@ -0,0 +1,3 @@
+增强了与 InfluxDB 连接健康检查相关的错误日志。
+在此更改之前,如果使用配置的参数 InfluxDB 未能通过健康检查,用户仅能获得一个“超时”的信息。
+现在,详细的错误消息将显示在日志和控制台,从而让用户更容易地识别和解决问题。

+ 1 - 1
lib-ee/emqx_ee_bridge/test/emqx_ee_bridge_influxdb_SUITE.erl

@@ -827,7 +827,7 @@ t_create_disconnected(Config) ->
         end),
         fun(Trace) ->
             ?assertMatch(
-                [#{error := influxdb_client_not_alive}],
+                [#{error := influxdb_client_not_alive, reason := econnrefused}],
                 ?of_kind(influxdb_connector_start_failed, Trace)
             ),
             ok

+ 1 - 1
lib-ee/emqx_ee_connector/rebar.config

@@ -1,7 +1,7 @@
 {erl_opts, [debug_info]}.
 {deps, [
   {hstreamdb_erl, {git, "https://github.com/hstreamdb/hstreamdb_erl.git", {tag, "0.2.5"}}},
-  {influxdb, {git, "https://github.com/emqx/influxdb-client-erl", {tag, "1.1.8"}}},
+  {influxdb, {git, "https://github.com/emqx/influxdb-client-erl", {tag, "1.1.9"}}},
   {tdengine, {git, "https://github.com/emqx/tdengine-client-erl", {tag, "0.1.5"}}},
   {emqx, {path, "../../apps/emqx"}}
 ]}.

+ 8 - 6
lib-ee/emqx_ee_connector/src/emqx_ee_connector_influxdb.erl

@@ -234,7 +234,7 @@ do_start_client(
 ) ->
     case influxdb:start_client(ClientConfig) of
         {ok, Client} ->
-            case influxdb:is_alive(Client) of
+            case influxdb:is_alive(Client, true) of
                 true ->
                     State = #{
                         client => Client,
@@ -249,13 +249,15 @@ do_start_client(
                         state => redact_auth(State)
                     }),
                     {ok, State};
-                false ->
-                    ?tp(influxdb_connector_start_failed, #{error => influxdb_client_not_alive}),
+                {false, Reason} ->
+                    ?tp(influxdb_connector_start_failed, #{
+                        error => influxdb_client_not_alive, reason => Reason
+                    }),
                     ?SLOG(warning, #{
-                        msg => "starting influxdb connector failed",
+                        msg => "failed_to_start_influxdb_connector",
                         connector => InstId,
                         client => redact_auth(Client),
-                        reason => "client is not alive"
+                        reason => Reason
                     }),
                     %% no leak
                     _ = influxdb:stop_client(Client),
@@ -273,7 +275,7 @@ do_start_client(
         {error, Reason} ->
             ?tp(influxdb_connector_start_failed, #{error => Reason}),
             ?SLOG(warning, #{
-                msg => "starting influxdb connector failed",
+                msg => "failed_to_start_influxdb_connector",
                 connector => InstId,
                 reason => Reason
             }),

+ 1 - 1
mix.exs

@@ -130,7 +130,7 @@ defmodule EMQXUmbrella.MixProject do
   defp enterprise_deps(_profile_info = %{edition_type: :enterprise}) do
     [
       {:hstreamdb_erl, github: "hstreamdb/hstreamdb_erl", tag: "0.2.5"},
-      {:influxdb, github: "emqx/influxdb-client-erl", tag: "1.1.7", override: true},
+      {:influxdb, github: "emqx/influxdb-client-erl", tag: "1.1.9", override: true},
       {:wolff, github: "kafka4beam/wolff", tag: "1.7.5"},
       {:kafka_protocol, github: "kafka4beam/kafka_protocol", tag: "4.1.2", override: true},
       {:brod_gssapi, github: "kafka4beam/brod_gssapi", tag: "v0.1.0-rc1"},