Skip to content

How do I add fixed attributes to the expanded array? #8644

Answered by spencergilbert
PanHywel asked this question in Q&A
Discussion options

You must be logged in to vote
source = '''
. = .msg
.clientIp = .x-forwarded-for
'''

The first line here will replace the entire event (.) with the the .msg field, if present. The following line should set a root level field named clientIp to the contents of the .x-forwarded-for field (presumably a part of the .msg key you used above?).

Could you share an example of an event that would be going into the remap transform here?

EDIT: if that second snippet is the example input, I think you may just want to use unnest on .msg

source = """
. = unnest!(.msg)
.clientIp = del(.x-forwarded-for)
"""

EDIT2: 💭 might require two remaps:

[transforms.parse_logs]
type = "remap"
inputs = ["httpSources"]
source = '''
. = unnest(.msg)
'''

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@spencergilbert
Comment options

@spencergilbert
Comment options

@PanHywel
Comment options

@spencergilbert
Comment options

@PanHywel
Comment options

Answer selected by PanHywel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #8642 on August 10, 2021 13:46.