Update new relic plugin to correctly handle 1 minute time periods requested on the hour. (+1 squashed commits)
Squashed commits: [57f5f76] Update new relic plugin to correctly handle 1 minute time periods requested on the hour.
This commit is contained in:
parent
06c243ab87
commit
a7ac63c235
|
@ -129,24 +129,26 @@ func (nr *NewRelic) Gather(acc inputs.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(nr.Metrics) > 0 {
|
if len(nr.Metrics) > 0 {
|
||||||
t := time.Now()
|
tNow := time.Now()
|
||||||
tFrom := fmt.Sprintf("%d-%02d-%02dT%02d:%02d:%02d-00:00\n",
|
tFrom := tNow.Add(-1 * time.Minute)
|
||||||
t.Year(), t.Month(), t.Day(),
|
|
||||||
t.Hour(), t.Minute()-1, t.Second())
|
|
||||||
|
|
||||||
tTo := fmt.Sprintf("%d-%02d-%02dT%02d:%02d:%02d-00:00\n",
|
tFromStr := fmt.Sprintf("%d-%02d-%02dT%02d:%02d:%02d-00:00\n",
|
||||||
t.Year(), t.Month(), t.Day(),
|
tFrom.Year(), tFrom.Month(), tFrom.Day(),
|
||||||
t.Hour(), t.Minute(), t.Second())
|
tFrom.Hour(), tFrom.Minute(), 00)
|
||||||
|
|
||||||
|
tToStr := fmt.Sprintf("%d-%02d-%02dT%02d:%02d:%02d-00:00\n",
|
||||||
|
tNow.Year(), tNow.Month(), tNow.Day(),
|
||||||
|
tNow.Hour(), tNow.Minute(), 00)
|
||||||
|
|
||||||
vals := url.Values{}
|
vals := url.Values{}
|
||||||
|
|
||||||
|
vals.Add("from", tFromStr)
|
||||||
|
vals.Add("to", tToStr)
|
||||||
|
|
||||||
for k := range nr.Metrics {
|
for k := range nr.Metrics {
|
||||||
vals.Add("names[]", k)
|
vals.Add("names[]", k)
|
||||||
}
|
}
|
||||||
|
|
||||||
vals.Add("from", tFrom)
|
|
||||||
vals.Add("to", tTo)
|
|
||||||
|
|
||||||
result := conn.GetMetricData(nr.APPID, vals)
|
result := conn.GetMetricData(nr.APPID, vals)
|
||||||
|
|
||||||
var fieldsMetrics map[string]interface{}
|
var fieldsMetrics map[string]interface{}
|
||||||
|
|
Loading…
Reference in New Issue