Closed chelseaRickman closed 2 years ago
The issue here is that the HTTP input automatically creates a content-type-to-codec mapping for application/json
to a self-instantiated codec that does not include your target
directive (see: HTTP Input: additional_codecs
), and will prefer the codecs found in the content type mapping to the "fallback" codec for the plugin itself.
To avoid this, you will need to provide an empty mapping to the HTTP input:
input {
http {
additional_codecs => {}
}
}
Logstash information:
Please include the following information:
bin/logstash --version
)logstash 8.0.0
Docker image, docker.elastic.co/logstash/logstash-oss:8.0.0
How is Logstash being run (e.g. as a service/service manager: systemd, upstart, etc. Via command line, docker/kubernetes):
How was the Logstash Plugin installed
JVM (e.g.
java -version
): 17.0.2If the affected version of Logstash is 7.9 (or earlier), or if it is NOT using the bundled JDK or using the 'no-jdk' version in 7.10 (or higher), please provide the following information:
java -version
)JAVA_HOME
environment variable if set.OS version (
uname -a
if on a Unix-like system):macOS Catalina Version 10.15.7
Description of the problem including expected versus actual behavior:
The target configuration option for the JSON codec plugin does not store the parsed JSON data at the specified target field (expected behavior). The parsed data is stored at the root of the event (actual behavior).
Steps to reproduce:
Created a logstash.conf file using the provided example provided from elastic: https://www.elastic.co/guide/en/logstash/8.0/plugins-codecs-json.html#plugins-codecs-json-target
The logstash.conf file consisted of:
Ran the logstash Docker image, mounting this logstash.conf into the container:
Using Postman, sent a POST request to 0.0.0.0/8080 with request body of: { "test": "testing", "test2": "second test" }
The output to stdout within the container:
I expected the body of my request to be placed in a "document" field, but there is no "document" field present and the body of my request was placed at the root of the event.
Please include a minimal but complete recreation of the problem, including (e.g.) pipeline definition(s), settings, locale, etc. The easier you make for us to reproduce it, the more likely that somebody will take the time to look at it.
Provide logs (if relevant):