aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-08-15 20:13:55 +0700
committerShulhan <ms@kilabit.info>2022-08-15 20:13:55 +0700
commit8a6eaebb36c0761b21398e72d934c072ac67fa7f (patch)
tree35150d19108888fb2c85b6d4743411121de4e493 /config.go
parent2965b17ccc24abde2346c20ee1f9384ae6e12f20 (diff)
downloadhaminer-8a6eaebb36c0761b21398e72d934c072ac67fa7f.tar.xz
all: add support for influxd API v2
This changes replace the "influxdb_api_write" with new section `[forwarder "influxd"]`. The section contains version, url, org, bucket, user, password, and token. The version field define the API version to be used when writing log to Influxd.
Diffstat (limited to 'config.go')
-rw-r--r--config.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/config.go b/config.go
index 79d08f5..857a392 100644
--- a/config.go
+++ b/config.go
@@ -31,6 +31,8 @@ const (
// Config define options to create and run Haminer instance.
type Config struct {
+ Influxd InfluxdConfig
+
// Listen is the address where Haminer will bind and receiving
// log from HAProxy.
Listen string `ini:"haminer::listen"`
@@ -44,9 +46,6 @@ type Config struct {
// output.
RequestHeaders []string `ini:"haminer::capture_request_header"`
- // InfluxAPIWrite define HTTP API to write to Influxdb.
- InfluxAPIWrite string `ini:"haminer::influxdb_api_write"`
-
HttpUrl []string `ini:"preprocess:tag:http_url"`
// retags contains list of pre-processing rules for tag.
@@ -99,6 +98,11 @@ func (cfg *Config) Load(path string) (err error) {
return fmt.Errorf(`%s: %w`, logp, err)
}
+ err = cfg.Influxd.init()
+ if err != nil {
+ return fmt.Errorf(`%s: %w`, logp, err)
+ }
+
return nil
}
@@ -143,6 +147,9 @@ func (cfg *Config) parsePreprocessTag() (err error) {
if err != nil {
return fmt.Errorf(`%s: %w`, logp, err)
}
+ if retag == nil {
+ continue
+ }
cfg.retags = append(cfg.retags, retag)
}