What happend?
I'm not sure. We need actual problematic log content for investigation.
Could you paste it?
In local testing, there is no result difference.
2018-06-20 11:33:33 +0900 [info]: using configuration file: <ROOT>
<source>
@type tail
path "/path/to/json_in_json.log"
tag "tail.test"
read_from_head true
<parse>
@type json
</parse>
</source>
<match tail.**>
@type stdout
</match>
</ROOT>
2018-06-20 11:33:33 +0900 [info]: starting fluentd-1.2.2 pid=68076 ruby="2.5.1"
...snip...
2018-06-20 11:33:33.644152000 +0900 tail.test: {"k1":"v1","log":"{\"k2\":\"v2\"}"}
2018-06-20 11:32:07 +0900 [info]: using configuration file: <ROOT>
<source>
@type tail
path /path/to/json_in_json.log
tag tail.test
format json
read_from_head true
</source>
<match tail.**>
@type stdout
</match>
</ROOT>
2018-06-20 11:32:07 +0900 [info]: following tail of /path/to/json_in_json.log
2018-06-20 11:32:07 +0900 tail.test: {"k1":"v1","log":"{\"k2\":\"v2\"}"}
Thank you @repeatedly for answer!
Here is Log:
{"log":"{\"Timestamp\":\"2018-06-11T14:44:57.3591704+00:00\",\"Level\":\"Warning\",\"MessageTemplate\":\"The LINQ expression '{expression}' could not be translated and will be evaluated locally.\",\"RenderedMessage\":\"The LINQ expression '\\\"where ([x] == [dummy].something)\\\"' could not be translated and will be evaluated locally.\"", "stream":"stdout","time":"2018-06-11T14:44:57.364059249Z"}
In 0.12 I was able to easily filter in Elasticsearch using for example Level field. Now after migration I can't as in Elasticsearch I see only "log" field with whole json string which I provided
We're having the exact same issue.
On 1.1.3 our JSON logs were being parsed correctly. Using 1.2.2, which fixes a stack trace problem we were having, no JSON log parsing is occuring.
Neither of the following configurations work for us on 1.2.x:
<source>
@id source_kubernetes_containers
@type tail
path /var/log/containers/*.log
pos_file /var/log/fluentd/kubernetes-containers.pos
read_from_head true
tag kubernetes.*
<parse>
@type json
json_parser yajl
time_format %Y-%m-%dT%H:%M:%S.%NZ
</parse>
</source>
<source>
@id source_kubernetes_containers
@type tail
path /var/log/containers/*.log
pos_file /var/log/fluentd/kubernetes-containers.pos
read_from_head true
tag kubernetes.*
<parse>
@type json
time_format %Y-%m-%dT%H:%M:%S.%NZ
</parse>
</source>
I confirm that downgrade to 1.1.3 fix the problem
https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/pull/128
I found the root cause is fluent-plugin-kubernetes-metadata-filter removes automatic json merging feature since latest version.
In v1.1.3, image uses older version.
diff -u docker-image/v1.1/debian-elasticsearch/Dockerfile docker-image/v1.2/debian-elasticsearch/Dockerfile
--- docker-image/v1.1/debian-elasticsearch/Dockerfile 2018-05-14 22:41:50.000000000 +0900
+++ docker-image/v1.2/debian-elasticsearch/Dockerfile 2018-06-13 20:50:47.000000000 +0900
@@ -1,7 +1,7 @@
# AUTOMATICALLY GENERATED
# DO NOT EDIT THIS FILE DIRECTLY, USE /templates/Dockerfile.erb
-FROM fluent/fluentd:v1.1.3-debian
+FROM fluent/fluentd:v1.2.2-debian
MAINTAINER Eduardo Silva <[email protected]>
USER root
diff -u docker-image/v1.1/debian-elasticsearch/Gemfile docker-image/v1.2/debian-elasticsearch/Gemfile
--- docker-image/v1.1/debian-elasticsearch/Gemfile 2018-05-03 00:30:14.000000000 +0900
+++ docker-image/v1.2/debian-elasticsearch/Gemfile 2018-06-13 20:50:49.000000000 +0900
@@ -3,7 +3,7 @@
source "https://rubygems.org"
-gem "fluentd", "1.1.3"
+gem "fluentd", "1.2.2"
gem "oj", "3.5.1"
gem "fluent-plugin-elasticsearch"
gem "fluent-plugin-kubernetes_metadata_filter"
diff -u docker-image/v1.1/debian-elasticsearch/Gemfile.lock docker-image/v1.2/debian-elasticsearch/Gemfile.lock
--- docker-image/v1.1/debian-elasticsearch/Gemfile.lock 2018-05-14 22:41:50.000000000 +0900
+++ docker-image/v1.2/debian-elasticsearch/Gemfile.lock 2018-06-13 20:50:58.000000000 +0900
@@ -13,30 +13,30 @@
dig_rb (1.0.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
- elasticsearch (6.0.2)
- elasticsearch-api (= 6.0.2)
- elasticsearch-transport (= 6.0.2)
- elasticsearch-api (6.0.2)
+ elasticsearch (6.0.3)
+ elasticsearch-api (= 6.0.3)
+ elasticsearch-transport (= 6.0.3)
+ elasticsearch-api (6.0.3)
multi_json
- elasticsearch-transport (6.0.2)
+ elasticsearch-transport (6.0.3)
faraday
multi_json
excon (0.62.0)
- faraday (0.15.0)
+ faraday (0.15.2)
multipart-post (>= 1.2, < 3)
- ffi (1.9.23)
- fluent-plugin-elasticsearch (2.9.2)
+ ffi (1.9.25)
+ fluent-plugin-elasticsearch (2.10.3)
elasticsearch
excon
fluentd (>= 0.14.20)
- fluent-plugin-kubernetes_metadata_filter (2.0.0)
+ fluent-plugin-kubernetes_metadata_filter (2.1.2)
fluentd (>= 0.14.0, < 2)
kubeclient (~> 1.1.4)
lru_redux
- fluent-plugin-systemd (1.0.0)
+ fluent-plugin-systemd (1.0.1)
fluentd (>= 0.14.11, < 2)
- systemd-journal (~> 1.3)
- fluentd (1.1.3)
+ systemd-journal (~> 1.3.2)
+ fluentd (1.2.2)
cool.io (>= 1.4.5, < 2.0.0)
dig_rb (~> 1.0.0)
http_parser.rb (>= 0.5.1, < 0.7.0)
@@ -83,7 +83,7 @@
sigdump (~> 0.2.2)
sigdump (0.2.4)
strptime (0.2.3)
- systemd-journal (1.3.1)
+ systemd-journal (1.3.2)
ffi (~> 1.9)
thread_safe (0.3.6)
tzinfo (1.2.5)
@@ -103,7 +103,7 @@
fluent-plugin-elasticsearch
fluent-plugin-kubernetes_metadata_filter
fluent-plugin-systemd
- fluentd (= 1.1.3)
+ fluentd (= 1.2.2)
oj (= 3.5.1)
BUNDLED WITH
Common subdirectories: docker-image/v1.1/debian-elasticsearch/conf and docker-image/v1.2/debian-elasticsearch/conf
Common subdirectories: docker-image/v1.1/debian-elasticsearch/hooks and docker-image/v1.2/debian-elasticsearch/hooks
Common subdirectories: docker-image/v1.1/debian-elasticsearch/plugins and docker-image/v1.2/debian-elasticsearch/plugins
Fix for that in new version can be achieved using
https://docs.fluentd.org/v1.0/articles/filter_parser
https://docs.fluentd.org/v1.0/articles/parser_json
as mentioned in https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/issues/79
Probably it can look like:
<filter foo.bar>
@type parser
format json
key_name log
</filter>
@jcardoso-bv I'm running version 1.1.3 for now. Could not get json_parser plugin to work in 1.2.4. Can I see the complete conf? Are you using the filter parser with the source you have?
We're having the exact same issue.
On 1.1.3 our JSON logs were being parsed correctly. Using 1.2.2, which fixes a stack trace problem we were having, no JSON log parsing is occuring.
Neither of the following configurations work for us on 1.2.x:
<source> @id source_kubernetes_containers @type tail path /var/log/containers/*.log pos_file /var/log/fluentd/kubernetes-containers.pos read_from_head true tag kubernetes.* <parse> @type json json_parser yajl time_format %Y-%m-%dT%H:%M:%S.%NZ </parse> </source>
<source> @id source_kubernetes_containers @type tail path /var/log/containers/*.log pos_file /var/log/fluentd/kubernetes-containers.pos read_from_head true tag kubernetes.* <parse> @type json time_format %Y-%m-%dT%H:%M:%S.%NZ </parse> </source>
Im also having the same issue and tried couple of filter parser configs suggested here, but didn't work.. Any solution ?
FIX : https://github.com/fluent/fluentd/issues/2073#issuecomment-409469227
Most helpful comment
Fix for that in new version can be achieved using
https://docs.fluentd.org/v1.0/articles/filter_parser
https://docs.fluentd.org/v1.0/articles/parser_json
as mentioned in https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter/issues/79
Probably it can look like: