forward接口接入
M³Meta平台提供forward命令接口,支持外部系统通过调用forward命令发送数据到M³Meta平台。
使用
- 通过管道传输数据给forward程序进行数据转发到规则
NAME:
forward - The matrix remote forward.
USAGE:
forward [global options] command [command options] [arguments...]
VERSION:
0.4.1
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
-r value, --remote value Remote server address. If it is nats protocol (nats://), use nats streaming to send. (default: "http://127.0.0.1:8080/agent")
-u value, --username value Login username.
-p value, --password value Login password.
-s value, --subject value Set Message subject.
--rule value Set Message rule. ("rule" and "subject" choose one, the rule exists subject will be invalid)
-t value, --timeout value Request timeout. (default: 5)
-c value, --config value Config file.
-d value, --delimiter value Data Delimiter. (default: "\n")
-l value, --limit value Forward limit. (default: 0)
--datatype value Data type.[text|csv|json] (default: "text")
--debug Debug mode, print debug message.
--printonce Print statistics result only once.
--ignoresending value Ignore the number of sending. (default: 0)
--limitsending value Limit the number of sending. (default: 0)
--useprotocol Use toe protocol to send message.
--attr value Toe message attribute, json format.
--help, -h show help
--version, -v print the version
示例
echo Hello,1 | ./forward -c config.toml
config.toml 示例
remote = "nats://user:password@172.23.12.229:4222" # Data is sent to a remote address, HTTP (http://127.0.0.1:8080/agent) or Nats (nats://user:password@127.0.0.1:4222)
rule = "/matrix/rules/test/forward" # The rule path for receiving data
debug = true # Print debug message.
delimiter = "," # Data split symbol.
limit = 0 # read data limit size. Default 0 is unlimited.
datatype = "csv" # Data format.
printonce = false # Print statistics result only once.
ignoresending = 0 # Ignore the number of sending. Default 0 is not ignored.
limitsending = 0 # Limit the number of sending. Default 0 is unlimited.
useprotocol = false # Use toe protocol to send message. (HTTP mode required)
attrs = "" # Toe message attribute, json format. This configuration is only valid if configuration useprotocol=true. (HTTP mode required)
username = "admin" # Login username. (HTTP mode required)
password = "admin" # Login password. (HTTP mode required)
timeout = 5 # Timeout. (HTTP mode required)