Update variable names and defaults
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -36,9 +36,9 @@ type ClickHouse struct {
|
|||||||
TableMode string `toml:"table_mode"`
|
TableMode string `toml:"table_mode"`
|
||||||
SingleTableOptions SingleTableOptions `toml:"single_table"`
|
SingleTableOptions SingleTableOptions `toml:"single_table"`
|
||||||
MultiTableOptions MultiTableOptions `toml:"multi_table"`
|
MultiTableOptions MultiTableOptions `toml:"multi_table"`
|
||||||
QueueSize int `toml:"queue_size"`
|
QueueInitialSize int `toml:"queue_initial_size"`
|
||||||
QueueLimit int `toml:"queue_limit"`
|
QueueMaxSize int `toml:"queue_max_size"`
|
||||||
FlushInterval time.Duration `toml:"flush_interval"`
|
QueueFlushInterval time.Duration `toml:"queue_flush_interval"`
|
||||||
ConnectionMaxIdleTime time.Duration `toml:"connection_max_idle_time"`
|
ConnectionMaxIdleTime time.Duration `toml:"connection_max_idle_time"`
|
||||||
ConnectionMaxLifetime time.Duration `toml:"connection_max_lifetime"`
|
ConnectionMaxLifetime time.Duration `toml:"connection_max_lifetime"`
|
||||||
ConnectionMaxIdle int `toml:"connection_max_idle"`
|
ConnectionMaxIdle int `toml:"connection_max_idle"`
|
||||||
@@ -77,25 +77,25 @@ func (ch *ClickHouse) Init() error {
|
|||||||
ch.Log.Info("table_name is not set, using default value: ", ch.SingleTableOptions.TableName)
|
ch.Log.Info("table_name is not set, using default value: ", ch.SingleTableOptions.TableName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ch.QueueSize <= 0 {
|
if ch.QueueInitialSize <= 0 {
|
||||||
ch.QueueSize = 100000
|
ch.QueueInitialSize = 100000
|
||||||
ch.Log.Info("queue_size is not set, using default value: ", ch.QueueSize)
|
ch.Log.Info("queue_initial_size is not set, using default value: ", ch.QueueInitialSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ch.QueueLimit <= 0 {
|
if ch.QueueMaxSize <= 0 {
|
||||||
ch.QueueLimit = int(math.MaxUint64 >> 1)
|
ch.QueueMaxSize = int(math.MaxUint64 >> 1)
|
||||||
ch.Log.Info("queue_limit is not set, using default value: ", ch.QueueLimit)
|
ch.Log.Info("queue_max_size is not set, using default value: ", ch.QueueMaxSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ch.FlushInterval <= 0 {
|
if ch.QueueFlushInterval <= 0 {
|
||||||
ch.FlushInterval = 5 * time.Second
|
ch.QueueFlushInterval = 1 * time.Second
|
||||||
ch.Log.Info("flush_interval is not set, using default value: ", ch.FlushInterval)
|
ch.Log.Info("queue_flush_interval is not set, using default value: ", ch.QueueFlushInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
ch.metricQueue = make([]telegraf.Metric, 0, ch.QueueSize)
|
ch.metricQueue = make([]telegraf.Metric, 0, ch.QueueInitialSize)
|
||||||
ch.metricTrigger = make(chan struct{}, 1)
|
ch.metricTrigger = make(chan struct{}, 1)
|
||||||
|
|
||||||
go ch.backgroundWriter(ch.FlushInterval)
|
go ch.backgroundWriter(ch.QueueFlushInterval)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -439,8 +439,8 @@ func (ch *ClickHouse) WriteSingleTable(metrics []telegraf.Metric) error {
|
|||||||
|
|
||||||
func (ch *ClickHouse) Write(metrics []telegraf.Metric) error {
|
func (ch *ClickHouse) Write(metrics []telegraf.Metric) error {
|
||||||
ch.metricLock.Lock()
|
ch.metricLock.Lock()
|
||||||
if len(ch.metricQueue) >= ch.QueueLimit {
|
if len(ch.metricQueue) >= ch.QueueMaxSize {
|
||||||
ch.Log.Errorf("Metrics queue is full (%d/%d), dropping metrics", len(ch.metricQueue), ch.QueueLimit)
|
ch.Log.Errorf("Metrics queue is full (%d/%d), dropping metrics", len(ch.metricQueue), ch.QueueMaxSize)
|
||||||
} else {
|
} else {
|
||||||
ch.metricQueue = append(ch.metricQueue, metrics...)
|
ch.metricQueue = append(ch.metricQueue, metrics...)
|
||||||
}
|
}
|
||||||
|
@@ -28,15 +28,15 @@
|
|||||||
# table_prefix = "telegraf"
|
# table_prefix = "telegraf"
|
||||||
|
|
||||||
## Initial metric queue size, resizes automatically if the queue becomes too large
|
## Initial metric queue size, resizes automatically if the queue becomes too large
|
||||||
# queue_size = 100000
|
# queue_initial_size = 100000
|
||||||
|
|
||||||
## Maximum queue size, 0 means unlimited.
|
## Maximum queue size, 0 means unlimited.
|
||||||
## If the queue reaches this size, new writes will be dropped until it drains.
|
## If the queue reaches this size, new writes will be dropped until it drains.
|
||||||
# queue_limit = 0
|
# queue_max_size = 0
|
||||||
|
|
||||||
## Flush interval for the metric queue
|
## Flush interval for the metric queue
|
||||||
## The agent waits until N seconds have passed without any writes before flushing metrics to ClickHouse.
|
## The agent waits until N seconds have passed without any writes before flushing metrics to ClickHouse.
|
||||||
# queue_flush_interval = "5"
|
# queue_flush_interval = "1"
|
||||||
|
|
||||||
## Maximum amount of time a connection may be idle. "0s" means connections are
|
## Maximum amount of time a connection may be idle. "0s" means connections are
|
||||||
## never closed due to idle time.
|
## never closed due to idle time.
|
||||||
|
Reference in New Issue
Block a user