Commit Graph

190 Commits

Author SHA1 Message Date
Andrew Mayorov a51baaa206
refactor(pluglib): move conversion utils to `emqx_utils_conv` 2023-06-09 14:44:37 +03:00
某文 367a0e312a chore: remove config_path() function 2023-06-02 07:09:08 +08:00
Andrew Mayorov 29fe201676
fix(ruleeng): parse bridge id on create / update
Instead of parsing it every time in the `send_message/2` hot path.
2023-05-31 17:08:42 +03:00
Thales Macedo Garitezi 57aacb471c fix(rule_engine_api): don't crash when formatting empty metrics
Fixes https://emqx.atlassian.net/browse/EMQX-10073
Fixes https://github.com/emqx/emqx/issues/10714#issuecomment-1567987664

Similar issue to https://github.com/emqx/emqx/pull/10743, but on the
rule engine API.
2023-05-30 11:54:27 -03:00
Kjell Winblad 354603da01 test: helper function was interpreted as a test function 2023-05-29 17:20:37 +02:00
Kjell Winblad 995025b572 feat: add timezone_to_second/1 function to rule engine
This commit adds the functions timezone_to_offset_seconds and its alias
timezone_to_second to the rule engine. As the names suggests, these
functions convert a timzone offset string such as "+02:00", "Z", "local"
to an integer representing how many seconds that the given timezone
differs from UTC. timezone_to_offset_seconds is the one of the two
functions that should be advertised while timezone_to_second in kept for
backwards compatibility with 4.X.

Fixes:
https://emqx.atlassian.net/browse/EMQX-10058
2023-05-29 14:30:43 +02:00
Zaiming (Stone) Shi 732a7be187 Merge remote-tracking branch 'origin/release-50' 2023-05-22 17:46:54 +02:00
lafirest 88e4078885
Merge pull request #10747 from lafirest/fix/rule_funs_time_offset
fix: port the `emqx_calendar` from v4.4
2023-05-22 20:52:21 +08:00
firest 087dc59115 test: add test cases for the `rule_test` API 2023-05-22 15:25:35 +08:00
firest 56a6b699ac fix: port the `emqx_calendar` from v4.4 2023-05-22 09:55:31 +08:00
Thales Macedo Garitezi 447b76464b Merge branch 'release-50' into merge-r50-into-v50-a 2023-05-17 14:50:18 -03:00
firest 18043150be fix: cannot access columns exported by FOREACH in DO clause 2023-05-17 10:55:47 +08:00
Ilya Averyanov c113a8ac6a
Merge pull request #10677 from savonarola/0511-fix-rule-api
fix(api): respond 404 on the deletion of nonexistent rule
2023-05-16 16:50:30 +03:00
Zaiming (Stone) Shi 3c64735b87 feat(rule_engine): support external SQL function provider 2023-05-15 08:58:40 +02:00
Ilya Averyanov 49e9ace1c1 fix(api): respond 404 on the deletion of nonexistent rule 2023-05-11 23:12:59 +05:00
Kjell Winblad 0c727fc9b2
Merge pull request #10392 from kjellwinblad/kjell/rule_engine/add_missing_datetime_function/EMQX-9245
freat: add date_to_unix_ts/3 function to the rule engine
2023-04-17 18:09:44 +02:00
Zaiming (Stone) Shi 18974a8e11 refactor: make schema dump and swagger spec work with split desc files 2023-04-17 13:58:11 +02:00
Kjell Winblad 37f42a486c test: improve proper test so it generates more cases 2023-04-17 12:03:13 +02:00
zhongwencool 494ffe86ad
Merge branch 'master' into conf-refactor 2023-04-15 06:40:38 +08:00
Zhongwen Deng 8facd130f6 chore: update cluster_hocon_file/0 function 2023-04-14 23:19:38 +08:00
Stefan Strigler f8e9e54393 refactor: move emqx_json to emqx_utils_json 2023-04-14 13:31:27 +02:00
Kjell Winblad d3ccd8a65d feat: add date_to_unix_ts/3 function to the rule engine
Fixes:
https://emqx.atlassian.net/browse/EMQX-9245
2023-04-13 16:14:03 +02:00
Stefan Strigler f668ad7b9e
Merge pull request #10336 from sstrigler/EMQX-8507-rule-engine-need-a-new-api-to-crud-rule-engines-setting-configs
feat: add `/rule_engine` API endpoint
2023-04-12 11:44:42 +02:00
Stefan Strigler e6f8682c47 fix: ensure we don't return 'rules' in rule_engine 2023-04-11 15:42:56 +02:00
Kjell Winblad 1938882f16
Merge pull request #10318 from kjellwinblad/kjell/feat/rule_engine_from_clause_support_both_string_types
feat(rule engine sql): enable both ' and " strings in FROM clause
2023-04-06 09:19:44 +02:00
Stefan Strigler 9cfe9cc709 fix: don't allow `rules` to be set from `/rule_engine` 2023-04-05 16:28:54 +02:00
Stefan Strigler aea870f319 feat: add `/rule_engine` API endpoint 2023-04-05 15:19:31 +02:00
Kjell Winblad 0e66eb5f3f feat(rule engine sql): enable both ' and " strings in FROM clause
This commit upgrades the rulesql dependency to version 1.5 instead of
1.4. The difference between these two versions is that strings surrounded
by ' and " are supported in FROM clauses in version 1.5, but in version
1.4, only strings surrounded by " are supported.

Fixes:
https://emqx.atlassian.net/browse/EMQX-9243
2023-04-04 10:36:48 +02:00
Thales Macedo Garitezi f3ffc02bff feat(bridges): enable async query mode for all bridges with buffer workers
Fixes https://emqx.atlassian.net/browse/EMQX-9130

Since buffer workers always support async calls ("outer calls"), we
should decouple those two call modes (inner and outer), and avoid
exposing the inner call configuration to user to avoid complexity.

For bridges that currently only allow sync query modes, we should
allow them to be configured with async.  That means basically all
bridge types except Kafka Producer.
2023-04-03 14:49:51 -03:00
Zaiming (Stone) Shi 80eb9d7542
Merge pull request #10252 from emqx/release-50
0327 merge release-50 to master
2023-03-29 12:33:17 +02:00
Thales Macedo Garitezi 1824e7efcc fix(rule_engine): count referenced bridges in `from` clauses as dependencies (rv5.0)
Fixes https://emqx.atlassian.net/browse/EMQX-9325

Currently, ingress bridges referenced in the `FROM` clause of rules
are not being accounted as dependencies.

When we try to delete an ingress bridge that's referenced in a rule
like `select * from "$bridges/mqtt:ingress"`, that bridge does not
trigger an UI warning about dependent actions.
2023-03-28 10:31:10 -03:00
Zaiming (Stone) Shi f5e9d3eab2 test: use valid config for jq function timeout 2023-03-28 14:29:24 +02:00
Stefan Strigler 6ebd3dc747 feat(emqx_rule_engine): decompose error tuples
sqltester for instance returns sth like {"...sytnax error...", OrigSql}
2023-03-03 09:59:24 +01:00
Stefan Strigler 64b5e9585e feat(emqx_rule_engine): API format errors in a human readable way 2023-03-02 16:49:11 +01:00
Thales Macedo Garitezi eb7dca3691 chore(rule_engine): reset metrics when disabling a rule
https://emqx.atlassian.net/browse/EMQX-8502

When a bridge is disabled, its metrics are reset.  With this change,
we make rule actions behave like that: disabling a rule will reset its
metrics.
2023-01-04 09:30:47 -03:00
Zaiming (Stone) Shi dbc10c2eed chore: update copyright year 2023 2023-01-02 09:22:27 +01:00
JimMoen 4906da9796
test(rule-funcs): test compression funcs 2022-12-19 15:43:50 +08:00
Zaiming (Stone) Shi bd65e8aad6 Merge remote-tracking branch 'origin/release-50' into 1206-chore-merge-ee50-to-release-50 2022-12-06 16:42:50 +01:00
Zaiming (Stone) Shi 1c2fc4b6c3 Merge remote-tracking branch 'origin/release-50' into 1206-chore-merge-ee50-to-release-50 2022-12-06 16:35:56 +01:00
Stefan Strigler 0b324da7cb refactor: move metrics out of /rules(/:id) to /rules/:id/metrics 2022-12-06 15:23:28 +01:00
Zaiming (Stone) Shi cca3421308 refactor: use static function references 2022-12-06 09:40:03 +01:00
Zaiming (Stone) Shi 7ee53e5319 Merge tag 'v5.0.11' into dev/ee5.0 2022-11-28 21:02:21 +01:00
JianBo He 8a0c468b01 test: refine tests for lots of List HTTP API 2022-11-24 20:14:33 +01:00
Zaiming (Stone) Shi f3df2c80d8 feat: add user_properties arg for republish action 2022-11-22 20:09:59 +01:00
kraftwerk28 00c57de4c3 feat: do not drop MQTTv5 properties in rule/bridge 2022-11-22 20:09:59 +01:00
Zaiming (Stone) Shi 09455edae8 Merge tag 'v5.0.10' into dev/ee5.0 2022-11-16 16:20:30 +01:00
JimMoen 4f00206693
test: different resons for disconnect event 2022-11-08 23:22:58 +08:00
Zaiming (Stone) Shi d704de4a84 fix(emqx_rule_events): drop tuple-value from message headers
the message headers are fed to a JSON ecnoder which
may crash if the header value is a tuple
2022-10-27 20:31:33 +02:00
Shawn 60a90858f8 feat: check dependent actions before removing the bridges 2022-09-06 15:34:23 +08:00
Zhongwen Deng 56417a3130 feat: list rules support for pagination and fuzzy filtering 2022-07-25 09:36:08 +08:00
Shawn 6685a3c5a8 fix: remove the 'headers' field from the rule events 2022-06-17 15:57:10 +08:00
Shawn 55fce33477 fix: add telemetry testcases in all/0 2022-05-25 21:55:28 +08:00
Shawn a157539710 refactor(rule): rename http_bridge -> webhook 2022-05-25 18:56:12 +08:00
Shawn 71de9616d3 refactor(rule): rename outputs -> actions 2022-05-25 17:02:37 +08:00
Xinyu Liu 866810cea6
Merge pull request #8006 from emqx/copy-of-kjell/jq/timeout
feat(rule_engine): default timeout for jq/2 and jq/3 with timeout
2022-05-23 11:58:40 +08:00
EMQ-YangM 005fce63d1 feat: add rule engine function float2str/2 2022-05-19 16:16:05 +08:00
EMQ-YangM 66c62f432b fix: zero padding should be to the MSB side 2022-05-18 15:28:01 +08:00
Kjell Winblad 05032467bd feat(rule_engine): default timeout for jq/2 and jq/3 with timeout
This commit adds a default timeout of 10 seconds to the rule engine's
`jq/2` function, and adds a new function `jq/3` (where the last parameter is
a timeout value). The default timeout can be configured with the setting
"rule_engine.jq_function_default_timeout".

Having a timeout when executing jq code in the rule engine is important
as jq code can potentially run forever. Also, the Erlang jq library
limits the number of jq programs that can execute concurrently so a jq
program that loops forever could potentially also prevent a "non-buggy"
jq program from ever starting.
2022-05-17 19:36:32 +02:00
EMQ-YangM d8da8f1686 fix: hexstr_to_bin support half byte 2022-05-17 16:47:59 +08:00
DDDHuang 5210cd6e8d fix(test): rule engine api SUITE , bad rule name 2022-05-12 18:01:37 +08:00
EMQ-YangM 685b06eeed fix: avoid 'rule_test' api crash 2022-05-05 17:28:59 +08:00
Kjell Winblad 74c33cd4e5 feat(rule_engine): add jq function to the rule engine
This commit adds a function to the rule engine that alows users
to transform text or JSON objects using [jq filter programs][1].

[jq][1] is a command line tool that can be used to transform
and filter JSON text using jq's built-in language. The rule engine
function that is added with this commit uses the
[Erlang jq NIF library][2] that wraps the jq C library in an
Erlang NIF function.

[1]: https://stedolan.github.io/jq/
[2]: https://github.com/emqx/jq
2022-05-04 17:09:16 +02:00
Zaiming (Stone) Shi 02c3f87b31 style: reformat all remaining apps 2022-04-27 15:51:18 +02:00
EMQ-YangM 1fac70d2bb fix: remove error field 2022-04-27 09:48:57 +08:00
EMQ-YangM e4b62f3a5f feat: add rule-engine functions 2022-04-15 18:02:24 +08:00
EMQ-YangM ee6ac90d47 fix: behavior of rule-engine when selection field does not exist 2022-04-13 18:19:42 +08:00
EMQ-YangM fa0c4d17ee feat: impl rule_engine reset_metrics api 2022-04-11 10:25:48 +08:00
Thales Macedo Garitezi 1aea6b3ea7
Merge pull request #7522 from thalesmg/telemetry-revamp-part5
feat: add basic rule engine and bridge usage info to telemetry
2022-04-07 10:19:55 -03:00
Thales Macedo Garitezi 8354095e4b
feat(rules): export basic usage info for telemetry 2022-04-06 10:20:23 -03:00
EMQ-YangM a31891e8e6 feat: enhanced rule engine error handling when json parsing error 2022-04-06 09:56:55 +08:00
Thales Macedo Garitezi ed7035ec41
style(bridge): please elvis checks 2022-04-05 15:59:50 -03:00
EMQ-YangM ccc134d061 fix(emqx_rule_api_schema): add rule events schema 2022-03-29 14:03:15 +08:00
EMQ-YangM 4791c64b73 feat: add rule event 'client.check_authz_complete' 2022-03-29 11:24:36 +08:00
EMQ-YangM 65164fb046 feat: add rule event 'client.connack' 2022-03-28 11:32:07 +08:00
Shawn b69dca4f08 feat(rule): add testcase for '/delivery_dropped' 2022-02-08 20:37:40 +08:00
Kian-Meng Ang fc92e4c8bf docs: fix typos 2022-01-27 12:29:38 +01:00
Zaiming (Stone) Shi 2105d1f22b test: call ct helpers to load config 2022-01-25 11:50:18 +01:00
Shawn 8cee9a9e47 fix(rule): compare to null variables should return false 2022-01-17 14:17:49 +08:00
Zaiming (Stone) Shi 63167cea70 chore: update copyright 2022-01-05 20:55:00 +01:00
Shawn affe69afd6 fix(rules): update the test cases for rule APIs 2021-12-07 09:48:47 +08:00
Ilya Averyanov ea0fa24ce5 chore(ct): remove verbose output during tests 2021-11-25 18:30:50 +03:00
Shawn 4c149f92c1 feat(bridge): support metrics for bridges 2021-11-23 09:36:10 +08:00
JimMoen dcc5ae0642 test: API return code section 2021-11-15 16:30:44 +08:00
zhongwencool d784e63b9f
emqx_conf (#5939)
* feat(emqx_conf): move conf manager for emqx_machine to emqx_conf

* chore(emqx_conf): change emqx:get_config/2 to emqx_conf:get/2

* fix: common test failed

* fix: badmatch by typo wrong key

* fix(emqx_conf): get the wrong core nodes

* fix(emqx_conf): get core node's tnx_id not latest tnx_id

* fix: add ro_transation when copy conf file

* fix: delete debug info

* fix: change ekka_rlog to mria_rlog

* fix: remove cluster_rpc from emqx_machine.

* fix: don't call ekka:start/0 explicitly

* fix: ekka should be start in emqx_machine
2021-10-21 18:08:51 +08:00
Tobias Lindahl aa19c2a908 chore: Remove emqx_ct_helpers as dependency 2021-10-15 10:40:57 +02:00
Shawn 0e7a3f89a9 feat(rules): support output functions in <<"Mod:Func">> format 2021-10-14 15:09:37 +08:00
Shawn 9c7eef5295 feat(rules): update rule_engine configs from APIs 2021-10-14 15:09:37 +08:00
Shawn 1ffae5d1b0 refactor(rule_engine): merge code for emqx_rule_registry and emqx_rule_engine 2021-10-14 15:09:37 +08:00
Shawn b063b6f253 feat(rules): support configure rules in config file 2021-10-14 15:09:37 +08:00
lafirest 3524942766 fix: change all ~s in io format to ~ts
we should use unicode to replace latin1
2021-10-12 15:09:24 +08:00
Shawn 0d26e50e87 fix(rules): parse outputs failed 2021-09-26 23:00:08 +08:00
Shawn 420ccf0f51 refactor(rules): change republish as an output 2021-09-26 23:00:08 +08:00
Shawn f33e28af6d fix(rules): update test cases for emqx_rule_engine_SUITE 2021-09-26 23:00:08 +08:00
Shawn 7bc69b129a fix(rules): update test cases for rule metrics 2021-09-26 23:00:08 +08:00
Shawn af295a9b71 refactor(rules): remove resources and actions 2021-09-26 23:00:08 +08:00
Shawn b055464f6b refactor(rule): remove CLIs for rules
We will have new CLIs based on HTTP API in the future.
2021-09-26 23:00:08 +08:00
Shawn d46241fe2f feat(bridges): avoid clientid competition between bridges on different nodes 2021-09-10 14:21:17 +08:00
Shawn 1dae970cd3 refactor(rule): move emqx_rule_utils.erl -> emqx_plugin_libs_rule.erl 2021-09-10 11:43:03 +08:00
zhongwencool 73238ed81f feat: emqx_resource support cluster_call 2021-08-26 17:23:39 +08:00
zhongwencool e5129ead6d fix(CI): Error detected: 'Invalid reference to group api in emqx_rule_engine_SUITE:all/0' 2021-08-26 17:17:47 +08:00