From 8870512e6b1463cccee6c321ac2ee4e2ccfc51af Mon Sep 17 00:00:00 2001 From: Gunnar Aasen Date: Thu, 5 Jul 2018 17:13:59 -0700 Subject: [PATCH] Update example config with UDP precision option Also add a test for precision in the UDP configuration. --- etc/config.sample.toml | 3 +++ services/udp/config.go | 4 ++-- services/udp/config_test.go | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/etc/config.sample.toml b/etc/config.sample.toml index b4f332d9ac..4ee96a72e8 100644 --- a/etc/config.sample.toml +++ b/etc/config.sample.toml @@ -487,6 +487,9 @@ # bind-address = ":8089" # database = "udp" # retention-policy = "" + + # InfluxDB precision for timestamps on received points ("" or "n", "u", "ms", "s", "m", "h") + # precision = "" # These next lines control how batching works. You should have this enabled # otherwise you could get dropped metrics or poor performance. Batching diff --git a/services/udp/config.go b/services/udp/config.go index e239935c9e..17620a515d 100644 --- a/services/udp/config.go +++ b/services/udp/config.go @@ -100,7 +100,7 @@ type Configs []Config // Diagnostics returns one set of diagnostics for all of the Configs. func (c Configs) Diagnostics() (*diagnostics.Diagnostics, error) { d := &diagnostics.Diagnostics{ - Columns: []string{"enabled", "bind-address", "database", "retention-policy", "batch-size", "batch-pending", "batch-timeout"}, + Columns: []string{"enabled", "bind-address", "database", "retention-policy", "batch-size", "batch-pending", "batch-timeout", "precision"}, } for _, cc := range c { @@ -109,7 +109,7 @@ func (c Configs) Diagnostics() (*diagnostics.Diagnostics, error) { continue } - r := []interface{}{true, cc.BindAddress, cc.Database, cc.RetentionPolicy, cc.BatchSize, cc.BatchPending, cc.BatchTimeout} + r := []interface{}{true, cc.BindAddress, cc.Database, cc.RetentionPolicy, cc.BatchSize, cc.BatchPending, cc.BatchTimeout, cc.Precision} d.AddRow(r) } diff --git a/services/udp/config_test.go b/services/udp/config_test.go index 740f424f1e..bfcaab020b 100644 --- a/services/udp/config_test.go +++ b/services/udp/config_test.go @@ -16,6 +16,7 @@ enabled = true bind-address = ":4444" database = "awesomedb" retention-policy = "awesomerp" +precision = "s" batch-size = 100 batch-pending = 9 batch-timeout = "10ms" @@ -33,6 +34,8 @@ udp-payload-size = 1500 t.Fatalf("unexpected database: %s", c.Database) } else if c.RetentionPolicy != "awesomerp" { t.Fatalf("unexpected retention policy: %s", c.RetentionPolicy) + } else if c.Precision != "s" { + t.Fatalf("unexpected precision: %s", c.Precision) } else if c.BatchSize != 100 { t.Fatalf("unexpected batch size: %d", c.BatchSize) } else if c.BatchPending != 9 {