2022-04-21 23:45:47 +08:00
|
|
|
# CrateDB Output Plugin
|
2017-11-10 06:03:16 +08:00
|
|
|
|
2022-04-21 23:45:47 +08:00
|
|
|
This plugin writes to [CrateDB](https://crate.io/) via its [PostgreSQL
|
|
|
|
|
protocol](https://crate.io/docs/crate/reference/protocols/postgres.html).
|
2017-11-10 06:03:16 +08:00
|
|
|
|
|
|
|
|
## Table Schema
|
|
|
|
|
|
|
|
|
|
The plugin requires a table with the following schema.
|
|
|
|
|
|
|
|
|
|
```sql
|
2023-10-30 16:02:12 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS my_metrics (
|
2017-11-10 06:03:16 +08:00
|
|
|
"hash_id" LONG INDEX OFF,
|
|
|
|
|
"timestamp" TIMESTAMP,
|
|
|
|
|
"name" STRING,
|
|
|
|
|
"tags" OBJECT(DYNAMIC),
|
|
|
|
|
"fields" OBJECT(DYNAMIC),
|
2023-10-30 16:02:12 +08:00
|
|
|
"day" TIMESTAMP GENERATED ALWAYS AS date_trunc('day', "timestamp"),
|
2017-11-10 06:03:16 +08:00
|
|
|
PRIMARY KEY ("timestamp", "hash_id","day")
|
|
|
|
|
) PARTITIONED BY("day");
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The plugin can create this table for you automatically via the `table_create`
|
|
|
|
|
config option, see below.
|
|
|
|
|
|
2022-10-27 03:58:36 +08:00
|
|
|
## Global configuration options <!-- @/docs/includes/plugin_config.md -->
|
|
|
|
|
|
|
|
|
|
In addition to the plugin-specific configuration settings, plugins support
|
|
|
|
|
additional global and plugin configuration settings. These settings are used to
|
|
|
|
|
modify metrics, tags, and field or create aliases and configure ordering, etc.
|
|
|
|
|
See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|
|
|
|
|
2023-01-12 23:55:21 +08:00
|
|
|
[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins
|
2022-10-27 03:58:36 +08:00
|
|
|
|
2017-11-10 06:03:16 +08:00
|
|
|
## Configuration
|
|
|
|
|
|
2022-05-25 22:48:59 +08:00
|
|
|
```toml @sample.conf
|
2017-11-10 06:03:16 +08:00
|
|
|
# Configuration for CrateDB to send metrics to.
|
|
|
|
|
[[outputs.cratedb]]
|
2021-06-03 11:28:16 +08:00
|
|
|
# A github.com/jackc/pgx/v4 connection string.
|
|
|
|
|
# See https://pkg.go.dev/github.com/jackc/pgx/v4#ParseConfig
|
2017-11-10 06:03:16 +08:00
|
|
|
url = "postgres://user:password@localhost/schema?sslmode=disable"
|
|
|
|
|
# Timeout for all CrateDB queries.
|
|
|
|
|
timeout = "5s"
|
|
|
|
|
# Name of the table to store metrics in.
|
|
|
|
|
table = "metrics"
|
|
|
|
|
# If true, and the metrics table does not exist, create it automatically.
|
|
|
|
|
table_create = true
|
2021-08-11 05:48:02 +08:00
|
|
|
# The character(s) to replace any '.' in an object key with
|
|
|
|
|
key_separator = "_"
|
2017-11-10 06:03:16 +08:00
|
|
|
```
|