monkeyDluffy6017 commented on code in PR #9687: URL: https://github.com/apache/apisix/pull/9687#discussion_r1236713830
########## docs/zh/latest/plugins/loki-logger.md: ########## @@ -0,0 +1,165 @@ +--- +title: loki-logger +keywords: + - Apache APISIX + - API 网关 + - Plugin + - Loki-logger + - Grafana Loki +description: 本文件包含关于 Apache APISIX loki-logger 插件的信息。 +--- + +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +## 描述 + +`loki-logger` 插件用于将日志转发到 [Grafana Loki](https://grafana.com/oss/loki/) 进行分析和存储。 + +当插件启用时,APISIX 将把请求上下文信息序列化为 [JSON 中的日志条目](https://grafana.com/docs/loki/latest/api/#push-log-entries-to-loki) 并提交给批处理队列。当超过最大批处理量时,队列中的数据会被推送到 Grafana Loki。更多细节见 [batch processor](../batch-processor.md)。 + +## 属性 + +| 名称 | 类型 | 必选项 | 默认值 | 描述 | +|--|---|---|---|---| +| endpoint_addrs | array[string] | True | | Loki API 基础 URL,格式如 http://127.0.0.1:3100,支持 HTTPS 和域名。如果配置了多个端点,它们将被随机写入。 | +| endpoint_uri | string | False | /loki/api/v1/push | 如果你使用与 Loki Push API 兼容的日志收集服务,你可以使用这个配置项来定制 API 路径。 | +| tenant_id | string | False | fake | Loki 租户 ID。根据 Loki 的 [多租户文档](https://grafana.com/docs/loki/latest/operations/multi-tenancy/#multi-tenancy),其默认值被设置为单租户下的默认值 `fake`。 | +| log_labels | object | False | {job = "apisix"} | Loki 日志标签。[APISIX 变量](../apisix-variable.md) 和 [Nginx 变量](http://nginx.org/en/docs/varindex.html) 可以通过在字符串前加上 `$` 来使用,包括单独和组合,如 `$host` 或 `$remote_addr:$remote_port`。 | +| ssl_verify | boolean | False | true | 当设置为 `true` 时,验证 SSL 证书。| +| timeout | integer | False | 3000ms | Loki 服务 HTTP 调用的超时。范围从 1 到 60,000ms。 | +| keepalive | boolean | False | true | 当设置为 `true` 时,为多个请求保持连接。 | +| keepalive_timeout | integer | False | 60000ms | 空闲时间之后连接被关闭。大于或等于 1000ms 的范围。 | +| keepalive_pool | integer | False | 5 | 连接池限制。大于或等于 1 的范围。 | +| log_format | object | False | | 日志格式以 JSON 格式的键值对声明。值只支持字符串。[APISIX 变量](../apisix-variable.md) 和 [Nginx 变量](http://nginx.org/en/docs/varindex.html) 可以通过在字符串前加上 `$` 来使用。 | +| include_req_body | boolean | False | false | 当设置为 `true` 时,在日志中包括请求正文。如果请求正文太大,不能保存在内存中,由于 Nginx 的限制,它不能被记录下来。 | +| include_req_body_expr | array | False | | 当 `include_req_body` 属性被设置为 `true` 时的过滤器。只有当这里设置的表达式评估为 `true` 时,才会记录请求正文。更多信息请参见 [lua-resty-expr](https://github.com/api7/lua-resty-expr)。 | +| include_resp_body | boolean | False | false | 当设置为 `true` 时,在日志中包括响应体。 | +| include_resp_body_expr | array | False | | 当 `include_resp_body` 属性被设置为 `true` 时的过滤器。只有当这里设置的表达式评估为 `true` 时,才会记录响应体。更多信息请参见 [lua-resty-expr](https://github.com/api7/lua-resty-expr)。 | Review Comment: I use DeepL and chatgpt, but i found that chatgpt is better -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
