rules create

    • <sql>: 规则 SQL
    • <actions>: JSON 格式的动作列表

    使用举例:

    上例创建了一个 ID 为 rule:9a6a725d 的规则,动作列表里只有一个动作:动作名为 inspect,动作的参数是 {"a": 1}

    rules list

    列出当前所有的规则:

    1. $ ./bin/emqx_ctl rules list
    2. rule(id='rule:9a6a725d', for='['t/a']', rawsql='select * from "t/a"', actions=[{"metrics":...,"name":"inspect","params":...}], metrics=..., enabled='true', description='Rule for debug')

    rules show

    查询规则:

    1. ## 查询 RuleID 为 'rule:9a6a725d' 的规则
    2. $ ./bin/emqx_ctl rules show 'rule:9a6a725d'
    3. rule(id='rule:9a6a725d', for='['t/a']', rawsql='select * from "t/a"', actions=[{"metrics":...,"name":"inspect","params":...}], metrics=..., enabled='true', description='Rule for debug')

    rules delete

    删除规则:

    1. $ ./bin/emqx_ctl rules delete 'rule:9a6a725d'
    2. ok

    rule-actions show

    查询动作:

    rule-actions list

    列出符合条件的动作:

    1. ## 列出当前所有的动作
    2. $ ./bin/emqx_ctl rule-actions list
    3. action(name='data_to_rabbit', app='emqx_bridge_rabbit', types=[bridge_rabbit], title ='Data bridge to RabbitMQ', description='Store Data to Kafka')
    4. action(name='data_to_timescaledb', app='emqx_backend_pgsql', types=[timescaledb], title ='Data to TimescaleDB', description='Store data to TimescaleDB')
    5. ...

    resources create

    创建一个新的资源,参数:

    • type: 资源类型
    • -d descr: 可选,资源的描述

      $ ./bin/emqx_ctl resources create ‘web_hook’ -c ‘{“url”: “‘ -d ‘forward msgs to host-name/chats’

    resources list

    列出当前所有的资源:

    1. resource(id='resource:a7a38187', type='web_hook', config=#{<<"url">> => <<"http://host-name/chats">>}, status=#{is_alive => false}, description='forward msgs to host-name/chats')

    列出当前某个类型的资源:

    1. $ ./bin/emqx_ctl resources list --type='web_hook'
    2. resource(id='resource:a7a38187', type='web_hook', config=#{<<"url">> => <<"http://host-name/chats">>}, status=#{is_alive => false}, description='forward msgs to host-name/chats')

    resources show

    查询资源:

    resources delete

    删除资源:

    1. $ ./bin/emqx_ctl resources delete 'resource:a7a38187'
    2. ok

    资源类型可以由 EMQ X 内置(称为系统内置资源类型),或者由 EMQ X 插件编写,但不能通过 CLI/API 添加或删除。

    resource-types list

    1. ./bin/emqx_ctl resource-types list
    2. resource_type(name='backend_mongo_rs', provider='emqx_backend_mongo', title ='MongoDB Replica Set Mode', description='MongoDB Replica Set Mode')
    3. resource_type(name='backend_cassa', provider='emqx_backend_cassa', title ='Cassandra', description='Cassandra Database')
    4. ...

    resource-types show

    查询资源类型:

    1. $ ./bin/emqx_ctl resource-types show backend_mysql
    2. resource_type(name='backend_mysql', provider='emqx_backend_mysql', title ='MySQL', description='MySQL Database')