diff --git a/storage/config.go b/storage/config.go index a11d547..96442db 100644 --- a/storage/config.go +++ b/storage/config.go @@ -38,7 +38,8 @@ type Configuration struct { MaxSpanCount int `yaml:"max_span_count"` // Encoding either json or protobuf. Default is json. Encoding EncodingType `yaml:"encoding"` - // ClickHouse address e.g. localhost:9000. + // ClickHouse address + // e.g. single addr: localhost:9000 multi addrs: 10.10.1.1:9000,10.10.1.2:9001 Address string `yaml:"address"` // Directory with .sql files to run at plugin startup, mainly for integration tests. // Depending on the value of init_tables, this can be run as a diff --git a/storage/store.go b/storage/store.go index 14a559c..9491d1c 100644 --- a/storage/store.go +++ b/storage/store.go @@ -139,8 +139,12 @@ func NewStore(logger hclog.Logger, cfg Configuration) (*Store, error) { func connector(cfg Configuration) (*sql.DB, error) { var conn *sql.DB + var addrs []string + for _, addr := range strings.Split(cfg.Address, ",") { + addrs = append(addrs, sanitize(addr)) + } options := clickhouse.Options{ - Addr: []string{sanitize(cfg.Address)}, + Addr: addrs, Auth: clickhouse.Auth{ Database: cfg.Database, Username: cfg.Username,