You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by mo...@apache.org on 2023/05/29 02:43:42 UTC

[apisix] branch master updated: docs: improve clickhouse logger docs (#9436)

This is an automated email from the ASF dual-hosted git repository.

monkeydluffy 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 73ac77d22 docs: improve clickhouse logger docs (#9436)
73ac77d22 is described below

commit 73ac77d22b4ae0c2b597105e778f9a5d6ea86e3d
Author: Abhishek Choudhary <sh...@gmail.com>
AuthorDate: Mon May 29 08:13:34 2023 +0530

    docs: improve clickhouse logger docs (#9436)
---
 docs/en/latest/plugins/clickhouse-logger.md | 30 ++++++++++++++---------------
 docs/zh/latest/plugins/clickhouse-logger.md | 30 ++++++++++++++---------------
 2 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/docs/en/latest/plugins/clickhouse-logger.md b/docs/en/latest/plugins/clickhouse-logger.md
index 10d359ca6..16a59b2ea 100644
--- a/docs/en/latest/plugins/clickhouse-logger.md
+++ b/docs/en/latest/plugins/clickhouse-logger.md
@@ -81,25 +81,16 @@ curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/clickhouse-logger -H 'X-
 }'
 ```
 
-You have to then create a table in your ClickHouse database to store the logs:
-
-```sql
-CREATE TABLE default.test (
-  `host` String,
-  `client_ip` String,
-  `route_id` String,
-  `service_id` String,
-  `@timestamp` String,
-   PRIMARY KEY(`@timestamp`)
-) ENGINE = MergeTree()
+You can use the clickhouse docker image to create a container like so:
+
+```shell
+docker run -d -p 8123:8123 -p 9000:9000 -p 9009:9009 --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server
 ```
 
-Now, if you run `select * from default.test;`, you will get the following row:
+Then create a table in your ClickHouse database to store the logs.
 
-```
-┌─host──────┬─client_ip─┬─route_id─┬─@timestamp────────────────┐
-│ 127.0.0.1 │ 127.0.0.1 │ 1        │ 2022-01-17T10:03:10+08:00 │
-└───────────┴───────────┴──────────┴───────────────────────────┘
+```shell
+echo "CREATE TABLE default.test (\`host\` String, \`client_ip\` String, \`route_id\` String, \`service_id\` String, \`@timestamp\` String, PRIMARY KEY(\`@timestamp\`)) ENGINE = MergeTree()" | curl 'http://localhost:8123/'
 ```
 
 ## Enabling the Plugin
@@ -137,6 +128,13 @@ Now, if you make a request to APISIX, it will be logged in your ClickHouse datab
 curl -i http://127.0.0.1:9080/hello
 ```
 
+Now, if you check for the rows in the table, you will get the following output:
+
+```shell
+curl 'http://localhost:8123/?query=select%20*%20from%20default.test'
+127.0.0.1	127.0.0.1	1		2023-05-08T19:15:53+05:30
+```
+
 ## Disable Plugin
 
 To disable the `clickhouse-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.
diff --git a/docs/zh/latest/plugins/clickhouse-logger.md b/docs/zh/latest/plugins/clickhouse-logger.md
index 4e8a1f3c1..b3851377c 100644
--- a/docs/zh/latest/plugins/clickhouse-logger.md
+++ b/docs/zh/latest/plugins/clickhouse-logger.md
@@ -74,25 +74,16 @@ curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/clickhouse-logger \
 }'
 ```
 
-首先,你需要在 ClickHouse 数据库中创建一个表来存储日志:
-
-```sql
-CREATE TABLE default.test (
-  `host` String,
-  `client_ip` String,
-  `route_id` String,
-  `service_id` String,
-  `@timestamp` String,
-   PRIMARY KEY(`@timestamp`)
-) ENGINE = MergeTree()
+您可以使用 Clickhouse docker 镜像来创建一个容器,如下所示:
+
+```shell
+docker run -d -p 8123:8123 -p 9000:9000 -p 9009:9009 --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server
 ```
 
-在 ClickHouse 中执行`select * from default.test;`,将得到类似下面的数据:
+然后在您的 ClickHouse 数据库中创建一个表来存储日志。
 
-```
-┌─host──────┬─client_ip─┬─route_id─┬─@timestamp────────────────┐
-│ 127.0.0.1 │ 127.0.0.1 │ 1        │ 2022-01-17T10:03:10+08:00 │
-└───────────┴───────────┴──────────┴───────────────────────────┘
+```shell
+echo "CREATE TABLE default.test (\`host\` String, \`client_ip\` String, \`route_id\` String, \`service_id\` String, \`@timestamp\` String, PRIMARY KEY(\`@timestamp\`)) ENGINE = MergeTree()" | curl 'http://localhost:8123/'
 ```
 
 ## 启用插件
@@ -136,6 +127,13 @@ curl http://127.0.0.1:9180/apisix/admin/routes/1 \
 curl -i http://127.0.0.1:9080/hello
 ```
 
+现在,如果您检查表中的行,您将获得以下输出:
+
+```shell
+curl 'http://localhost:8123/?query=select%20*%20from%20default.test'
+127.0.0.1	127.0.0.1	1		2023-05-08T19:15:53+05:30
+```
+
 ## 禁用插件
 
 当你需要禁用该插件时,可通过以下命令删除相应的 JSON 配置,APISIX 将会自动重新加载相关配置,无需重启服务: