Support configuring a default timezone in JSON parser (#5472)

This commit is contained in:
Douglas Drinka
2019-02-25 12:30:33 -07:00
committed by Daniel Nelson
parent eb794ec30f
commit 1886676e14
7 changed files with 95 additions and 4 deletions

View File

@@ -599,6 +599,23 @@ func TestTimeParser(t *testing.T) {
require.Equal(t, false, metrics[0].Time() == metrics[1].Time())
}
func TestTimeParserWithTimezone(t *testing.T) {
testString := `{
"time": "04 Jan 06 15:04"
}`
parser := JSONParser{
MetricName: "json_test",
JSONTimeKey: "time",
JSONTimeFormat: "02 Jan 06 15:04",
JSONTimezone: "America/New_York",
}
metrics, err := parser.Parse([]byte(testString))
require.NoError(t, err)
require.Equal(t, 1, len(metrics))
require.EqualValues(t, int64(1136405040000000000), metrics[0].Time().UnixNano())
}
func TestUnixTimeParser(t *testing.T) {
testString := `[
{