This repository has been archived on 2025-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
Files
telegraf-clickhouse-plugin/README.md
Nikolaos Karaolidis 7b2191d2ea Update README
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2023-07-27 09:12:46 +03:00

36 lines
1.4 KiB
Markdown

# telegraf-clickhouse-plugin
The ClickHouse output plugin saves Telegraf metric data to a ClickHouse database.
The plugin uses Golang's generic "database/sql" interface and third party drivers.
## Build
Dependencies:
* [Go](https://golang.org/doc/install)
* [Make](https://www.gnu.org/software/make/)
To build the plugin, run `make` in the root directory of the project.
Alternatively, you can build the plugin using Docker:
```bash
docker run --rm -v $(pwd):/telegraf -w /telegraf -e CGOENABLED=false -e GOOS=linux -e GOARCH=amd64 golang go build -o telegraf-clickhouse-plugin-linux-amd64 cmd/main.go
docker run --rm -v $(pwd):/telegraf -w /telegraf -e CGOENABLED=false -e GOOS=linux -e GOARCH=arm64 golang go build -o telegraf-clickhouse-plugin-linux-arm64 cmd/main.go
```
## Getting started
To use the plugin, set the data source name (DSN). The user account must have privileges to insert rows and create tables.
## Advanced options
When the plugin first connects it runs SQL from the init_sql setting, allowing you to perform custom initialization for the connection.
Before inserting a row, the plugin checks whether the table exists. If it doesn't exist, the plugin creates the table.
## DSN
Currently, Telegraf's sql output plugin depends on [clickhouse-go v1.5.4](https://github.com/ClickHouse/clickhouse-go/tree/v1.5.4) which uses a [different DSN format](https://github.com/ClickHouse/clickhouse-go/tree/v1.5.4#dsn) than its newer `v2.*` version.