You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sy...@apache.org on 2022/08/04 07:47:46 UTC
[apisix] branch master updated: docs: refactor tcp-logger plugin Chinese doc (#7602)
This is an automated email from the ASF dual-hosted git repository.
sylviasu 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 18a6cacf1 docs: refactor tcp-logger plugin Chinese doc (#7602)
18a6cacf1 is described below
commit 18a6cacf1681c80d7821b0791f6b704fe6a9a4d8
Author: Fei Han <97...@users.noreply.github.com>
AuthorDate: Thu Aug 4 15:47:38 2022 +0800
docs: refactor tcp-logger plugin Chinese doc (#7602)
* docs: refactor tcp-logger plugin doc
---
docs/zh/latest/plugins/tcp-logger.md | 50 ++++++++++++++++++++----------------
1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/docs/zh/latest/plugins/tcp-logger.md b/docs/zh/latest/plugins/tcp-logger.md
index 6169ef063..e5f5e044f 100644
--- a/docs/zh/latest/plugins/tcp-logger.md
+++ b/docs/zh/latest/plugins/tcp-logger.md
@@ -1,7 +1,13 @@
---
title: tcp-logger
+keywords:
+ - APISIX
+ - Plugin
+ - TCP Logger
+description: 本文介绍了 API 网关 Apache APISIX 如何启用 tcp-logger 插件,并将日志数据发送到 TCP 服务器的步骤。
---
+
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -23,34 +29,30 @@ title: tcp-logger
## 描述
-`tcp-logger` 是用于将日志数据发送到 TCP 服务的插件。
-
-以实现将日志数据以 JSON 格式发送到监控工具或其它 TCP 服务的能力。
-
-该插件提供了将 Log Data 作为批处理推送到外部 TCP 服务器的功能。如果您没有收到日志数据,请等待一些时间,它会在我们的批处理处理器中的计时器功能到期后自动发送日志。
+`tcp-logger` 插件可用于将日志数据发送到 TCP 服务器。
-有关 Apache APISIX 中 Batch-Processor 的更多信息,请参考:
-[Batch-Processor](../batch-processor.md)
+该插件还实现了将日志数据以 JSON 格式发送到监控工具或其它 TCP 服务的能力。
## 属性
-| 名称 | 类型 | 必选项 | 默认值 | 有效值 | 描述 |
+| 名称 | 类型 | 必选项 | 默认值 | 有效值 | 描述 |
| ---------------- | ------- | ------ | ------ | ------- | ------------------------------------------------ |
-| host | string | 必须 | | | TCP 服务的 IP 地址或主机名 |
-| port | integer | 必须 | | [0,...] | 目标端口 |
-| timeout | integer | 可选 | 1000 | [1,...] | 发送数据超时间 |
-| tls | boolean | 可选 | false | | 用于控制是否执行 SSL 验证 |
-| tls_options | string | 可选 | | | TLS 选项 |
-| include_req_body | boolean | 可选 | | | 是否包括请求 body |
+| host | string | 是 | | | TCP 服务器的 IP 地址或主机名。 |
+| port | integer | 是 | | [0,...] | 目标端口。 |
+| timeout | integer | 否 | 1000 | [1,...] | 发送数据超时间。 |
+| tls | boolean | 否 | false | | 用于控制是否执行 SSL 验证。 |
+| tls_options | string | 否 | | | TLS 选项。 |
+| include_req_body | boolean | 否 | | | 当设置为 `true` 时,将请求体包含在日志中。 |
-本插件支持使用批处理器来聚合并批量处理条目(日志/数据)。这样可以避免插件频繁地提交数据,默认设置情况下批处理器会每 `5` 秒钟或队列中的数据达到 `1000` 条时提交数据,如需了解或自定义批处理器相关参数设置,请参考 [Batch-Processor](../batch-processor.md#配置) 配置部分。
+该插件支持使用批处理器来聚合并批量处理条目(日志/数据)。这样可以避免插件频繁地提交数据,默认情况下批处理器每 `5` 秒钟或队列中的数据达到 `1000` 条时提交数据,如需了解批处理器相关参数设置,请参考 [Batch-Processor](../batch-processor.md#配置)。
-## 如何开启
+## 启用插件
-1. 下面例子展示了如何为指定路由开启 `tcp-logger` 插件的。
+你可以通过以下命令在指定路由中启用该插件:
```shell
-curl http://127.0.0.1:9080/apisix/admin/routes/5 -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 '
{
"plugins": {
"tcp-logger": {
@@ -73,10 +75,13 @@ curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: edd1c9f034335f13
## 测试插件
-* 成功的情况:
+现在你可以向 APISIX 发起请求:
```shell
-$ curl -i http://127.0.0.1:9080/hello
+curl -i http://127.0.0.1:9080/hello
+```
+
+```
HTTP/1.1 200 OK
...
hello, world
@@ -84,10 +89,11 @@ hello, world
## 禁用插件
-想要禁用“tcp-logger”插件,是非常简单的,将对应的插件配置从 json 配置删除,就会立即生效,不需要重新启动服务:
+当你需要禁用该插件时,可通过以下命令删除相应的 JSON 配置,APISIX 将会自动重新加载相关配置,无需重启服务:
```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",