From 98aea6cdd5ac41bd1283f9fb3250f5edd139d8fd Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 14 Feb 2022 18:22:52 +0800 Subject: [PATCH 1/9] docs: update public API relative usage --- docs/en/latest/plugins/batch-requests.md | 36 ++++++++++++++-------- docs/en/latest/plugins/jwt-auth.md | 14 +++++++++ docs/en/latest/plugins/node-status.md | 18 ++++++++++- docs/en/latest/plugins/prometheus.md | 38 ++++++++++++++++-------- docs/en/latest/plugins/wolf-rbac.md | 16 ++++++++++ docs/zh/latest/plugins/batch-requests.md | 36 ++++++++++++++-------- docs/zh/latest/plugins/jwt-auth.md | 14 +++++++++ docs/zh/latest/plugins/node-status.md | 12 +++++++- docs/zh/latest/plugins/prometheus.md | 36 ++++++++++++++-------- docs/zh/latest/plugins/wolf-rbac.md | 16 ++++++++++ 10 files changed, 186 insertions(+), 50 deletions(-) diff --git a/docs/en/latest/plugins/batch-requests.md b/docs/en/latest/plugins/batch-requests.md index f397765aef5a..cf6aef22b2b4 100644 --- a/docs/en/latest/plugins/batch-requests.md +++ b/docs/en/latest/plugins/batch-requests.md @@ -118,23 +118,35 @@ Response is `Array` of [HttpResponse](#httpresponse). ## How to specify custom uri -We can change the default uri in the `plugin_attr` section of `conf/config.yaml`. +We have the [public-api](public-api.md) plugin, customizing the uri becomes even easier. We just need to set the `uri` you want when creating the route and change the configuration of the `public-api` plugin. -| Name | Type | Requirement | Default | Description | -| ---------- | ------ |-------------| ---------------------------- | --------------------------------- | -| uri | string | optional | "/apisix/batch-requests" | uri to use with batch-requests plugin | - -Here is an example: - -```yaml -plugin_attr: - batch-requests: - uri: "/api-gw/batch" +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/br -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/batch-requests", + "plugins": { + "public-api": { + "uri": "/apisix/batch-requests" + } + } +}' ``` ## Test Plugin -You can pass your request detail to batch API( `/apisix/batch-requests` ), `apisix` can automatically complete requests via [http pipeline](https://en.wikipedia.org/wiki/HTTP_pipelining). Such as: +First you need to setup the route for the API that batch request, which will use the [public-api](public-api.md) plugin. + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/br -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/batch-requests", + "plugins": { + "public-api": {} + } +}' +``` + +Then, you can pass your request detail to batch API( `/apisix/batch-requests` ), APISIX can automatically complete requests via [http pipeline](https://en.wikipedia.org/wiki/HTTP_pipelining). Such as: ```shell curl --location --request POST 'http://127.0.0.1:9080/apisix/batch-requests' \ diff --git a/docs/en/latest/plugins/jwt-auth.md b/docs/en/latest/plugins/jwt-auth.md index e23653e86ab5..4be4861fbeb7 100644 --- a/docs/en/latest/plugins/jwt-auth.md +++ b/docs/en/latest/plugins/jwt-auth.md @@ -196,6 +196,20 @@ then add jwt-auth plugin in the Consumer page: #### Get the Token in `jwt-auth` Plugin: +First you need to setup the route for the API that sign the token, which will use the [public-api](public-api.md) plugin. + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/plugin/jwt/sign", + "plugins": { + "public-api": {} + } +}' +``` + +Let's get a token. + * without extension payload: ```shell diff --git a/docs/en/latest/plugins/node-status.md b/docs/en/latest/plugins/node-status.md index d70f7389948f..0636c2b800bc 100644 --- a/docs/en/latest/plugins/node-status.md +++ b/docs/en/latest/plugins/node-status.md @@ -58,7 +58,17 @@ plugins: # plugin list ...... ``` -After starting `APISIX`, you can get status information through the API `/apisix/status`. +2. Setup the route for the status API, which will use the [public-api](public-api.md) plugin. + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/ns -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/status", + "plugins": { + "public-api": {} + } +}' +``` ## Test Plugin @@ -121,3 +131,9 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f "plugins": {} }' ``` + +3. You can also remove the route on `/apisix/status`, no one can access the API. + +```sh +$ curl http://127.0.0.1:9080/apisix/admin/routes/ns -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X DELETE +``` diff --git a/docs/en/latest/plugins/prometheus.md b/docs/en/latest/plugins/prometheus.md index f4d55693ca40..528b62444317 100644 --- a/docs/en/latest/plugins/prometheus.md +++ b/docs/en/latest/plugins/prometheus.md @@ -91,7 +91,21 @@ Then add prometheus plugin: ## How to fetch the metric data -We fetch the metric data from the specified url `/apisix/prometheus/metrics`. +We fetch the metric data from the specified url `/apisix/prometheus/metrics`. + +First you need to setup the route for the metrics API, which will use the [public-api](public-api.md) plugin. + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/prometheus/metrics", + "plugins": { + "public-api": {} + } +}' +``` + +Then, we can get the metrics. ``` curl -i http://127.0.0.1:9091/apisix/prometheus/metrics @@ -119,18 +133,18 @@ And we can check the status at prometheus console: ## How to specify export uri -We can change the default export uri in the `plugin_attr` section of `conf/config.yaml`. - -| Name | Type | Default | Description | -| ---------- | ------ | ---------------------------- | --------------------------------- | -| export_uri | string | "/apisix/prometheus/metrics" | uri to get the prometheus metrics | +We have the [public-api](public-api.md) plugin, customizing the export uri becomes even easier. We just need to set the `uri` you want when creating the route and change the configuration of the `public-api` plugin. -Here is an example: - -```yaml -plugin_attr: - prometheus: - export_uri: /apisix/metrics +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/metrics", + "plugins": { + "public-api": { + "uri": "/apisix/prometheus/metrics" + } + } +}' ``` ### Grafana dashboard diff --git a/docs/en/latest/plugins/wolf-rbac.md b/docs/en/latest/plugins/wolf-rbac.md index eef6e3afbe44..1b91a7836eae 100644 --- a/docs/en/latest/plugins/wolf-rbac.md +++ b/docs/en/latest/plugins/wolf-rbac.md @@ -110,6 +110,22 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1 ## Test Plugin +#### Setup routes for public API + +Use the `public-api` plugin to expose the public API. + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/wal -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/plugin/wolf-rbac/login", + "plugins": { + "public-api": {} + } +}' +``` + +You also need to setup the `change_pwd` and `user_info` routes together. + #### Login and get `wolf-rbac` token: The following `appid`, `username`, and `password` must be real ones in the wolf system. diff --git a/docs/zh/latest/plugins/batch-requests.md b/docs/zh/latest/plugins/batch-requests.md index bfb9876ef53e..31d6ffb2e90e 100644 --- a/docs/zh/latest/plugins/batch-requests.md +++ b/docs/zh/latest/plugins/batch-requests.md @@ -122,23 +122,35 @@ curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/batch-requests -H 'X-API ## 如何修改自定义 uri -我们可以在 `conf/config.yaml` 的 `plugin_attr` 配置项中修改默认的 `uri` +我们可以使用 [public-api](../../../en/latest/plugins/public-api.md) 插件轻易的设置自定义 uri。只需要在创建路由时设置需要的 uri 并改变 `public-api` 插件的配置即可。 -| 名称 | 类型 | 必选项 | 默认值 | 描述 | -| --------- | ------ | ------ | ---------------------------- | -------------- | -| uri | string | 可选 |"/apisix/batch-requests" | `batch-requests` 插件的自定义 uri | - -配置示例: - -```yaml -plugin_attr: - batch-requests: - uri: "/api-gw/batch" +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/br -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/batch-requests", + "plugins": { + "public-api": { + "uri": "/apisix/batch-requests" + } + } +}' ``` ## 测试插件 -你可以将要访问的请求信息传到网关的批量请求接口( `/apisix/batch-requests` ),网关会以 [http pipeline](https://en.wikipedia.org/wiki/HTTP_pipelining) 的方式自动帮你完成请求。 +首先,你需要为 batch request 的 API 设置一个路由,它将使用 [public-api](public-api.md) 插件。 + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/br -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/batch-requests", + "plugins": { + "public-api": {} + } +}' +``` + +之后,你就可以将要访问的请求信息传到网关的批量请求接口( `/apisix/batch-requests` )了,网关会以 [http pipeline](https://en.wikipedia.org/wiki/HTTP_pipelining) 的方式自动帮你完成请求。 ```shell curl --location --request POST 'http://127.0.0.1:9080/apisix/batch-requests' \ diff --git a/docs/zh/latest/plugins/jwt-auth.md b/docs/zh/latest/plugins/jwt-auth.md index 2ee30151bf0b..aa24b66d1496 100644 --- a/docs/zh/latest/plugins/jwt-auth.md +++ b/docs/zh/latest/plugins/jwt-auth.md @@ -123,6 +123,20 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 #### 首先进行登录获取 `jwt-auth` token: +首先,你需要为签发 token 的 API 设置一个路由,它将使用 [public-api](public-api.md) 插件。 + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/plugin/jwt/sign", + "plugins": { + "public-api": {} + } +}' +``` + +之后,我们就可以调用它获取 token 了。 + * 没有额外的 payload: ```shell diff --git a/docs/zh/latest/plugins/node-status.md b/docs/zh/latest/plugins/node-status.md index 1901ac6b4de0..42988c9e5eb2 100644 --- a/docs/zh/latest/plugins/node-status.md +++ b/docs/zh/latest/plugins/node-status.md @@ -56,7 +56,17 @@ plugins: # plugin list ...... ``` -启动 `APISIX` 之后,即可访问该插件提供的接口,获得基本的状态信息。 +2. 为状态 API 配置路由,它将使用 [public-api](public-api.md) 插件。 + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/ns -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/status", + "plugins": { + "public-api": {} + } +}' +``` ## 测试插件 diff --git a/docs/zh/latest/plugins/prometheus.md b/docs/zh/latest/plugins/prometheus.md index 033e0b0e71c8..ba8ba491c96e 100644 --- a/docs/zh/latest/plugins/prometheus.md +++ b/docs/zh/latest/plugins/prometheus.md @@ -91,7 +91,19 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 ## 如何提取指标数据 -我们可以从指定的 url 中提取指标数据 `/apisix/prometheus/metrics`: +我们可以从指定的 url 中提取指标数据 `/apisix/prometheus/metrics`。为此,您需要先为它配置一个路由,它将使用 [public-api](../../../en/latest/plugins/public-api.md) 插件。 + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/prometheus/metrics", + "plugins": { + "public-api": {} + } +}' +``` + +然后,我们就可以获取指标数据了。 ``` curl -i http://127.0.0.1:9091/apisix/prometheus/metrics @@ -118,18 +130,18 @@ scrape_configs: ## 如何修改暴露指标的 uri -我们可以在 `conf/config.yaml` 的 `plugin_attr` 修改默认的 uri - -| 名称 | 类型 | 默认值 | 描述 | -| ---------- | ------ | ---------------------------- | -------------- | -| export_uri | string | "/apisix/prometheus/metrics" | 暴露指标的 uri | - -配置示例: +我们可以使用 [public-api](../../../en/latest/plugins/public-api.md) 插件轻易的改变暴露指标的 uri。只需要在创建路由时设置需要的 uri 并改变 `public-api` 插件的配置即可。 -```yaml -plugin_attr: - prometheus: - export_uri: /apisix/metrics +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/metrics", + "plugins": { + "public-api": { + "uri": "/apisix/prometheus/metrics" + } + } +}' ``` ### Grafana 面板 diff --git a/docs/zh/latest/plugins/wolf-rbac.md b/docs/zh/latest/plugins/wolf-rbac.md index 58d07f8af18a..4e1eededabc9 100644 --- a/docs/zh/latest/plugins/wolf-rbac.md +++ b/docs/zh/latest/plugins/wolf-rbac.md @@ -110,6 +110,22 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1 ## 测试插件 +#### 为 API 设置路由 + +我们使用 [public-api](../../../en/latest/plugins/public-api.md) 插件来暴露这些 public API. + +```shell +$ curl http://127.0.0.1:9080/apisix/admin/routes/wal -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/apisix/plugin/wolf-rbac/login", + "plugins": { + "public-api": {} + } +}' +``` + +你也需要为 `change_pwd` 和 `user_info` 两个 API 配置路由。 + #### 首先进行登录获取 `wolf-rbac` token: 下面的 `appid`, `username`, `password` 必须为 wolf 系统中真实存在的. From 199b64d472b47b7647367a9d93d2c15de0c0fb99 Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 14 Feb 2022 18:49:53 +0800 Subject: [PATCH 2/9] fix: lint --- docs/en/latest/plugins/prometheus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/latest/plugins/prometheus.md b/docs/en/latest/plugins/prometheus.md index 528b62444317..6b3292d37a99 100644 --- a/docs/en/latest/plugins/prometheus.md +++ b/docs/en/latest/plugins/prometheus.md @@ -91,7 +91,7 @@ Then add prometheus plugin: ## How to fetch the metric data -We fetch the metric data from the specified url `/apisix/prometheus/metrics`. +We fetch the metric data from the specified url `/apisix/prometheus/metrics`. First you need to setup the route for the metrics API, which will use the [public-api](public-api.md) plugin. From 03694e7ff683db57dc504bd4e1d699dc3d2294e9 Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Wed, 16 Feb 2022 10:41:18 +0800 Subject: [PATCH 3/9] docs: fix wrong curl demo --- docs/en/latest/plugins/jwt-auth.md | 2 +- docs/zh/latest/plugins/jwt-auth.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/latest/plugins/jwt-auth.md b/docs/en/latest/plugins/jwt-auth.md index 4be4861fbeb7..cfc727b987f0 100644 --- a/docs/en/latest/plugins/jwt-auth.md +++ b/docs/en/latest/plugins/jwt-auth.md @@ -199,7 +199,7 @@ then add jwt-auth plugin in the Consumer page: First you need to setup the route for the API that sign the token, which will use the [public-api](public-api.md) plugin. ```shell -$ curl http://127.0.0.1:9080/apisix/admin/routes/ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +$ curl http://127.0.0.1:9080/apisix/admin/routes/jas -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/apisix/plugin/jwt/sign", "plugins": { diff --git a/docs/zh/latest/plugins/jwt-auth.md b/docs/zh/latest/plugins/jwt-auth.md index aa24b66d1496..2a66b0fded65 100644 --- a/docs/zh/latest/plugins/jwt-auth.md +++ b/docs/zh/latest/plugins/jwt-auth.md @@ -126,7 +126,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 首先,你需要为签发 token 的 API 设置一个路由,它将使用 [public-api](public-api.md) 插件。 ```shell -$ curl http://127.0.0.1:9080/apisix/admin/routes/ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +$ curl http://127.0.0.1:9080/apisix/admin/routes/jas -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/apisix/plugin/jwt/sign", "plugins": { From 91a32a9cf450badef73fe7e5a5a06819f74cbb4f Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 21 Feb 2022 10:08:20 +0800 Subject: [PATCH 4/9] docs: fix broken document link --- docs/zh/latest/plugins/batch-requests.md | 2 +- docs/zh/latest/plugins/jwt-auth.md | 2 +- docs/zh/latest/plugins/node-status.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/zh/latest/plugins/batch-requests.md b/docs/zh/latest/plugins/batch-requests.md index 31d6ffb2e90e..13aa04b69a88 100644 --- a/docs/zh/latest/plugins/batch-requests.md +++ b/docs/zh/latest/plugins/batch-requests.md @@ -138,7 +138,7 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/br -H 'X-API-KEY: edd1c9f034335 ## 测试插件 -首先,你需要为 batch request 的 API 设置一个路由,它将使用 [public-api](public-api.md) 插件。 +首先,你需要为 batch request 的 API 设置一个路由,它将使用 [public-api](../../../en/latest/plugins/public-api.md) 插件。 ```shell $ curl http://127.0.0.1:9080/apisix/admin/routes/br -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' diff --git a/docs/zh/latest/plugins/jwt-auth.md b/docs/zh/latest/plugins/jwt-auth.md index 2a66b0fded65..d3caff81543a 100644 --- a/docs/zh/latest/plugins/jwt-auth.md +++ b/docs/zh/latest/plugins/jwt-auth.md @@ -123,7 +123,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 #### 首先进行登录获取 `jwt-auth` token: -首先,你需要为签发 token 的 API 设置一个路由,它将使用 [public-api](public-api.md) 插件。 +首先,你需要为签发 token 的 API 设置一个路由,它将使用 [public-api](../../../en/latest/plugins/public-api.md) 插件。 ```shell $ curl http://127.0.0.1:9080/apisix/admin/routes/jas -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' diff --git a/docs/zh/latest/plugins/node-status.md b/docs/zh/latest/plugins/node-status.md index 42988c9e5eb2..89782d0153cc 100644 --- a/docs/zh/latest/plugins/node-status.md +++ b/docs/zh/latest/plugins/node-status.md @@ -56,7 +56,7 @@ plugins: # plugin list ...... ``` -2. 为状态 API 配置路由,它将使用 [public-api](public-api.md) 插件。 +2. 为状态 API 配置路由,它将使用 [public-api](../../../en/latest/plugins/public-api.md) 插件。 ```shell $ curl http://127.0.0.1:9080/apisix/admin/routes/ns -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' From 540f1edb390152955188eeec9cbe1fffbe9efe98 Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 21 Feb 2022 10:10:13 +0800 Subject: [PATCH 5/9] fix: typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 琚致远 --- docs/en/latest/plugins/batch-requests.md | 2 +- docs/en/latest/plugins/jwt-auth.md | 2 +- docs/en/latest/plugins/prometheus.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/latest/plugins/batch-requests.md b/docs/en/latest/plugins/batch-requests.md index cf6aef22b2b4..81f0c4e18fb5 100644 --- a/docs/en/latest/plugins/batch-requests.md +++ b/docs/en/latest/plugins/batch-requests.md @@ -146,7 +146,7 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/br -H 'X-API-KEY: edd1c9f034335 }' ``` -Then, you can pass your request detail to batch API( `/apisix/batch-requests` ), APISIX can automatically complete requests via [http pipeline](https://en.wikipedia.org/wiki/HTTP_pipelining). Such as: +Then, you can pass your request detail to batch API(`/apisix/batch-requests`), APISIX can automatically complete requests via [http pipeline](https://en.wikipedia.org/wiki/HTTP_pipelining). Such as: ```shell curl --location --request POST 'http://127.0.0.1:9080/apisix/batch-requests' \ diff --git a/docs/en/latest/plugins/jwt-auth.md b/docs/en/latest/plugins/jwt-auth.md index cfc727b987f0..cd5b82672197 100644 --- a/docs/en/latest/plugins/jwt-auth.md +++ b/docs/en/latest/plugins/jwt-auth.md @@ -196,7 +196,7 @@ then add jwt-auth plugin in the Consumer page: #### Get the Token in `jwt-auth` Plugin: -First you need to setup the route for the API that sign the token, which will use the [public-api](public-api.md) plugin. +First, you need to set up the route for the API that signs the token, which will use the [public-api](public-api.md) plugin. ```shell $ curl http://127.0.0.1:9080/apisix/admin/routes/jas -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' diff --git a/docs/en/latest/plugins/prometheus.md b/docs/en/latest/plugins/prometheus.md index 6b3292d37a99..8cf6d7e2d92a 100644 --- a/docs/en/latest/plugins/prometheus.md +++ b/docs/en/latest/plugins/prometheus.md @@ -93,7 +93,7 @@ Then add prometheus plugin: We fetch the metric data from the specified url `/apisix/prometheus/metrics`. -First you need to setup the route for the metrics API, which will use the [public-api](public-api.md) plugin. +First, you need to set up the route for the metrics API, which will use the [public-api](public-api.md) plugin. ```shell $ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' From bf7839ead897fe5a600b4fd9fabdf977fe035bfc Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 21 Feb 2022 15:29:49 +0800 Subject: [PATCH 6/9] docs: add use cases for different port --- docs/en/latest/plugins/prometheus.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/en/latest/plugins/prometheus.md b/docs/en/latest/plugins/prometheus.md index 8cf6d7e2d92a..294d9dd265d9 100644 --- a/docs/en/latest/plugins/prometheus.md +++ b/docs/en/latest/plugins/prometheus.md @@ -93,7 +93,9 @@ Then add prometheus plugin: We fetch the metric data from the specified url `/apisix/prometheus/metrics`. -First, you need to set up the route for the metrics API, which will use the [public-api](public-api.md) plugin. +### shared port (default: 9080) + +When you use a shared port with APISIX, you need to configure the route using the [public-api](public-api.md) plugin. ```shell $ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' @@ -107,10 +109,20 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f Then, we can get the metrics. +``` +curl -i http://127.0.0.1:9080/apisix/prometheus/metrics +``` + +### independent port (setting via configuration file) + +APISIX supports configuring separate port for the `prometheus` plugin to secure access. You can set it up like [this](#api). + ``` curl -i http://127.0.0.1:9091/apisix/prometheus/metrics ``` +### configuring prometheus + Puts this URL address into prometheus, and it will automatically fetch these metric data. From 24bd6c4e602e09775ccee38efe7f4621c3ecce14 Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 21 Feb 2022 17:12:55 +0800 Subject: [PATCH 7/9] docs: fix configuration file typo (#6395) --- docs/en/latest/config.json | 65 +++++++++++++++++++++++--------------- docs/zh/latest/config.json | 62 ++++++++++++++++++++++-------------- 2 files changed, 77 insertions(+), 50 deletions(-) diff --git a/docs/en/latest/config.json b/docs/en/latest/config.json index 0977cdc9b255..d08b51370eb4 100644 --- a/docs/en/latest/config.json +++ b/docs/en/latest/config.json @@ -107,32 +107,45 @@ "type": "category", "label": "Monitoring", "items": [ - "plugins/prometheus", - "plugins/zipkin", - "plugins/skywalking", - "plugins/opentelemetry", - "plugins/node-status", - "plugins/datadog" - ] - }, - { - "type": "category", - "label": "Loggers", - "items": [ - "plugins/http-logger", - "plugins/skywalking-logger", - "plugins/tcp-logger", - "plugins/kafka-logger", - "plugins/rocketmq-logger", - "plugins/udp-logger", - "plugins/syslog", - "plugins/log-rotate", - "plugins/error-log-logger", - "plugins/sls-logger", - "plugins/google-cloud-logging", - "plugins/splunk-hec-logging", - "plugins/file-logger", - "plugins/loggly" + { + "type": "category", + "label": "Tracers", + "items": [ + "plugins/zipkin", + "plugins/skywalking", + "plugins/opentelemetry" + ] + }, + { + "type": "category", + "label": "Metrics", + "items": [ + "plugins/prometheus", + "plugins/node-status", + "plugins/datadog" + ] + }, + { + "type": "category", + "label": "Loggers", + "items": [ + "plugins/http-logger", + "plugins/skywalking-logger", + "plugins/tcp-logger", + "plugins/kafka-logger", + "plugins/rocketmq-logger", + "plugins/udp-logger", + "plugins/clickhouse-logger", + "plugins/syslog", + "plugins/log-rotate", + "plugins/error-log-logger", + "plugins/sls-logger", + "plugins/google-cloud-logging", + "plugins/splunk-hec-logging", + "plugins/file-logger", + "plugins/loggly" + ] + } ] }, { diff --git a/docs/zh/latest/config.json b/docs/zh/latest/config.json index c6f2ac94bf66..80f1d4bfea9d 100644 --- a/docs/zh/latest/config.json +++ b/docs/zh/latest/config.json @@ -103,30 +103,44 @@ "type": "category", "label": "Monitoring", "items": [ - "plugins/prometheus", - "plugins/zipkin", - "plugins/skywalking", - "plugins/opentelemetry", - "plugins/node-status" - ] - }, - { - "type": "category", - "label": "Loggers", - "items": [ - "plugins/http-logger", - "plugins/skywalking-logger", - "plugins/tcp-logger", - "plugins/kafka-logger", - "plugins/rocketmq-logger", - "plugins/udp-logger", - "plugins/syslog", - "plugins/log-rotate", - "plugins/error-log-logger", - "plugins/sls-logger", - "plugins/google-cloud-logging", - "plugins/splunk-hec-logging", - "plugins/file-logger" + { + "type": "category", + "label": "Tracers", + "items": [ + "plugins/zipkin", + "plugins/skywalking", + "plugins/opentelemetry" + ] + }, + { + "type": "category", + "label": "Metrics", + "items": [ + "plugins/prometheus", + "plugins/node-status", + "plugins/datadog" + ] + }, + { + "type": "category", + "label": "Loggers", + "items": [ + "plugins/http-logger", + "plugins/skywalking-logger", + "plugins/tcp-logger", + "plugins/kafka-logger", + "plugins/rocketmq-logger", + "plugins/udp-logger", + "plugins/clickhouse-logger", + "plugins/syslog", + "plugins/log-rotate", + "plugins/error-log-logger", + "plugins/sls-logger", + "plugins/google-cloud-logging", + "plugins/splunk-hec-logging", + "plugins/file-logger" + ] + } ] }, { From b427a7a19c3755da44e6bebbc34a9f50c6b679a3 Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 21 Feb 2022 18:02:59 +0800 Subject: [PATCH 8/9] docs: fix logger --- docs/zh/latest/config.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/zh/latest/config.json b/docs/zh/latest/config.json index 80f1d4bfea9d..884407d7a349 100644 --- a/docs/zh/latest/config.json +++ b/docs/zh/latest/config.json @@ -117,8 +117,7 @@ "label": "Metrics", "items": [ "plugins/prometheus", - "plugins/node-status", - "plugins/datadog" + "plugins/node-status" ] }, { From ff3a7047c0d95b92c4617798fa3256071dc8b6ef Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 21 Feb 2022 18:21:47 +0800 Subject: [PATCH 9/9] docs: recover prometheus usage --- docs/en/latest/plugins/prometheus.md | 48 +++++++--------------------- docs/zh/latest/plugins/prometheus.md | 36 +++++++-------------- 2 files changed, 23 insertions(+), 61 deletions(-) diff --git a/docs/en/latest/plugins/prometheus.md b/docs/en/latest/plugins/prometheus.md index 270f5fd87107..0bab8234f876 100644 --- a/docs/en/latest/plugins/prometheus.md +++ b/docs/en/latest/plugins/prometheus.md @@ -93,36 +93,10 @@ Then add prometheus plugin: We fetch the metric data from the specified url `/apisix/prometheus/metrics`. -### shared port (default: 9080) - -When you use a shared port with APISIX, you need to configure the route using the [public-api](public-api.md) plugin. - -```shell -$ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' -{ - "uri": "/apisix/prometheus/metrics", - "plugins": { - "public-api": {} - } -}' -``` - -Then, we can get the metrics. - -``` -curl -i http://127.0.0.1:9080/apisix/prometheus/metrics -``` - -### independent port (setting via configuration file) - -APISIX supports configuring separate port for the `prometheus` plugin to secure access. You can set it up like [this](#api). - ``` curl -i http://127.0.0.1:9091/apisix/prometheus/metrics ``` -### configuring prometheus - Puts this URL address into prometheus, and it will automatically fetch these metric data. @@ -145,18 +119,18 @@ And we can check the status at prometheus console: ## How to specify export uri -We have the [public-api](public-api.md) plugin, customizing the export uri becomes even easier. We just need to set the `uri` you want when creating the route and change the configuration of the `public-api` plugin. +We can change the default export uri in the `plugin_attr` section of `conf/config.yaml`. -```shell -$ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' -{ - "uri": "/metrics", - "plugins": { - "public-api": { - "uri": "/apisix/prometheus/metrics" - } - } -}' +| Name | Type | Default | Description | +| ---------- | ------ | ---------------------------- | --------------------------------- | +| export_uri | string | "/apisix/prometheus/metrics" | uri to get the prometheus metrics | + +Here is an example: + +```yaml +plugin_attr: + prometheus: + export_uri: /apisix/metrics ``` ### Grafana dashboard diff --git a/docs/zh/latest/plugins/prometheus.md b/docs/zh/latest/plugins/prometheus.md index 6d879199f63c..855ad37ecdbf 100644 --- a/docs/zh/latest/plugins/prometheus.md +++ b/docs/zh/latest/plugins/prometheus.md @@ -91,19 +91,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 ## 如何提取指标数据 -我们可以从指定的 url 中提取指标数据 `/apisix/prometheus/metrics`。为此,您需要先为它配置一个路由,它将使用 [public-api](../../../en/latest/plugins/public-api.md) 插件。 - -```shell -$ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' -{ - "uri": "/apisix/prometheus/metrics", - "plugins": { - "public-api": {} - } -}' -``` - -然后,我们就可以获取指标数据了。 +我们可以从指定的 url 中提取指标数据 `/apisix/prometheus/metrics`: ``` curl -i http://127.0.0.1:9091/apisix/prometheus/metrics @@ -130,18 +118,18 @@ scrape_configs: ## 如何修改暴露指标的 uri -我们可以使用 [public-api](../../../en/latest/plugins/public-api.md) 插件轻易的改变暴露指标的 uri。只需要在创建路由时设置需要的 uri 并改变 `public-api` 插件的配置即可。 +我们可以在 `conf/config.yaml` 的 `plugin_attr` 修改默认的 uri -```shell -$ curl http://127.0.0.1:9080/apisix/admin/routes/p -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' -{ - "uri": "/metrics", - "plugins": { - "public-api": { - "uri": "/apisix/prometheus/metrics" - } - } -}' +| 名称 | 类型 | 默认值 | 描述 | +| ---------- | ------ | ---------------------------- | -------------- | +| export_uri | string | "/apisix/prometheus/metrics" | 暴露指标的 uri | + +配置示例: + +```yaml +plugin_attr: + prometheus: + export_uri: /apisix/metrics ``` ### Grafana 面板