@@ -31,7 +31,10 @@ type Agent struct {
31
31
// Interval at which to gather information
32
32
Interval Duration
33
33
34
- // Run in debug mode?
34
+ // Option for outputting data in UTC
35
+ UTC bool `toml:"utc"`
36
+
37
+ // Option for running in debug mode
35
38
Debug bool
36
39
Hostname string
37
40
@@ -43,8 +46,13 @@ type Agent struct {
43
46
44
47
// NewAgent returns an Agent struct based off the given Config
45
48
func NewAgent (config * Config ) (* Agent , error ) {
46
- agent := & Agent {Config : config , Interval : Duration {10 * time .Second }}
49
+ agent := & Agent {
50
+ Config : config ,
51
+ Interval : Duration {10 * time .Second },
52
+ UTC : true ,
53
+ }
47
54
55
+ // Apply the toml table to the agent config, overriding defaults
48
56
err := config .ApplyAgent (agent )
49
57
if err != nil {
50
58
return nil , err
@@ -199,7 +207,11 @@ func (a *Agent) crankParallel() error {
199
207
200
208
var bp BatchPoints
201
209
bp .Time = time .Now ()
210
+ if a .UTC {
211
+ bp .Time = bp .Time .UTC ()
212
+ }
202
213
bp .Tags = a .Config .Tags
214
+ bp .Precision = "s"
203
215
204
216
for sub := range points {
205
217
bp .Points = append (bp .Points , sub .Points ... )
@@ -223,8 +235,12 @@ func (a *Agent) crank() error {
223
235
}
224
236
}
225
237
226
- bp .Time = time .Now ()
227
238
bp .Tags = a .Config .Tags
239
+ bp .Time = time .Now ()
240
+ if a .UTC {
241
+ bp .Time = bp .Time .UTC ()
242
+ }
243
+ bp .Precision = "s"
228
244
229
245
return a .flush (& bp )
230
246
}
@@ -250,6 +266,10 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err
250
266
251
267
bp .Tags = a .Config .Tags
252
268
bp .Time = time .Now ()
269
+ if a .UTC {
270
+ bp .Time = bp .Time .UTC ()
271
+ }
272
+ bp .Precision = "s"
253
273
254
274
if err := a .flush (& bp ); err != nil {
255
275
outerr = errors .New ("Error encountered processing plugins & outputs" )
0 commit comments