Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add event field to http body #18

Open
dtclayton opened this issue Jul 28, 2019 · 3 comments
Open

Unable to add event field to http body #18

dtclayton opened this issue Jul 28, 2019 · 3 comments

Comments

@dtclayton
Copy link

I would like to reference a value from an event field into the http body.
It doesn't seem to be possible, but it states it is possible with headers? Is it also possible with the http body?

@ankitnfs
Copy link

ankitnfs commented Aug 3, 2020

Hi - any progress on this ? I am also facing this issue.

@ankitnfs
Copy link

ankitnfs commented Aug 4, 2020

Found a workaround, Use below in the filters to have event into a given field

ruby {
code => "
# Move everything to request
event.set('request', event.to_hash)
"
}

and then pass, body => "%{request}"

@C0rn3j
Copy link

C0rn3j commented Jan 22, 2024

It would be really nice if some example documentation could be added, both in the README which doesn't even link to the plugin page or call the filter the HTTP filter and the actual documentation.

# Way to set the entire body from the outside
mutate {
	add_field => { 
		"[cm][request][body]" => '{"data":{"nodeId":4,"dateFrom":"%{[datetime]}","kind":"compute"}}' 
	}
}
...
body_format => "text"
body => "%{[cm][request][body]}"
# Way to set the body from the inside while keeping some things modular
body_format => "json"
body => {
	"data" => {
		"nodeId" => 4
		"%{[cm][date_name]}" => "%{[datetime]}"
		"kind" => "compute"
		"isSuccess" => true
	}
}

There is no way to set up the body from a previously existing hash. (outside of hacks with ruby code)

# This block won't work

add_field => {
    "[cm][request][body]" => {
        "data" => {
            "nodeId" => 4
            "dateTo" => "%{[datetime]}"
            "kind" => "compute"
            "isSuccess" => true
        }
    }
}
...
body_format => "json"

# This will just set the string "[cm][request][body]"
body => "[cm][request][body]"

# This will just pass the raw Hash, not parsed JSON
body => "${[cm][request][body]}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants