add option to mark field as int

This commit is contained in:
Max U
2018-07-02 11:20:16 -07:00
parent 92e156c784
commit d4a4ac25bb
4 changed files with 74 additions and 13 deletions

View File

@@ -1390,6 +1390,19 @@ func buildParser(name string, tbl *ast.Table) (parsers.Parser, error) {
}
}
c.GJSONIntPaths = make(map[string]string)
if node, ok := tbl.Fields["gjson_int_paths"]; ok {
if subtbl, ok := node.(*ast.Table); ok {
for name, val := range subtbl.Fields {
if kv, ok := val.(*ast.KeyValue); ok {
if str, ok := kv.Value.(*ast.String); ok {
c.GJSONIntPaths[name] = str.Value
}
}
}
}
}
c.MetricName = name
delete(tbl.Fields, "data_format")
@@ -1409,6 +1422,7 @@ func buildParser(name string, tbl *ast.Table) (parsers.Parser, error) {
delete(tbl.Fields, "gjson_bool_paths")
delete(tbl.Fields, "gjson_float_paths")
delete(tbl.Fields, "gjson_string_paths")
delete(tbl.Fields, "gjson_int_paths")
return parsers.NewParser(c)
}