Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/sql/greptime-private/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ operation succeeded.

The table is created when the first event is recorded. If no event has been
recorded, or event recording is disabled, querying it returns a table-not-found
error. Configure recording in [Lifecycle event recorder](/user-guide/deployments-administration/configuration.md#lifecycle-event-recorder).
error. Configure recording in [Event recording](/user-guide/deployments-administration/configuration.md#event-recording).

```sql
USE greptime_private;
Expand Down
12 changes: 9 additions & 3 deletions docs/user-guide/deployments-administration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,9 @@ default_ratio = 1.0

How to use distributed tracing, please reference [Tracing](/user-guide/deployments-administration/monitoring/tracing.md#tutorial-use-jaeger-to-trace-greptimedb)

### Lifecycle event recorder
### Event recording
Comment thread
WenyXu marked this conversation as resolved.
Comment thread
WenyXu marked this conversation as resolved.

The lifecycle event recorder persists procedure lifecycle events in the `greptime_private.events` system table. Configure it in `standalone` mode or on Metasrv in a distributed deployment:
Recorded events are stored in the `greptime_private.events` system table.

```toml
[event_recorder]
Expand All @@ -530,11 +530,17 @@ create_database, alter_database, drop_database,
create_flow, drop_flow,
create_table, create_logical_tables, alter_table, alter_logical_tables,
drop_table, undrop_table, purge_dropped_table, truncate_table,
create_view, drop_view
create_view, drop_view, admin_function
```

`undrop_table` and `purge_dropped_table` require GreptimeDB Enterprise.

In distributed deployments, the Frontend supports the following event type:

```text
admin_function
```

Metasrv supports the following event types:

```text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ not guaranteed to appear in the order shown:
| `Failed` | The Procedure reached a failed terminal state. Inspect `procedure_error` for failure details. |
| `Poisoned` | The Procedure cannot proceed. Inspect `procedure_error` for the failure details. |

## ADMIN function event columns

An `admin_function` event records the result returned by an `ADMIN` statement.

| Column | Meaning |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| `actor` | The current database user that executed the `ADMIN` function. |
| `admin_function_name` | The name of the executed ADMIN function. |
| `admin_function_status` | The execution status: `Succeeded` or `Failed`. |
| `admin_function_output` | JSON containing `result` when the function succeeds or `error` when it fails. |

The event `payload` contains the function arguments. If the result is a
Procedure ID, query the Procedure events for that ID to track its progress.

## Query JSON fields

See the [JSON functions](/reference/sql/functions/json.md) reference for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ acknowledgement.

## Configure event recording

The event recorder can be configured in standalone deployments or on Metasrv in distributed deployments. See [Lifecycle event recorder](/user-guide/deployments-administration/configuration.md#lifecycle-event-recorder) for configuration options and the supported type list.

Standalone deployments record supported local DDL Procedure events. Distributed deployments with Metasrv can additionally record operational event types.
See [Event recording](/user-guide/deployments-administration/configuration.md#event-recording) for configuration options and the event types supported by standalone, Frontend, and Metasrv.

## Query events

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,36 @@ cluster. It varies with workload and does not define the configured or
source-supported types. See [DDL events](/user-guide/deployments-administration/monitoring/events/ddl-events.md)
for the supported local DDL event types.

## Query ADMIN function events

An `admin_function` event records the function name, the current database user,
the immediate status, the input arguments, and the immediate output:

```sql
SELECT timestamp,
actor,
admin_function_name,
admin_function_status,
json_to_string(payload) AS payload,
json_to_string(admin_function_output) AS output
FROM greptime_private.events
WHERE type = 'admin_function'
AND timestamp >= now() - INTERVAL '1' hour
ORDER BY timestamp DESC
LIMIT 20;
```

For a successful function, `output` contains a `result`. For a failed function,
it contains an `error`:

```text
| actor | admin_function_name | admin_function_status | output |
| root | flush_table | Succeeded | {"result":0} |
| root | unknown_function | Failed | {"error":"..."} |
```

The `actor` value comes from the current protocol session user.

Combine an event type with a database and object name to avoid unrelated rows:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: greptime_private 数据库中的 events 表。

`events` 表保存 GreptimeDB 运行期间产生的事件。单机部署记录受支持的本地 DDL Procedure 事件;带有 Metasrv 的分布式部署还可以记录运维事件。事件会异步写入,写入失败不会影响原操作的执行结果。因此,不能以事件是否出现作为操作成功的依据。

该表会在首次记录事件时自动创建。如果还没有事件记录,或已禁用事件记录,查询会提示表不存在。配置方法请参阅[生命周期事件记录器](/user-guide/deployments-administration/configuration.md#生命周期事件记录器)。
该表会在首次记录事件时自动创建。如果还没有事件记录,或已禁用事件记录,查询会提示表不存在。配置方法请参阅[事件记录配置](/user-guide/deployments-administration/configuration.md#事件记录配置)。

```sql
USE greptime_private;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,9 @@ default_ratio = 1.0

如何使用分布式追踪,请参考 [Tracing](/user-guide/deployments-administration/monitoring/tracing.md#教程使用-jaeger-追踪-greptimedb-调用链路)

### 生命周期事件记录器
### 事件记录配置

生命周期事件记录器会将 Procedure 的生命周期事件持久化到 `greptime_private.events` 系统表。在单机模式下使用 `standalone` 配置;在分布式部署中,在 Metasrv 上配置:
记录的事件保存在 `greptime_private.events` 系统表中。

```toml
[event_recorder]
Expand All @@ -532,11 +532,17 @@ create_database, alter_database, drop_database,
create_flow, drop_flow,
create_table, create_logical_tables, alter_table, alter_logical_tables,
drop_table, undrop_table, purge_dropped_table, truncate_table,
create_view, drop_view
create_view, drop_view, admin_function
```

`undrop_table` 和 `purge_dropped_table` 仅 GreptimeDB 企业版支持。

在分布式部署中,Frontend 支持以下事件类型:

```text
admin_function
```

Metasrv 支持以下事件类型:

```text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ Procedure 事件还有以下列:
| `Failed` | Procedure 到达失败终态。请检查 `procedure_error` 中的失败详情。 |
| `Poisoned` | Procedure 无法继续。请检查 `procedure_error` 中的失败详情。 |

## 管理函数事件列

`admin_function` 事件记录 `ADMIN` 语句返回的结果。

| 列 | 含义 |
| ----------------------- | --------------------------------------------------------------------------------------------------------------- |
| `actor` | 执行 `ADMIN` 语句的当前数据库用户。 |
| `admin_function_name` | 执行的管理函数名称。 |
| `admin_function_status` | 执行状态:`Succeeded` 或 `Failed`。 |
| `admin_function_output` | JSON 数据。函数成功时包含 `result`,函数失败时包含 `error`。 |

事件的 `payload` 包含函数参数。如果返回结果是 Procedure ID,可使用该 ID 查询
Procedure 事件以查看执行进度。

## 查询 JSON 字段

详细信息请参阅 [JSON 函数](/reference/sql/functions/json.md)。在事件查询中,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ GreptimeDB 会异步写入事件记录,通常每 5 秒刷新一次。刚完成

## 配置事件记录

单机部署可以在本地配置事件记录器,分布式部署则可以在 Metasrv 上配置。配置选项和支持的事件类型请参阅[生命周期事件记录器](/user-guide/deployments-administration/configuration.md#生命周期事件记录器)。

单机部署会记录受支持的本地 DDL Procedure 事件。带有 Metasrv 的分布式部署还可以记录更多运维事件。
配置选项以及 standalone、Frontend 和 Metasrv 支持的事件类型请参阅[事件记录配置](/user-guide/deployments-administration/configuration.md#事件记录配置)。

## 查询事件

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,35 @@ ORDER BY type;
该结果仅反映最近一小时内实际出现的事件类型,不能作为已配置或受支持类型的完整清单。
支持的本地 DDL 事件类型请参阅 [DDL 事件](/user-guide/deployments-administration/monitoring/events/ddl-events.md)。

## 查询管理函数事件

`admin_function` 事件记录管理函数名称、当前数据库用户、立即执行状态、输入参数
和立即返回结果:

```sql
SELECT timestamp,
actor,
admin_function_name,
admin_function_status,
json_to_string(payload) AS payload,
json_to_string(admin_function_output) AS output
FROM greptime_private.events
WHERE type = 'admin_function'
AND timestamp >= now() - INTERVAL '1' hour
ORDER BY timestamp DESC
LIMIT 20;
```

管理函数执行成功时,`output` 包含 `result`;执行失败时,包含 `error`:

```text
| actor | admin_function_name | admin_function_status | output |
| root | flush_table | Succeeded | {"result":0} |
| root | unknown_function | Failed | {"error":"..."} |
```

`actor` 的值来自当前协议会话用户。

将事件类型、数据库和对象名称组合,可以避免混入无关事件:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: greptime_private 数据库中的 events 表。

`events` 表保存 GreptimeDB 运行期间产生的事件。单机部署记录受支持的本地 DDL Procedure 事件;带有 Metasrv 的分布式部署还可以记录运维事件。事件会异步写入,写入失败不会影响原操作的执行结果。因此,不能以事件是否出现作为操作成功的依据。

该表会在首次记录事件时自动创建。如果还没有事件记录,或已禁用事件记录,查询会提示表不存在。配置方法请参阅[生命周期事件记录器](/user-guide/deployments-administration/configuration.md#生命周期事件记录器)。
该表会在首次记录事件时自动创建。如果还没有事件记录,或已禁用事件记录,查询会提示表不存在。配置方法请参阅[事件记录配置](/user-guide/deployments-administration/configuration.md#事件记录配置)。

```sql
USE greptime_private;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,9 @@ default_ratio = 1.0

如何使用分布式追踪,请参考 [Tracing](/user-guide/deployments-administration/monitoring/tracing.md#教程使用-jaeger-追踪-greptimedb-调用链路)

### 生命周期事件记录器
### 事件记录配置

生命周期事件记录器会将 Procedure 的生命周期事件持久化到 `greptime_private.events` 系统表。在单机模式下使用 `standalone` 配置;在分布式部署中,在 Metasrv 上配置:
记录的事件保存在 `greptime_private.events` 系统表中。

```toml
[event_recorder]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GreptimeDB 会异步写入事件记录,通常每 5 秒刷新一次。刚完成

## 配置事件记录

单机部署可以在本地配置事件记录器,分布式部署则可以在 Metasrv 上配置。配置选项和支持的事件类型请参阅[生命周期事件记录器](/user-guide/deployments-administration/configuration.md#生命周期事件记录器)。
配置选项以及 standalone 和 Metasrv 支持的事件类型请参阅[事件记录配置](/user-guide/deployments-administration/configuration.md#事件记录配置)。

单机部署会记录受支持的本地 DDL Procedure 事件。带有 Metasrv 的分布式部署还可以记录更多运维事件。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ operation succeeded.

The table is created when the first event is recorded. If no event has been
recorded, or event recording is disabled, querying it returns a table-not-found
error. Configure recording in [Lifecycle event recorder](/user-guide/deployments-administration/configuration.md#lifecycle-event-recorder).
error. Configure recording in [Event recording](/user-guide/deployments-administration/configuration.md#event-recording).

```sql
USE greptime_private;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,9 @@ default_ratio = 1.0

How to use distributed tracing, please reference [Tracing](/user-guide/deployments-administration/monitoring/tracing.md#tutorial-use-jaeger-to-trace-greptimedb)

### Lifecycle event recorder
### Event recording

The lifecycle event recorder persists procedure lifecycle events in the `greptime_private.events` system table. Configure it in `standalone` mode or on Metasrv in a distributed deployment:
Recorded events are stored in the `greptime_private.events` system table.

```toml
[event_recorder]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ acknowledgement.

## Configure event recording

The event recorder can be configured in standalone deployments or on Metasrv in distributed deployments. See [Lifecycle event recorder](/user-guide/deployments-administration/configuration.md#lifecycle-event-recorder) for configuration options and the supported type list.
See [Event recording](/user-guide/deployments-administration/configuration.md#event-recording) for configuration options and the event types supported by standalone and Metasrv.

Standalone deployments record supported local DDL Procedure events. Distributed deployments with Metasrv can additionally record operational event types.

Expand Down
Loading