Rules management

    The command is used for creating a rule. The rule’s definition is specified with JSON format, read rule for more detailed information.

    The rule can be created with two ways.

    • Specify the rule definition in command line. Notice that, the json string must be quoted.

    Sample:

    The command create a rule named rule1.

    • Specify the rule definition in file. If the rule is complex, or the rule is already wrote in text files with well organized formats, you can just specify the rule definition through -f option.

    Sample:

    1. # bin/kuiper create rule rule1 -f /tmp/rule.txt

    Below is the contents of rule.txt.

    1. {
    2. "sql": "SELECT * from demo",
    3. "actions": [
    4. {
    5. "log": {}
    6. },
    7. {
    8. "mqtt": {
    9. "server": "tcp://127.0.0.1:1883",
    10. "topic": "demoSink"
    11. }
    12. }
    13. ]
    14. }

    show rules

    1. show rules

    Sample:

    1. # bin/kuiper show rules
    2. [
    3. {
    4. "id": "rule1",
    5. },
    6. {
    7. "id": "rule2",
    8. "status": "Stopped: canceled by error."
    9. ]

    describe a rule

    The command is used for print the detailed definition of rule.

    Sample:

    1. # bin/kuiper describe rule rule1
    2. {
    3. "sql": "SELECT * from demo",
    4. "actions": [
    5. {
    6. "log": {}
    7. },
    8. {
    9. "mqtt": {
    10. "server": "tcp://127.0.0.1:1883",
    11. "topic": "demoSink"
    12. }
    13. }
    14. ]
    15. }

    The command is used for drop the rule.

    1. drop rule $rule_name

    Sample:

    1. # bin/kuiper drop rule rule1
    2. Rule rule1 is dropped.

    start a rule

    The command is used to start running the rule.

    1. start rule $rule_name
    1. # bin/kuiper start rule rule1
    2. Rule rule1 was started.

    stop a rule

    The command is used to stop running the rule.

    Sample:

    1. # bin/kuiper stop rule rule1
    2. Rule rule1 was stopped.

    The command is used to restart the rule.

    1. restart rule $rule_name

    Sample:

    1. # bin/kuiper restart rule rule1
    2. Rule rule1 was restarted.

    get the status of a rule

    The command is used to get the status of the rule. If the rule is running, the metrics will be retrieved realtime. The status can be

    • stopped: $reason
    1. getstatus rule $rule_name

    Sample:

    1. {
    2. "source_demo_0_records_in_total":5,
    3. "source_demo_0_records_out_total":5,
    4. "source_demo_0_exceptions_total":0,
    5. "source_demo_0_process_latency_ms":0,
    6. "source_demo_0_buffer_length":0,
    7. "source_demo_0_last_invocation":"2020-01-02T11:28:33.054821",
    8. ...
    9. "op_filter_0_records_in_total":5,
    10. "op_filter_0_records_out_total":2,
    11. "op_filter_0_exceptions_total":0,
    12. "op_filter_0_process_latency_ms":0,
    13. "op_filter_0_buffer_length":0,
    14. "op_filter_0_last_invocation":"2020-01-02T11:28:33.054821",
    15. ...
    16. }

    get the topology structure of a rule

    • sources: it is a string array of the names of all source nodes. They are the entry of the topology.
    • edges: it is a hash map of all edges categorized by nodes. The keys are the starting point of an edge. And the value is a collection of ending point.

    Sample result:

    1. {
    2. "sources": [
    3. "source_stream"
    4. ],
    5. "edges": {
    6. "op_project": [
    7. "sink_log"
    8. ],
    9. "source_stream": [
    10. "op_project"
    11. ]