Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
f2966b372e | |||
7b2191d2ea |
6
Makefile
6
Makefile
@@ -1,7 +1,5 @@
|
||||
.PHONY: build
|
||||
|
||||
COMMIT_HASH=$(shell git rev-parse --short HEAD)
|
||||
|
||||
build:
|
||||
CGOENABLED=false GOOS=linux GOARCH=amd64 go build -o clickhouse_${COMMIT_HASH}_amd64 cmd/main.go
|
||||
CGOENABLED=false GOOS=linux GOARCH=arm64 go build -o clickhouse_${COMMIT_HASH}_arm64 cmd/main.go
|
||||
CGOENABLED=false GOOS=linux GOARCH=amd64 go build -o telegraf-clickhouse-plugin-linux-amd64 cmd/main.go
|
||||
CGOENABLED=false GOOS=linux GOARCH=arm64 go build -o telegraf-clickhouse-plugin-linux-arm64 cmd/main.go
|
||||
|
16
README.md
16
README.md
@@ -4,6 +4,22 @@ 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.
|
||||
|
@@ -160,10 +160,10 @@ func (ch *ClickHouse) toDatatype(value interface{}) string {
|
||||
|
||||
func (ch *ClickHouse) toNullableDatatype(key string, value interface{}) string {
|
||||
datatype := ch.toDatatype(value)
|
||||
if key != "host" && key != ch.TimestampColumn && key != "measurement" {
|
||||
return fmt.Sprintf("Nullable(%s)", datatype)
|
||||
if key == "host" || key == "measurement" {
|
||||
return fmt.Sprintf("LowCardinality(%s)", datatype)
|
||||
}
|
||||
return datatype
|
||||
return fmt.Sprintf("Nullable(%s)", datatype)
|
||||
}
|
||||
|
||||
func (ch *ClickHouse) pepareMetrics(metrics []telegraf.Metric, metricsData map[string][]map[string]interface{}, columns map[string]*orderedmap.OrderedMap[string, string]) {
|
||||
|
Reference in New Issue
Block a user