Skip to content

Commit

Permalink
docs: new quick start doc for logs (GreptimeTeam#1073)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
Co-authored-by: tison <wander4096@gmail.com>
  • Loading branch information
nicecui and tisonkun authored Jul 17, 2024
1 parent 826a831 commit 3d94423
Show file tree
Hide file tree
Showing 17 changed files with 733 additions and 515 deletions.
3 changes: 2 additions & 1 deletion docs/nightly/en/user-guide/logs/pipeline-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ processors:
- regex:
fields:
- message
pattern: ':(?<id>[0-9])'
patterns:
- ':(?<id>[0-9])'
ignore_missing: true
```

Expand Down
287 changes: 169 additions & 118 deletions docs/nightly/en/user-guide/logs/quick-start.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/nightly/en/user-guide/logs/write-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Before writing logs, please read the [Pipeline Configuration](pipeline-config.md
You can use the following command to write logs via the HTTP interface:

```shell
curl -X "POST" "http://localhost:4000/v1/events/logs?db=<db-name>&table=<table-name>&pipeline_name=<pipeline-name>" \
curl -X "POST" "http://localhost:4000/v1/events/logs?db=<db-name>&table=<table-name>&pipeline_name=<pipeline-name>&version=<pipeline-version>" \
-H 'Content-Type: application/json' \
-d "$<log-items>"
```
Expand All @@ -21,6 +21,7 @@ This interface accepts the following parameters:
- `db`: The name of the database.
- `table`: The name of the table.
- `pipeline_name`: The name of the [pipeline](./pipeline-config.md).
- `version`: The version of the pipeline. Optional, default use the latest one.

## Body data format

Expand Down
3 changes: 2 additions & 1 deletion docs/nightly/zh/user-guide/logs/pipeline-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ processors:
- regex:
fields:
- message
pattern: ':(?<id>[0-9])'
patterns:
- ':(?<id>[0-9])'
ignore_missing: true
```

Expand Down
2 changes: 1 addition & 1 deletion docs/nightly/zh/user-guide/logs/query-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SELECT * FROM logs WHERE MATCHES(message, 'error OR fail');

`MATCHES` 是一个专门用于全文搜索的函数,它接受两个参数:

- `column_name`:要进行全文搜索的列,该列包含文本数据,列的数据类型必须是 `String`。必须为此列建立[全文索引](全文索引加速搜索)以优化查询。
- `column_name`:要进行全文搜索的列,该列包含文本数据,列的数据类型必须是 `String`。必须为此列建立[全文索引](#全文索引加速搜索)以优化查询。
- `search_query`:一个字符串,包含要搜索的关键词和操作符,详情请看下文中的[查询语句类型](#查询语句类型)

## 查询语句类型
Expand Down
281 changes: 162 additions & 119 deletions docs/nightly/zh/user-guide/logs/quick-start.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/nightly/zh/user-guide/logs/write-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
您可以使用以下命令通过 HTTP 接口写入日志:

```shell
curl -X "POST" "http://localhost:4000/v1/events/logs?db=<db-name>&table=<table-name>&pipeline_name=<pipeline-name>" \
curl -X "POST" "http://localhost:4000/v1/events/logs?db=<db-name>&table=<table-name>&pipeline_name=<pipeline-name>&version=<pipeline-version>" \
-H 'Content-Type: application/json' \
-d "$<log-items>"
```
Expand All @@ -22,6 +22,7 @@ curl -X "POST" "http://localhost:4000/v1/events/logs?db=<db-name>&table=<table-n
- `db`:数据库名称。
- `table`:表名称。
- `pipeline_name`[Pipeline](./pipeline-config.md) 名称。
- `version`:Pipeline 版本号。可选,默认使用最新版本。

## Body 数据格式

Expand Down
3 changes: 2 additions & 1 deletion docs/v0.9/en/user-guide/logs/pipeline-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ processors:
- regex:
fields:
- message
pattern: ':(?<id>[0-9])'
patterns:
- ':(?<id>[0-9])'
ignore_missing: true
```

Expand Down
39 changes: 25 additions & 14 deletions docs/v0.9/en/user-guide/logs/query-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SELECT * FROM logs WHERE MATCHES(message, 'error OR fail');

The `MATCHES` function is designed for full-text search and accepts two parameters:

- `column_name`: The column to perform the full-text search on, which should contain textual data of type `String`.
- `column_name`: The column to perform the full-text search on, which should contain textual data of type `String`. The [full-text index](#full-text-index-for-accelerated-search) must be created on this column to optimize queries.
- `search_query`: A string containing query statement which you want to search for. See the [Query Statements](#query-statements) section below for more details.

## Query Statements
Expand Down Expand Up @@ -81,13 +81,26 @@ SELECT * FROM logs WHERE MATCHES(message, '"He said \"hello\""');

## Full-Text Index for Accelerated Search

A full-text index is essential for full-text search, especially when dealing with large datasets. Without a full-text index, the search operation could be very slow, impacting the overall query performance and user experience. By configuring a full-text index within the Pipeline, you can ensure that search operations are performed efficiently, even with significant data volumes.
A full-text index is essential for full-text search, especially when dealing with large datasets. Without a full-text index, the search operation could be very slow, impacting the overall query performance and user experience. You can configure a full-text index either directly via SQL during table creation or through the Pipeline configuration, ensuring that search operations are performed efficiently, even with significant data volumes.

### Configuring Full-Text Index
### Creating Full-Text Index via SQL

In the Pipeline configuration, you can specify a column to use a full-text index. Below is a configuration example where the `message` column is set with a full-text index:
You can create a full-text index for a column by specifying the `FULLTEXT` option in the column definition. Below is an example of creating a table with a full-text index on the `message` column:

<!-- In the Pipeline configuration, you can [specify a column to use a full-text index](./pipeline-config.md#index-field). Below is a configuration example where the `message` column is set with a full-text index: -->
```sql
CREATE TABLE `logs` (
`message` STRING FULLTEXT,
`time` TIMESTAMP TIME INDEX,
) WITH (
append_mode = 'true'
);
```

For more details, see the [Fulltext Column Option](/reference/sql/create#fulltext-column-option).

### Configuring Full-Text Index via Pipeline

In the Pipeline configuration, you can [specify a column to use a full-text index](./pipeline-config.md#the-index-field). Below is a configuration example where the `message` column is set with a full-text index:

```yaml
processors:
Expand All @@ -106,20 +119,18 @@ transform:
index: timestamp
```
### Viewing Table Schema
#### Viewing Table Schema
After data is written, you can use an SQL statement to view the table schema and confirm that the `message` column is set for full-text indexing:

```sql
SHOW CREATE TABLE many_logs\G
SHOW CREATE TABLE logs\G
*************************** 1. row ***************************
Table: many_logs
Create Table: CREATE TABLE IF NOT EXISTS `many_logs` (
`host` STRING NULL,
`log` STRING NULL FULLTEXT WITH(analyzer = 'English', case_sensitive = 'false'),
`ts` TIMESTAMP(9) NOT NULL,
TIME INDEX (`ts`),
PRIMARY KEY (`host`)
Table: logs
Create Table: CREATE TABLE IF NOT EXISTS `logs` (
`message` STRING NULL FULLTEXT WITH(analyzer = 'English', case_sensitive = 'false'),
`time` TIMESTAMP(9) NOT NULL,
TIME INDEX (`time`),
)

ENGINE=mito
Expand Down
Loading

0 comments on commit 3d94423

Please sign in to comment.