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:

    1. host: localhost
    2. content-length: 6
    3. connection: close
    4. abcdef

You can also set the format of the logs by configuring the Plugin metadata. The following configurations are available:

NameTypeRequiredDefaultDescription
log_formatobjectFalse{“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 $.
rocketmq-logger - 图2IMPORTANT

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:

  1. {"host":"localhost","@timestamp":"2020-09-23T19:05:05-04:00","client_ip":"127.0.0.1","route_id":"1"}
  2. {"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:

  1. "127.0.0.1:9876",
  2. "127.0.0.2:9876"
  3. ]

Now, if you make a request to APISIX, it will be logged in your RocketMQ server:

Disable Plugin

  1. {
  2. "methods": ["GET"],
  3. "uri": "/hello",
  4. "plugins": {},
  5. "upstream": {
  6. "type": "roundrobin",
  7. "nodes": {
  8. "127.0.0.1:1980": 1
  9. }
  10. }