rocketmq-logger
It might take some time to receive the log data. It will be automatically sent after the timer function in the expires.
Attributes
NOTE: encrypt_fields = {"secret_key"}
is also defined in the schema, which means that the field will be stored encrypted in etcd. See .
This Plugin supports using batch processors to aggregate and process entries (logs/data) in a batch. This avoids the need for frequently submitting the data. The batch processor submits data every 5
seconds or when the data in the queue reaches 1000
. See Batch Processor for more information or setting your custom configuration.
IMPORTANT
The data is first written to a buffer. When the buffer exceeds the batch_max_size
or attribute, the data is sent to the RocketMQ server and the buffer is flushed.
default
:origin
:host: localhost
content-length: 6
connection: close
abcdef
You can also set the format of the logs by configuring the Plugin metadata. The following configurations are available:
Name | Type | Required | Default | Description |
---|---|---|---|---|
log_format | object | False | {“host”: “$host”, “@timestamp”: “$time_iso8601”, “client_ip”: “$remote_addr”} | Log format declared as key value pairs in JSON format. Values only support strings. APISIX or variables can be used by prefixing the string with $ . |
IMPORTANT
Configuring the Plugin metadata is global in scope. This means that it will take effect on all Routes and Services which use the rocketmq-logger
Plugin.
With this configuration, your logs would be formatted as shown below:
{"host":"localhost","@timestamp":"2020-09-23T19:05:05-04:00","client_ip":"127.0.0.1","route_id":"1"}
{"host":"localhost","@timestamp":"2020-09-23T19:05:05-04:00","client_ip":"127.0.0.1","route_id":"1"}
Enabling the Plugin
The example below shows how you can enable the rocketmq-logger
Plugin on a specific Route:
This Plugin also supports pushing to more than one nameserver at a time. You can specify multiple nameserver in the Plugin configuration as shown below:
"127.0.0.1:9876",
"127.0.0.2:9876"
]
Now, if you make a request to APISIX, it will be logged in your RocketMQ server:
Disable Plugin
{
"methods": ["GET"],
"uri": "/hello",
"plugins": {},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
}