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/01/04 02:19:31 UTC

[apisix] branch master updated: docs: list APISIX variable in a separate page (#5997)

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 a2628a6  docs: list APISIX variable in a separate page (#5997)
a2628a6 is described below

commit a2628a602e2b5b77258fa6c20232bae998967a2c
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Tue Jan 4 10:19:22 2022 +0800

    docs: list APISIX variable in a separate page (#5997)
---
 docs/en/latest/apisix-variable.md         | 42 +++++++++++++++++++++++++++++++
 docs/en/latest/config.json                |  4 +++
 docs/en/latest/plugins/http-logger.md     | 12 +--------
 docs/en/latest/plugins/kafka-logger.md    | 12 +--------
 docs/en/latest/plugins/rocketmq-logger.md | 12 +--------
 docs/zh/latest/plugins/http-logger.md     | 12 +--------
 docs/zh/latest/plugins/kafka-logger.md    | 12 +--------
 docs/zh/latest/plugins/rocketmq-logger.md | 12 +--------
 8 files changed, 52 insertions(+), 66 deletions(-)

diff --git a/docs/en/latest/apisix-variable.md b/docs/en/latest/apisix-variable.md
new file mode 100644
index 0000000..08b1f81
--- /dev/null
+++ b/docs/en/latest/apisix-variable.md
@@ -0,0 +1,42 @@
+---
+title: APISIX variable
+---
+
+<!--
+#
+# 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.
+#
+-->
+
+Besides [Nginx variable](http://nginx.org/en/docs/varindex.html), APISIX also provides
+additional variables.
+
+List in alphabetical order:
+
+|   Variable Name  |      Description        | Example      |
+|------------------|-------------------------| ---------    |
+| balancer_ip      | the IP of picked upstream server | 1.1.1.1 |
+| balancer_port    | the port of picked upstream server | 80 |
+| consumer_name    | username of `consumer` |   |
+| graphql_name     | the [operation name](https://graphql.org/learn/queries/#operation-name) of GraphQL | HeroComparison |
+| graphql_operation     | the operation type of GraphQL | mutation  |
+| graphql_root_fields     | the top level fields of GraphQL | ["hero"] |
+| route_id         | id of `route`          |   |
+| route_name       | name of `route`        |   |
+| service_id       | id of `service`        |   |
+| service_name     | name of `service`      |   |
+
+You can also [register your own variable](./plugin-develop.md#register-custom-variable).
diff --git a/docs/en/latest/config.json b/docs/en/latest/config.json
index 1094fd7..13f4fde 100644
--- a/docs/en/latest/config.json
+++ b/docs/en/latest/config.json
@@ -225,6 +225,10 @@
         },
         {
           "type": "doc",
+          "id": "apisix-variable"
+        },
+        {
+          "type": "doc",
           "id": "external-plugin"
         },
         {
diff --git a/docs/en/latest/plugins/http-logger.md b/docs/en/latest/plugins/http-logger.md
index c4f5056..f4ff56d 100644
--- a/docs/en/latest/plugins/http-logger.md
+++ b/docs/en/latest/plugins/http-logger.md
@@ -91,20 +91,10 @@ hello, world
 
 | 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` variables or [Nginx variable](http://nginx.org/en/docs/varindex.html). |
+| 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). |
 
  Note that **the metadata configuration is applied in global scope**, which means it will take effect on all Route or Service which use http-logger plugin.
 
-**APISIX Variables**
-
-|   Variable Name  |      Description        | Usage Example  |
-|------------------|-------------------------|----------------|
-| route_id         | id of `route`          | $route_id      |
-| route_name       | name of `route`        | $route_name    |
-| service_id       | id of `service`        | $service_id    |
-| service_name     | name of `service`      | $service_name  |
-| consumer_name    | username of `consumer` | $consumer_name |
-
 ### Example
 
 ```shell
diff --git a/docs/en/latest/plugins/kafka-logger.md b/docs/en/latest/plugins/kafka-logger.md
index 504aa11..5761e35 100644
--- a/docs/en/latest/plugins/kafka-logger.md
+++ b/docs/en/latest/plugins/kafka-logger.md
@@ -183,20 +183,10 @@ hello, world
 
 | 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` variables or [Nginx variable](http://nginx.org/en/docs/varindex.html). |
+| 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). |
 
  Note that **the metadata configuration is applied in global scope**, which means it will take effect on all Route or Service which use kafka-logger plugin.
 
-**APISIX Variables**
-
-|   Variable Name  |      Description        | Usage Example  |
-|------------------|-------------------------|----------------|
-| route_id         | id of `route`          | $route_id      |
-| route_name       | name of `route`        | $route_name    |
-| service_id       | id of `service`        | $service_id    |
-| service_name     | name of `service`      | $service_name  |
-| consumer_name    | username of `consumer` | $consumer_name |
-
 ### Example
 
 ```shell
diff --git a/docs/en/latest/plugins/rocketmq-logger.md b/docs/en/latest/plugins/rocketmq-logger.md
index f17968c..9699379 100644
--- a/docs/en/latest/plugins/rocketmq-logger.md
+++ b/docs/en/latest/plugins/rocketmq-logger.md
@@ -179,20 +179,10 @@ hello, world
 
 | 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` variables or [Nginx variable](http://nginx.org/en/docs/varindex.html). |
+| 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 variables](../apisix-variable.md) or [Nginx variable](http://nginx.org/en/docs/varindex.html). |
 
  Note that **the metadata configuration is applied in global scope**, which means it will take effect on all Route or Service which use rocketmq-logger plugin.
 
-**APISIX Variables**
-
-|   Variable Name  |      Description        | Usage Example  |
-|------------------|-------------------------|----------------|
-| route_id         | id of `route`          | $route_id      |
-| route_name       | name of `route`        | $route_name    |
-| service_id       | id of `service`        | $service_id    |
-| service_name     | name of `service`      | $service_name  |
-| consumer_name    | username of `consumer` | $consumer_name |
-
 ### Example
 
 ```shell
diff --git a/docs/zh/latest/plugins/http-logger.md b/docs/zh/latest/plugins/http-logger.md
index b253355..023bdd3 100644
--- a/docs/zh/latest/plugins/http-logger.md
+++ b/docs/zh/latest/plugins/http-logger.md
@@ -91,17 +91,7 @@ hello, world
 
 | 名称             | 类型    | 必选项 | 默认值        | 有效值  | 描述                                             |
 | ---------------- | ------- | ------ | ------------- | ------- | ------------------------------------------------ |
-| log_format       | object  | 可选   | {"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"} |         | 以 JSON 格式的键值对来声明日志格式。对于值部分,仅支持字符串。如果是以 `$` 开头,则表明是要获取 __APISIX__ 变量或 [Nginx 内置变量](http://nginx.org/en/docs/varindex.html)。特别的,**该设置是全局生效的**,意味着指定 log_format 后,将对所有绑定 http-logger 的 Route 或 Service 生效。 |
-
-**APISIX 变量**
-
-|       变量名      |           描述          |      使用示例    |
-|------------------|-------------------------|----------------|
-| route_id         | `route` 的 id           | $route_id      |
-| route_name       | `route` 的 name         | $route_name    |
-| service_id       | `service` 的 id         | $service_id    |
-| service_name     | `service` 的 name       | $service_name  |
-| consumer_name    | `consumer` 的 username  | $consumer_name |
+| log_format       | object  | 可选   | {"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"} |         | 以 JSON 格式的键值对来声明日志格式。对于值部分,仅支持字符串。如果是以 `$` 开头,则表明是要获取 [APISIX 变量](../../../en/latest/apisix-variable.md) 或 [Nginx 内置变量](http://nginx.org/en/docs/varindex.html)。特别的,**该设置是全局生效的**,意味着指定 log_format 后,将对所有绑定 http-logger 的 Route 或 Service 生效。 |
 
 ### 设置日志格式示例
 
diff --git a/docs/zh/latest/plugins/kafka-logger.md b/docs/zh/latest/plugins/kafka-logger.md
index 8595533..a41b603 100644
--- a/docs/zh/latest/plugins/kafka-logger.md
+++ b/docs/zh/latest/plugins/kafka-logger.md
@@ -180,17 +180,7 @@ hello, world
 
 | 名称             | 类型    | 必选项 | 默认值        | 有效值  | 描述                                             |
 | ---------------- | ------- | ------ | ------------- | ------- | ------------------------------------------------ |
-| log_format       | object  | 可选   | {"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"} |         | 以 JSON 格式的键值对来声明日志格式。对于值部分,仅支持字符串。如果是以 `$` 开头,则表明是要获取 __APISIX__ 变量或 [Nginx 内置变量](http://nginx.org/en/docs/varindex.html)。特别的,**该设置是全局生效的**,意味着指定 log_format 后,将对所有绑定 http-logger 的 Route 或 Service 生效。 |
-
-**APISIX 变量**
-
-|       变量名      |           描述          |      使用示例    |
-|------------------|-------------------------|----------------|
-| route_id         | `route` 的 id           | $route_id      |
-| route_name       | `route` 的 name         | $route_name    |
-| service_id       | `service` 的 id         | $service_id    |
-| service_name     | `service` 的 name       | $service_name  |
-| consumer_name    | `consumer` 的 username  | $consumer_name |
+| log_format       | object  | 可选   | {"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"} |         | 以 JSON 格式的键值对来声明日志格式。对于值部分,仅支持字符串。如果是以 `$` 开头,则表明是要获取 [APISIX 变量](../../../en/latest/apisix-variable.md) 或 [Nginx 内置变量](http://nginx.org/en/docs/varindex.html)。特别的,**该设置是全局生效的**,意味着指定 log_format 后,将对所有绑定 http-logger 的 Route 或 Service 生效。 |
 
 ### 设置日志格式示例
 
diff --git a/docs/zh/latest/plugins/rocketmq-logger.md b/docs/zh/latest/plugins/rocketmq-logger.md
index f61c0b4..23c74b0 100644
--- a/docs/zh/latest/plugins/rocketmq-logger.md
+++ b/docs/zh/latest/plugins/rocketmq-logger.md
@@ -177,17 +177,7 @@ hello, world
 
 | 名称             | 类型    | 必选项 | 默认值        | 有效值  | 描述                                             |
 | ---------------- | ------- | ------ | ------------- | ------- | ------------------------------------------------ |
-| log_format       | object  | 可选   | {"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"} |         | 以 JSON 格式的键值对来声明日志格式。对于值部分,仅支持字符串。如果是以 `$` 开头,则表明是要获取 __APISIX__ 变量或 [Nginx 内置变量](http://nginx.org/en/docs/varindex.html)。特别的,**该设置是全局生效的**,意味着指定 log_format 后,将对所有绑定 http-logger 的 Route 或 Service 生效。 |
-
-**APISIX 变量**
-
-|       变量名      |           描述          |      使用示例    |
-|------------------|-------------------------|----------------|
-| route_id         | `route` 的 id           | $route_id      |
-| route_name       | `route` 的 name         | $route_name    |
-| service_id       | `service` 的 id         | $service_id    |
-| service_name     | `service` 的 name       | $service_name  |
-| consumer_name    | `consumer` 的 username  | $consumer_name |
+| log_format       | object  | 可选   | {"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"} |         | 以 JSON 格式的键值对来声明日志格式。对于值部分,仅支持字符串。如果是以 `$` 开头,则表明是要获取 [APISIX 变量](../../../en/latest/apisix-variable.md) 或 [Nginx 内置变量](http://nginx.org/en/docs/varindex.html)。特别的,**该设置是全局生效的**,意味着指定 log_format 后,将对所有绑定 http-logger 的 Route 或 Service 生效。 |
 
 ### 设置日志格式示例