Skip to content

Commit

Permalink
refactor: remove unused code and correct the docs for logger plugins (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Vacant2333 authored Dec 12, 2023
1 parent 986f356 commit 4db435e
Show file tree
Hide file tree
Showing 46 changed files with 99 additions and 65 deletions.
4 changes: 3 additions & 1 deletion apisix/plugins/clickhouse-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/elasticsearch-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/file-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format
log_format = {
type = "object"
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/google-cloud-logging.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/http-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/kafka-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/loki-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/rocketmq-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/skywalking-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/splunk-hec-logging.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/syslog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ local schema = batch_processor_manager:wrap_schema(schema)
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/tcp-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/tencent-cloud-cls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/plugins/udp-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ local schema = {
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
4 changes: 3 additions & 1 deletion apisix/stream/plugins/syslog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ local schema = batch_processor_manager:wrap_schema(schema)
local metadata_schema = {
type = "object",
properties = {
log_format = log_util.metadata_schema_log_format,
log_format = {
type = "object"
}
},
}

Expand Down
8 changes: 0 additions & 8 deletions apisix/utils/log-util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ local lru_log_format = core.lrucache.new({
})

local _M = {}
_M.metadata_schema_log_format = {
type = "object",
default = {
["host"] = "$host",
["@timestamp"] = "$time_iso8601",
["client_ip"] = "$remote_addr",
},
}


local function gen_log_format(format)
Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/plugins/clickhouse-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The `clickhouse-logger` Plugin is used to push logs to [ClickHouse](https://clic
| timeout | integer | False | 3 | [1,...] | Time to keep the connection alive for after sending a request. |
| name | string | False | "clickhouse logger" | | Unique identifier for the logger. |
| ssl_verify | boolean | False | true | [true,false] | When set to `true`, verifies SSL. |
| 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | object | False | | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| include_req_body | boolean | False | false | [false, true] | When set to `true` includes the request body in the log. If the request body is too big to be kept in the memory, it can't be logged due to Nginx's limitations. |
| include_req_body_expr | array | False | | | Filter for when the `include_req_body` attribute is set to `true`. Request body is only logged when the expression set here evaluates to `true`. See [lua-resty-expr](https://github.com/api7/lua-resty-expr) for more. |
| include_resp_body | boolean | False | false | [false, true] | When set to `true` includes the response body in the log. |
Expand All @@ -60,7 +60,7 @@ You can also set the format of the logs by configuring the Plugin metadata. The

| 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | object | False | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |

:::info IMPORTANT

Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/plugins/elasticsearch-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ When the Plugin is enabled, APISIX will serialize the request context informatio
| field | array | True | | Elasticsearch `field` configuration. |
| field.index | string | True | | Elasticsearch [_index field](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index-field.html#mapping-index-field). |
| field.type | string | False | Elasticsearch default value | Elasticsearch [_type field](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/mapping-type-field.html#mapping-type-field). |
| 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | object | False | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| auth | array | False | | Elasticsearch [authentication](https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-up-authentication.html) configuration. |
| auth.username | string | True | | Elasticsearch [authentication](https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-up-authentication.html) username. |
| auth.password | string | True | | Elasticsearch [authentication](https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-up-authentication.html) password. |
Expand Down Expand Up @@ -195,7 +195,7 @@ You can also set the format of the logs by configuring the Plugin metadata. The

| 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | object | False | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |

:::info IMPORTANT

Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/plugins/file-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can also set the format of the logs by configuring the Plugin metadata. The

| 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | object | False | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |

The example below shows how you can configure through the Admin API:

Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/plugins/google-cloud-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This plugin also allows to push logs as a batch to your Google Cloud Logging Ser
| ssl_verify | False | true | When set to `true`, enables SSL verification as mentioned in [OpenResty docs](https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake). |
| resource | False | {"type": "global"} | Google monitor resource. See [MonitoredResource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/MonitoredResource) for more details. |
| log_id | False | apisix.apache.org%2Flogs | Google Cloud logging ID. See [LogEntry](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry) for details. |
| log_format | 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | False | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |

NOTE: `encrypt_fields = {"auth_config.private_key"}` is also defined in the schema, which means that the field will be stored encrypted in etcd. See [encrypted storage fields](../plugin-develop.md#encrypted-storage-fields).

Expand All @@ -59,7 +59,7 @@ You can also set the format of the logs by configuring the Plugin metadata. The

| 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | object | False | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |

:::info IMPORTANT

Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/plugins/http-logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This will allow the ability to send log data requests as JSON objects to monitor
| uri | string | True | | | URI of the HTTP/HTTPS server. |
| auth_header | string | False | | | Authorization headers if required. |
| timeout | integer | False | 3 | [1,...] | Time to keep the connection alive for after sending a request. |
| 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | object | False | | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| include_req_body | boolean | False | false | [false, true] | When set to `true` includes the request body in the log. If the request body is too big to be kept in the memory, it can't be logged due to Nginx's limitations. |
| include_resp_body | boolean | False | false | [false, true] | When set to `true` includes the response body in the log. |
| 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 if the expression evaluates to `true`. |
Expand All @@ -59,7 +59,7 @@ You can also set the format of the logs by configuring the Plugin metadata. The

| 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](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |
| log_format | object | False | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |

:::info IMPORTANT

Expand Down
Loading

0 comments on commit 4db435e

Please sign in to comment.