Skip to content

Converting protobuf bytes to JSON #19434

Closed Answered by hanshuebner
hanshuebner asked this question in Q&A
Discussion options

You must be logged in to vote

I came up with this VRL transform myself:

[transforms.convert_ids]
type = "remap"
inputs = [ "http" ]
source = '''
. = map_values(., true) -> |value| {
                      if is_object(value) {
                         if exists(value.trace_id) { value.trace_id, err = encode_base16(value.trace_id)}
                         if exists(value.parent_span_id) { value.parent_span_id, err = encode_base16(value.parent_span_id) }
                         if exists(value.span_id) { value.span_id, err = encode_base16(value.span_id) }
                      }
                      value
}

It seems that the bytes from the protobuf input data are just carried into JSON strings with no conversion appl…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hanshuebner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant