Skip to content

Commit

Permalink
docs: Add default log format for each logger plugin (#10764)
Browse files Browse the repository at this point in the history
  • Loading branch information
smileby authored Jan 10, 2024
1 parent 1e15629 commit 131f20a
Show file tree
Hide file tree
Showing 32 changed files with 1,047 additions and 1 deletion.
43 changes: 43 additions & 0 deletions docs/en/latest/plugins/clickhouse-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,49 @@ NOTE: `encrypt_fields = {"password"}` is also defined in the schema, which means

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](../batch-processor.md#configuration) for more information or setting your custom configuration.

### Example of default log format

```json
{
"response": {
"status": 200,
"size": 118,
"headers": {
"content-type": "text/plain",
"connection": "close",
"server": "APISIX/3.7.0",
"content-length": "12"
}
},
"client_ip": "127.0.0.1",
"upstream_latency": 3,
"apisix_latency": 98.999998092651,
"upstream": "127.0.0.1:1982",
"latency": 101.99999809265,
"server": {
"version": "3.7.0",
"hostname": "localhost"
},
"route_id": "1",
"start_time": 1704507612177,
"service_id": "",
"request": {
"method": "POST",
"querystring": {
"foo": "unknown"
},
"headers": {
"host": "localhost",
"connection": "close",
"content-length": "18"
},
"size": 110,
"uri": "/hello?foo=unknown",
"url": "http://localhost:1984/hello?foo=unknown"
}
}
```

## Metadata

You can also set the format of the logs by configuring the Plugin metadata. The following configurations are available:
Expand Down
40 changes: 40 additions & 0 deletions docs/en/latest/plugins/elasticsearch-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,46 @@ NOTE: `encrypt_fields = {"auth.password"}` is also defined in the schema, which

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](../batch-processor.md#configuration) for more information or setting your custom configuration.

### Example of default log format

```json
{
"upstream_latency": 2,
"apisix_latency": 100.9999256134,
"request": {
"size": 59,
"url": "http://localhost:1984/hello",
"method": "GET",
"querystring": {},
"headers": {
"host": "localhost",
"connection": "close"
},
"uri": "/hello"
},
"server": {
"version": "3.7.0",
"hostname": "localhost"
},
"client_ip": "127.0.0.1",
"upstream": "127.0.0.1:1980",
"response": {
"status": 200,
"headers": {
"content-length": "12",
"connection": "close",
"content-type": "text/plain",
"server": "APISIX/3.7.0"
},
"size": 118
},
"start_time": 1704524807607,
"route_id": "1",
"service_id": "",
"latency": 102.9999256134
}
```

## Enable Plugin

### Full configuration
Expand Down
6 changes: 6 additions & 0 deletions docs/en/latest/plugins/error-log-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ NOTE: `encrypt_fields = {"clickhouse.password"}` is also defined in the schema,

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](../batch-processor.md#configuration) for more information or setting your custom configuration.

### Example of default log format

```text
["2024/01/06 16:04:30 [warn] 11786#9692271: *1 [lua] plugin.lua:205: load(): new plugins: {"error-log-logger":true}, context: init_worker_by_lua*","\n","2024/01/06 16:04:30 [warn] 11786#9692271: *1 [lua] plugin.lua:255: load_stream(): new plugins: {"limit-conn":true,"ip-restriction":true,"syslog":true,"mqtt-proxy":true}, context: init_worker_by_lua*","\n"]
```

## Enable Plugin

To enable the Plugin, you can add it in your configuration file (`conf/config.yaml`):
Expand Down
44 changes: 44 additions & 0 deletions docs/en/latest/plugins/file-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,50 @@ The `file-logger` Plugin is used to push log streams to a specific location.
| include_resp_body_expr | array | False | When the `include_resp_body` attribute is set to `true`, use this to filter based on [lua-resty-expr](https://github.com/api7/lua-resty-expr). If present, only logs the response into file if the expression evaluates to `true`. |
| match | array[] | False | Logs will be recorded when the rule matching is successful if the option is set. See [lua-resty-expr](https://github.com/api7/lua-resty-expr#operator-list) for a list of available expressions. |

### Example of default log format

```json
{
"service_id": "",
"apisix_latency": 100.99999809265,
"start_time": 1703907485819,
"latency": 101.99999809265,
"upstream_latency": 1,
"client_ip": "127.0.0.1",
"route_id": "1",
"server": {
"version": "3.7.0",
"hostname": "localhost"
},
"request": {
"headers": {
"host": "127.0.0.1:1984",
"content-type": "application/x-www-form-urlencoded",
"user-agent": "lua-resty-http/0.16.1 (Lua) ngx_lua/10025",
"content-length": "12"
},
"method": "POST",
"size": 194,
"url": "http://127.0.0.1:1984/hello?log_body=no",
"uri": "/hello?log_body=no",
"querystring": {
"log_body": "no"
}
},
"response": {
"headers": {
"content-type": "text/plain",
"connection": "close",
"content-length": "12",
"server": "APISIX/3.7.0"
},
"status": 200,
"size": 123
},
"upstream": "127.0.0.1:1982"
}
```

## Metadata

You can also set the format of the logs by configuring the Plugin metadata. The following configurations are available:
Expand Down
30 changes: 30 additions & 0 deletions docs/en/latest/plugins/google-cloud-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,36 @@ NOTE: `encrypt_fields = {"auth_config.private_key"}` is also defined in the sche

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](../batch-processor.md#configuration) for more information or setting your custom configuration.

### Example of default log format

```json
{
"insertId": "0013a6afc9c281ce2e7f413c01892bdc",
"labels": {
"source": "apache-apisix-google-cloud-logging"
},
"logName": "projects/apisix/logs/apisix.apache.org%2Flogs",
"httpRequest": {
"requestMethod": "GET",
"requestUrl": "http://localhost:1984/hello",
"requestSize": 59,
"responseSize": 118,
"status": 200,
"remoteIp": "127.0.0.1",
"serverIp": "127.0.0.1:1980",
"latency": "0.103s"
},
"resource": {
"type": "global"
},
"jsonPayload": {
"service_id": "",
"route_id": "1"
},
"timestamp": "2024-01-06T03:34:45.065Z"
}
```

## Metadata

You can also set the format of the logs by configuring the Plugin metadata. The following configurations are available:
Expand Down
44 changes: 44 additions & 0 deletions docs/en/latest/plugins/http-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,50 @@ This Plugin supports using batch processors to aggregate and process entries (lo

:::

### Example of default log format

```json
{
"service_id": "",
"apisix_latency": 100.99999809265,
"start_time": 1703907485819,
"latency": 101.99999809265,
"upstream_latency": 1,
"client_ip": "127.0.0.1",
"route_id": "1",
"server": {
"version": "3.7.0",
"hostname": "localhost"
},
"request": {
"headers": {
"host": "127.0.0.1:1984",
"content-type": "application/x-www-form-urlencoded",
"user-agent": "lua-resty-http/0.16.1 (Lua) ngx_lua/10025",
"content-length": "12"
},
"method": "POST",
"size": 194,
"url": "http://127.0.0.1:1984/hello?log_body=no",
"uri": "/hello?log_body=no",
"querystring": {
"log_body": "no"
}
},
"response": {
"headers": {
"content-type": "text/plain",
"connection": "close",
"content-length": "12",
"server": "APISIX/3.7.0"
},
"status": 200,
"size": 123
},
"upstream": "127.0.0.1:1982"
}
```

## Metadata

You can also set the format of the logs by configuring the Plugin metadata. The following configurations are available:
Expand Down
6 changes: 6 additions & 0 deletions docs/en/latest/plugins/loggly.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ This Plugin supports using batch processors to aggregate and process entries (lo

To generate a Customer token, go to `<your assigned subdomain>/loggly.com/tokens` or navigate to Logs > Source setup > Customer tokens.

### Example of default log format

```text
<10>1 2024-01-06T06:50:51.739Z 127.0.0.1 apisix 58525 - [token-1@41058 tag="apisix"] {"service_id":"","server":{"version":"3.7.0","hostname":"localhost"},"apisix_latency":100.99985313416,"request":{"url":"http://127.0.0.1:1984/opentracing","headers":{"content-type":"application/x-www-form-urlencoded","user-agent":"lua-resty-http/0.16.1 (Lua) ngx_lua/10025","host":"127.0.0.1:1984"},"querystring":{},"uri":"/opentracing","size":155,"method":"GET"},"response":{"headers":{"content-type":"text/plain","server":"APISIX/3.7.0","transfer-encoding":"chunked","connection":"close"},"size":141,"status":200},"route_id":"1","latency":103.99985313416,"upstream_latency":3,"client_ip":"127.0.0.1","upstream":"127.0.0.1:1982","start_time":1704523851634}
```

## Metadata

You can also configure the Plugin through Plugin metadata. The following configurations are available:
Expand Down
42 changes: 42 additions & 0 deletions docs/en/latest/plugins/loki-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,48 @@ When the Plugin is enabled, APISIX will serialize the request context informatio

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](../batch-processor.md#configuration) for more information or setting your custom configuration.

### Example of default log format

```json
{
"request": {
"headers": {
"connection": "close",
"host": "localhost",
"test-header": "only-for-test#1"
},
"method": "GET",
"uri": "/hello",
"url": "http://localhost:1984/hello",
"size": 89,
"querystring": {}
},
"client_ip": "127.0.0.1",
"start_time": 1704525701293,
"apisix_latency": 100.99994659424,
"response": {
"headers": {
"content-type": "text/plain",
"server": "APISIX/3.7.0",
"content-length": "12",
"connection": "close"
},
"status": 200,
"size": 118
},
"route_id": "1",
"loki_log_time": "1704525701293000000",
"upstream_latency": 5,
"latency": 105.99994659424,
"upstream": "127.0.0.1:1980",
"server": {
"hostname": "localhost",
"version": "3.7.0"
},
"service_id": ""
}
```

## Metadata

You can also set the format of the logs by configuring the Plugin metadata. The following configurations are available:
Expand Down
55 changes: 55 additions & 0 deletions docs/en/latest/plugins/rocketmq-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,61 @@ If the process is successful, it will return `true` and if it fails, returns `ni

### meta_format example

- default:

```json
{
"upstream": "127.0.0.1:1980",
"start_time": 1619414294760,
"client_ip": "127.0.0.1",
"service_id": "",
"route_id": "1",
"request": {
"querystring": {
"ab": "cd"
},
"size": 90,
"uri": "/hello?ab=cd",
"url": "http://localhost:1984/hello?ab=cd",
"headers": {
"host": "localhost",
"content-length": "6",
"connection": "close"
},
"method": "GET"
},
"response": {
"headers": {
"connection": "close",
"content-type": "text/plain; charset=utf-8",
"date": "Mon, 26 Apr 2021 05:18:14 GMT",
"server": "APISIX/2.5",
"transfer-encoding": "chunked"
},
"size": 190,
"status": 200
},
"server": {
"hostname": "localhost",
"version": "2.5"
},
"latency": 0
}
```

- origin:

```http
GET /hello?ab=cd HTTP/1.1
host: localhost
content-length: 6
connection: close
abcdef
```

### meta_format example

- `default`:

```json
Expand Down
Loading

0 comments on commit 131f20a

Please sign in to comment.