You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/06/27 05:52:04 UTC
[apisix] branch master updated: docs: update "Loggers" Plugins 5/5 (#7308)
This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 436279c5a docs: update "Loggers" Plugins 5/5 (#7308)
436279c5a is described below
commit 436279c5ac73a8a755ba2b61c1dacfcb163d4ee8
Author: Navendu Pottekkat <na...@gmail.com>
AuthorDate: Mon Jun 27 11:21:57 2022 +0530
docs: update "Loggers" Plugins 5/5 (#7308)
---
docs/en/latest/plugins/file-logger.md | 88 +++++++++++++------------
docs/en/latest/plugins/loggly.md | 97 ++++++++++++++++------------
docs/en/latest/plugins/splunk-hec-logging.md | 54 +++++++++-------
3 files changed, 129 insertions(+), 110 deletions(-)
diff --git a/docs/en/latest/plugins/file-logger.md b/docs/en/latest/plugins/file-logger.md
index 27bc93d69..8ad5cc1de 100644
--- a/docs/en/latest/plugins/file-logger.md
+++ b/docs/en/latest/plugins/file-logger.md
@@ -1,5 +1,11 @@
---
title: file-logger
+keywords:
+ - APISIX
+ - API Gateway
+ - Plugin
+ - File Logger
+description: This document contains information about the Apache APISIX file-logger Plugin.
---
<!--
@@ -23,17 +29,45 @@ title: file-logger
## Description
-`file-logger` is a plugin that pushes a stream of log data to a specified location. For example, the output path can be customized: `logs/file.log`.
+The `file-logger` Plugin is used to push log streams to a specific location.
## Attributes
-| Name | Type | Requirement | Default | Valid | Description |
-| ---------------- | ------- | ------ | ------------- | ------- | ------------------------------------------------ |
-| path | string | required | | | Customise the output file path |
+| Name | Type | Required | Description |
+| ---- | ------ | -------- | ------------- |
+| path | string | True | Log file path. |
-## How To Enable
+## Metadata
+
+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](../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:
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/file-logger -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+ "log_format": {
+ "host": "$host",
+ "@timestamp": "$time_iso8601",
+ "client_ip": "$remote_addr"
+ }
+}'
+```
+
+With this configuration, your logs would be formatted as shown below:
+
+```shell
+{"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
-This is an example of how to enable the `file-logger` plugin for a specific route.
+The example below shows how you can enable the Plugin on a specific Route:
```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
@@ -53,52 +87,22 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}'
```
-## Test Plugin
+## Example usage
-> success:
+Now, if you make a request, it will be logged in the path you specified:
```shell
-$ curl -i http://127.0.0.1:9080/hello
-HTTP/1.1 200 OK
-...
-hello, world
+curl -i http://127.0.0.1:9080/hello
```
-You can then find the `file.log` file in the corresponding `logs` directory.
-
-## Metadata
-
-| Name | Type | Requirement | Default | Valid | Description |
-| ---------------- | ------- | ----------- | ------------- | ------- | ---------------------------------------------------------------------------------------- |
-| log_format | object | optional | {"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"} | | Log format declared as key value pair in JSON format. Only string is supported in the `value` part. If the value starts with `$`, it means to get [APISIX variable](../apisix-variable.md) or [Nginx variable](http://nginx.org/en/docs/varindex.html). |
-
-### Example
-
-```shell
-curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/file-logger -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
-{
- "log_format": {
- "host": "$host",
- "@timestamp": "$time_iso8601",
- "client_ip": "$remote_addr"
- }
-}'
-```
-
-It is expected to see some logs like that:
-
-```shell
-{"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"}
-```
+You will be able to find the `file.log` file in the configured `logs` directory.
## Disable Plugin
-Remove the corresponding json configuration in the plugin configuration to disable the `file-logger`.
-APISIX plugins are hot-reloaded, therefore no need to restart APISIX.
+To disable the `file-logger` Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.
```shell
-$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"methods": ["GET"],
"uri": "/hello",
diff --git a/docs/en/latest/plugins/loggly.md b/docs/en/latest/plugins/loggly.md
index f931f41e3..bb8ef625c 100644
--- a/docs/en/latest/plugins/loggly.md
+++ b/docs/en/latest/plugins/loggly.md
@@ -1,5 +1,11 @@
---
title: loggly
+keywords:
+ - APISIX
+ - API Gateway
+ - Plugin
+ - SolarWinds Loggly
+description: This document contains information about the Apache APISIX loggly Plugin.
---
<!--
@@ -23,45 +29,61 @@ title: loggly
## Description
-The `loggly` plugin is used to forward the request log of `Apache APISIX` to `Loggly by SolarWinds` for analysis and storage. After the plugin is enabled, `Apache APISIX` will obtain request context information in `Log Phase` serialize it into [Loggly Syslog](https://documentation.solarwinds.com/en/success_center/loggly/content/admin/streaming-syslog-without-using-files.htm?cshid=loggly_streaming-syslog-without-using-files) data format which is actually syslog events with [RFC5424](https [...]
+The `loggly` Plugin is used to forward logs to [SolarWinds Loggly](https://www.solarwinds.com/loggly) for analysis and storage.
-> At present, APISIX loggly plugin supports sending logs to Loggly server via syslog protocol, support for more event protocols are coming soon.
+When the Plugin is enabled, APISIX will serialize the request context information to [Loggly Syslog](https://documentation.solarwinds.com/en/success_center/loggly/content/admin/streaming-syslog-without-using-files.htm?cshid=loggly_streaming-syslog-without-using-files) data format which is Syslog events with [RFC5424](https://datatracker.ietf.org/doc/html/rfc5424) compliant headers.
-For more info on Batch-Processor in Apache APISIX please refer to:
-[Batch-Processor](../batch-processor.md)
+When the maximum batch size is exceeded, the data in the queue is pushed to Loggly enterprise syslog endpoint. See [batch processor](../batch-processor.md) for more details.
## Attributes
-| Name | Type | Requirement | Default | Description |
-| ----------------------- | ---- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| customer_token | string | required || A unique identifier is used when sending log data to Loggly to ensure that the logs are sent to the right organization account. |
-| severity | string (enum) | optional | INFO | Syslog log event severity level (choose between: "DEBUG", "INFO", "NOTICE", "WARNING", "ERR", "CRIT", "ALERT", "EMEGR" ) [case insensitive] |
-| severity_map | object | optional | nil | A sophisticated way of mapping upstream HTTP response code to SYSLOG severity. A set of key value pairs where keys are HTTP response code and values are one of the 8 SYSLOG severity keywords ("alert", "err" ...) Eg. {"410": "CRIT"} |
-| tags | array | optional | | To aid in segmentation & filtering. They are metadata you can set and they will be included with any event that is transmitted to Loggly. |
-| include_req_body | boolean | optional | false | Whether to include the request body. false: indicates that the requested body is not included; true: indicates that the requested body is included. Note: if the request body is too big to be kept in the memory, it can't be logged due to Nginx's limitation. |
-| include_resp_body| boolean | optional | false | Whether to include the response body. The response body is included if and only if it is `true`. |
-| include_resp_body_expr | array | optional | | When `include_resp_body` is true, control the behavior based on the result of the [lua-resty-expr](https://github.com/api7/lua-resty-expr) expression. If present, only log the response body when the result is true. |
+| Name | Type | Required | Default | Description |
+|------------------------|---------------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| customer_token | string | True | | Unique identifier used when sending logs to Loggly to ensure that they are sent to the right organisation account. |
+| severity | string (enum) | False | INFO | Syslog log event severity level. Choose between: `DEBUG`, `INFO`, `NOTICE`, `WARNING`, `ERR`, `CRIT`, `ALERT`, and `EMEGR`. |
+| severity_map | object | False | nil | A way to map upstream HTTP response codes to Syslog severity. Key-value pairs where keys are the HTTP response codes and the values are the Syslog severity levels. For example `{"410": "CRIT"}`. |
+| tags | array | False | | Metadata to be included with any event log to aid in segmentation and filtering. |
+| include_req_body | boolean | False | false | 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 | When set to `true` includes the request 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`. |
-The plugin supports the use of batch processors to aggregate and process entries(logs/data) in a batch. This avoids frequent data submissions by the plugin, which by default the batch processor submits data every `5` seconds or when the data in the queue reaches `1000`. For information or custom batch processor parameter settings, see [Batch-Processor](../batch-processor.md#configuration) configuration section.
+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.
-To generate a Customer Token, head over to `<your assigned subdomain>/loggly.com/tokens` or navigate to `Logs > Source Setup > Customer Tokens` to generate a new token.
+To generate a Customer token, go to `<your assigned subdomain>/loggly.com/tokens` or navigate to Logs > Source setup > Customer tokens.
## Metadata
-| Name | Type | Requirement | Default | Valid | Description |
-| ----------- | ------ | ----------- | ------- | ----- | ---------------------------------------------------------------------- |
-| host | string | optional | "logs-01.loggly.com" | | The host address endpoint where logs are being sent. |
-| port | integer | optional | 514 | | Loggly port (for "syslog" protocol only) to make a connection request. |
-| timeout | integer | optional | 5000 | | Loggly send data request timeout in milliseconds. |
-| protocol | string | optional | "syslog" | [ "syslog" , "http", "https" ] | Protocol through which the logs are sent to Loggly from APISIX (currently supported protocol : "syslog", "http", "https") |
-| log_format | object | optional | nil | | Log format declared as key value pair in JSON format. Only string is supported in the `value` part. If the value starts with `$`, it means to get [`APISIX` variables](../apisix-variable.md) or [Nginx variable](http://nginx.org/en/docs/varindex.html). If it is nil or empty object, APISIX generates full log info. |
+You can also configure the Plugin through Plugin metadata. The following configurations are available:
-## How To Enable
+| Name | Type | Required | Default | Valid values | Description |
+|------------|---------|----------|----------------------|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| host | string | False | "logs-01.loggly.com" | | Endpoint of the host where the logs are being sent. |
+| port | integer | False | 514 | | Loggly port to connect to. Only used for `syslog` protocol. |
+| timeout | integer | False | 5000 | | Loggly send data request timeout in milliseconds. |
+| protocol | string | False | "syslog" | [ "syslog" , "http", "https" ] | Protocol in which the logs are sent to Loggly. |
+| log_format | object | False | nil | | 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 following is an example of how to enable the `loggly` for a specific route.
+We support [Syslog](https://documentation.solarwinds.com/en/success_center/loggly/content/admin/streaming-syslog-without-using-files.htm), [HTTP/S](https://documentation.solarwinds.com/en/success_center/loggly/content/admin/http-bulk-endpoint.htm) (bulk endpoint) protocols to send log events to Loggly. By default, in APISIX side, the protocol is set to "syslog". It lets you send RFC5424 compliant syslog events with some fine-grained control (log severity mapping based on upstream HTTP re [...]
+
+:::note
+
+APISIX supports [Syslog](https://documentation.solarwinds.com/en/success_center/loggly/content/admin/streaming-syslog-without-using-files.htm) and [HTTP/S](https://documentation.solarwinds.com/en/success_center/loggly/content/admin/http-bulk-endpoint.htm) protocols to send data to Loggly. Syslog lets you send RFC5424 compliant syslog events with fine-grained control. But, HTTP/S bulk endpoint is better while sending large batches of logs at a fast transmission speed. You can configure th [...]
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/loggly -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+ "protocol": "http"
+}'
+```
+
+:::
+
+## Enabling the Plugin
### Full configuration
+The example below shows a complete configuration of the Plugin on a specific Route:
+
```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
@@ -91,17 +113,10 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}'
```
-We support [Syslog](https://documentation.solarwinds.com/en/success_center/loggly/content/admin/streaming-syslog-without-using-files.htm), [HTTP/S](https://documentation.solarwinds.com/en/success_center/loggly/content/admin/http-bulk-endpoint.htm) (bulk endpoint) protocols to send log events to Loggly. By default, in APISIX side, the protocol is set to "syslog". It lets you send RFC5424 compliant syslog events with some fine-grained control (log severity mapping based on upstream HTTP re [...]
-
-```shell
-curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/loggly -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
-{
- "protocol": "http"
-}'
-```
-
### Minimal configuration
+The example below shows a bare minimum configuration of the Plugin on a Route:
+
```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
@@ -120,28 +135,24 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}'
```
-## Test Plugin
+## Example usage
-* Send request to route configured with the `loggly` plugin
+Now, if you make a request to APISIX, it will be logged in Loggly:
```shell
-$ curl -i http://127.0.0.1:9080/index.html
-HTTP/1.1 200 OK
-...
-<!DOCTYPE html>
-<html>
+curl -i http://127.0.0.1:9080/index.html
```
-* Login to Loggly Dashboard to search and view
+You can then view the logs on your Loggly Dashboard:

## Disable Plugin
-Disabling the `loggly` plugin is very simple, just remove the `JSON` configuration corresponding to `loggly`. APISIX plugins are hot loaded, so no need to restart APISIX.
+To disable the `file-logger` Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.
```shell
-$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/index.html",
"plugins": {},
diff --git a/docs/en/latest/plugins/splunk-hec-logging.md b/docs/en/latest/plugins/splunk-hec-logging.md
index 3dd677fc1..abcfde0b5 100644
--- a/docs/en/latest/plugins/splunk-hec-logging.md
+++ b/docs/en/latest/plugins/splunk-hec-logging.md
@@ -1,5 +1,11 @@
---
title: splunk-hec-logging
+keywords:
+ - APISIX
+ - Plugin
+ - Splunk HTTP Event Collector
+ - splunk-hec-logging
+description: This document contains information about the Apache APISIX splunk-hec-logging Plugin.
---
<!--
@@ -23,30 +29,29 @@ title: splunk-hec-logging
## Description
-The `splunk-hec-logging` plugin is used to forward the request log of `Apache APISIX` to `Splunk HTTP Event Collector (HEC)` for analysis and storage. After the plugin is enabled, `Apache APISIX` will obtain request context information in `Log Phase` serialize it into [Splunk Event Data format](https://docs.splunk.com/Documentation/Splunk/latest/Data/FormateventsforHTTPEventCollector#Event_metadata) and submit it to the batch queue. When the maximum processing capacity of each batch of t [...]
+The `splunk-hec-logging` Plugin is used to forward logs to [Splunk HTTP Event Collector (HEC)](https://docs.splunk.com/Documentation/Splunk/8.2.6/Data/UsetheHTTPEventCollector) for analysis and storage.
-For more info on Batch-Processor in Apache APISIX please refer to:
-[Batch-Processor](../batch-processor.md)
+When the Plugin is enabled, APISIX will serialize the request context information to [Splunk Event Data format](https://docs.splunk.com/Documentation/Splunk/latest/Data/FormateventsforHTTPEventCollector#Event_metadata) and submit it to the batch queue. When the maximum batch size is exceeded, the data in the queue is pushed to Splunk HEC. See [batch processor](../batch-processor.md) for more details.
## Attributes
-| Name | Requirement | Default | Description |
-| ---------------- | ----------- | ------- | ------------------------------------------------------------ |
-| endpoint | required | | Splunk HEC endpoint configuration info |
-| endpoint.uri | required | | Splunk HEC event collector API |
-| endpoint.token | required | | Splunk HEC authentication token |
-| endpoint.channel | optional | | Splunk HEC send data channel identifier, refer to: [About HTTP Event Collector Indexer Acknowledgment](https://docs.splunk.com/Documentation/Splunk/8.2.3/Data/AboutHECIDXAck) |
-| endpoint.timeout | optional | 10 | Splunk HEC send data timeout, time unit: (seconds) |
-| ssl_verify | optional | true | enable `SSL` verification, option as per [OpenResty docs](https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake) |
+| Name | Required | Default | Description |
+|------------------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| endpoint | True | | Splunk HEC endpoint configurations. |
+| endpoint.uri | True | | Splunk HEC event collector API endpoint. |
+| endpoint.token | True | | Splunk HEC authentication token. |
+| endpoint.channel | False | | Splunk HEC send data channel identifier. Read more: [About HTTP Event Collector Indexer Acknowledgment](https://docs.splunk.com/Documentation/Splunk/8.2.3/Data/AboutHECIDXAck). |
+| endpoint.timeout | False | 10 | Splunk HEC send data timeout in seconds. |
+| ssl_verify | False | true | When set to `true` enables SSL verification as per [OpenResty docs](https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake). |
-The plugin supports the use of batch processors to aggregate and process entries(logs/data) in a batch. This avoids frequent data submissions by the plugin, which by default the batch processor submits data every `5` seconds or when the data in the queue reaches `1000`. For information or custom batch processor parameter settings, see [Batch-Processor](../batch-processor.md#configuration) configuration section.
+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.
-## How To Enable
-
-The following is an example of how to enable the `splunk-hec-logging` for a specific route.
+## Enabling the Plugin
### Full configuration
+The example below shows a complete configuration of the Plugin on a specific Route:
+
```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
@@ -75,7 +80,9 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}'
```
-### Minimize configuration
+### Minimal configuration
+
+The example below shows a bare minimum configuration of the Plugin on a Route:
```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
@@ -98,27 +105,24 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}'
```
-## Test Plugin
+## Example usage
-* Send request to route configured with the `splunk-hec-logging` plugin
+Once you have configured the Route to use the Plugin, when you make a request to APISIX, it will be logged in your Splunk server:
```shell
-$ curl -i http://127.0.0.1:9080/splunk.do?q=hello
-HTTP/1.1 200 OK
-...
-hello, world
+curl -i http://127.0.0.1:9080/splunk.do?q=hello
```
-* Login to Splunk Dashboard to search and view
+You should be able to login and search these logs from your Splunk dashboard:

## Disable Plugin
-Disabling the `splunk-hec-logging` plugin is very simple, just remove the `JSON` configuration corresponding to `splunk-hec-logging`.
+To disable the `splunk-hec-logging` Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.
```shell
-$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"plugins": {},