emqx charts配置webhook失败

错误报告

emqx charts 使用环境变量配置webhook的属性时失败

配置EMQX_WEB__HOOK__URL生效
配置EMQX_WEB__HOOK__RULE__CLIENT__CONNECTED__1__ACTION等属性失效

环境

官方helm chart emqx

  • EMQX 版本:4.4.11
  • 操作系统版本:ubuntu20.04

重现此问题的步骤

values.yml部分配置文件内容

emqxConfig:

  EMQX_WEB__HOOK__URL: "http://webhook/mqtt/webhook"
  EMQX_WEB__HOOK__RULE__CLIENT__CONNECTED__1__ACTION: "on_client_connected"
  EMQX_WEB__HOOK__RULE__CLIENT__DISCONNECTED__1__ACTION: "on_client_disconnected"
  EMQX_WEB__HOOK__RULE__MESSAGE__DELIVERD__1__ACTION: "on_message_delivered"

预期行为

调用webhook服务

实际行为

容器日志,可以看到读取到了webhook url的环境变量,但是未读取到行为的环境变量

2022-12-07T11:55:44.742528+00:00 [info] [Plugins] web.hook.url = "http://101.35.198.250:6666/mqtt/webhook"

 2022-12-07T11:55:44.742588+00:00 [debug] Adding Defaults

 2022-12-07T11:55:44.742681+00:00 [debug] Right Hand Side Substitutions

 2022-12-07T11:55:44.742738+00:00 [debug] Applying Datatypes

 2022-12-07T11:55:44.743002+00:00 [debug] Validation

 2022-12-07T11:55:44.743101+00:00 [debug] Applied 1:1 Mappings

 2022-12-07T11:55:44.743140+00:00 [debug] Running translation for emqx_web_hook.headers

 2022-12-07T11:55:44.743196+00:00 [debug] "emqx_web_hook.rules" in Translations to drop...

 2022-12-07T11:55:44.743231+00:00 [debug] Applied Translations

 2022-12-07T11:55:44.745215+00:00 [info] [Plugins] Started plugins: [emqx_web_hook]

 2022-12-07T11:55:44.745270+00:00 [info] [Plugins] Load plugin emqx_web_hook successfully

 2022-12-07T11:55:44.746170+00:00 [info] [Modules] Load emqx_mod_acl_internal module successfully.

 2022-12-07T11:55:44.746254+00:00 [info] [Modules] Load emqx_mod_presence module successfully.

 EMQ X Broker 4.4.11 is running now!

 2022-12-07T11:55:44.933959+00:00 [info] Ekka(Membership): Node emqx@emqx-3.emqx-headless.smzs-yinxiang.svc.cluster.local up

 2022-12-07T11:55:44.949378+00:00 [info] Ekka(Membership): Mnesia emqx@emqx-3.emqx-headless.smzs-yinxiang.svc.cluster.local up

 2022-12-07T11:55:48.319274+00:00 [warning] Description: "Authenticity is not established by certificate path validation", Reason: "Option {verify, verify_peer} and cacertfile/cacerts is missing"

 2022-12-07T11:55:48.331491+00:00 [info] Ekka(AutoCluster): all discovered nodes already in cluster; ignoring

 2022-12-07T11:55:48.331560+00:00 [debug] Ekka(AutoCluster): join result: ignore

 2022-12-07T11:55:48.331605+00:00 [info] Ekka(AutoCluster): no discovered nodes outside cluster

 2022-12-07T11:55:49.282300+00:00 [debug] file: emqx_telemetry.erl, line: 357, mfa: {emqx_telemetry,report_telemetry,1}, msg: telemetry_data_reported, pid: <0.2044.0>

 2022-12-07T11:56:15.163786+00:00 [debug] 172.23.105.0:48636 [MQTT] RECV <<16,26,0,4,77,81,84,84,5,194,0,60,0,0,3,97,112,112,0,3,97,112,112,0,3,97,112,112>>

 2022-12-07T11:56:15.163927+00:00 [debug] 172.23.105.0:48636 [MQTT] RECV CONNECT(Q0, R0, D0ClientId=app, ProtoName=MQTT, ProtoVsn=5, CleanStart=true, KeepAlive=60, Username=app, Password=******)

 2022-12-07T11:56:15.170526+00:00 [debug] app@172.23.105.0:48636 [Channel] RECV CONNECT(Q0, R0, D0ClientId=app, ProtoName=MQTT, ProtoVsn=5, CleanStart=true, KeepAlive=60, Username=app, Password=******)

 2022-12-07T11:56:15.171506+00:00 [debug] app@172.23.105.0:48636 client_id: <<"app">>, file: emqx_cm.erl, line: 128, mfa: {emqx_cm,insert_channel_info,3}, msg: insert_channel_info, pid: <0.2331.0>

功能请求

描述你需要的功能

为什么你需要这个功能


其他

抱歉这是 EMQX Helm Char 的一个 bug,现在已经提交了修复 PR:https://github.com/emqx/emqx/pull/9504,你可以等待我们的 4.4.12 版本,或是根据 PR 内容自行修改本地的 helm chart

修复了之后可以在 values.yaml 中配置 EMQX_WEB__HOOK__RULE__CLIENT__CONNECT__1: {"action":"on_client_connect"},注意不要使用引号。

另外需要在 values.yaml 中开启 emqx_web_hook 插件,开启方法是在 value.yaml 中的添加下面的内容

 emqxLoadedPlugins: >
+  {emqx_web_hook, true}.
   {emqx_management, true}.
   {emqx_recon, true}.
   {emqx_retainer, true}.
...

注意 {emqx_web_hook, true}. 的行末有一个 . 不要漏掉了

1 个赞

感谢大佬,我去看看自己能不能改一下helm chart。。。