fix(parsers.xpath): Handle explicitly defined fields correctly (#13550)
This commit is contained in:
parent
64ea1d00cb
commit
57bcdaf695
|
|
@ -397,6 +397,13 @@ func (p *Parser) parseQuery(starttime time.Time, doc, selected dataNode, config
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query field %q: %w", name, err)
|
||||
}
|
||||
|
||||
if config.FieldsHexFilter != nil && config.FieldsHexFilter.Match(name) {
|
||||
if b, ok := v.([]byte); ok {
|
||||
v = hex.EncodeToString(b)
|
||||
}
|
||||
}
|
||||
|
||||
fields[name] = v
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
data fieldc="this is a test",fielda="0001020304050607",fieldb="666f6f626172" 1687852514000000000
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Example data:
|
||||
# [
|
||||
# {
|
||||
# "str_a": bytearray("this is a test"),
|
||||
# "str_b": bytearray("foobar"),
|
||||
# "bytes_a": bytearray([0, 1, 2, 3, 4, 5, 6, 7]),
|
||||
# "bytes_b": bytearray("foobar"),
|
||||
# "timestamp": 1687852514
|
||||
# }
|
||||
# ]
|
||||
|
||||
[[inputs.file]]
|
||||
files = ["./testcases/cbor_hex_encoding/data.bin"]
|
||||
data_format = "xpath_cbor"
|
||||
|
||||
xpath_native_types = true
|
||||
|
||||
[[inputs.file.xpath]]
|
||||
metric_name = "'data'"
|
||||
metric_selection = "child::*"
|
||||
timestamp = "timestamp"
|
||||
timestamp_format = "unix"
|
||||
fields_bytes_as_hex = ["fielda", "fieldb"]
|
||||
|
||||
[inputs.file.xpath.fields]
|
||||
fielda = "bytes_a"
|
||||
fieldb = "bytes_b"
|
||||
fieldc = "str_a"
|
||||
|
||||
Loading…
Reference in New Issue