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

config: yaml_parser: Handle $log_level element for special case #4482

Merged
merged 1 commit into from
May 2, 2024

Conversation

cosmo0920
Copy link
Contributor

@cosmo0920 cosmo0920 commented May 1, 2024

Which issue(s) this PR fixes:

Closes #4463.

What this PR does / why we need it:

This is because @log_level is invalid for YAML.
Instead, we should interpret $log_level as @log_level on YAML parser.

Docs Changes:

Needed. Will handle on it.

fluent/fluentd-docs-gitbook#497

Release Note:

Same as title.

This is because `@log_level` is invalid for YAML.
Instead, we should interpret $log_level as `@log_level` on YAML parser.

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@daipom daipom self-requested a review May 1, 2024 08:57
@daipom
Copy link
Contributor

daipom commented May 1, 2024

Thanks! I will check this tomorrow!

@Shingo-Nakayama
Copy link
Contributor

I confirmed that it works fine.

config:
  - source:
      $type: tail
      tag: sample
      path: /tmp/test.log
      pos_file: /tmp/tail-test.pos
      $log_level: debug
      parse: 
        $type: none

  - match:
      $tag: '**'
      $type: stdout
$ bundle exec fluentd -c /Users/config.yaml
2024-05-02 12:19:15 +0900 [info]: init supervisor logger path=nil rotate_age=nil rotate_size=nil
2024-05-02 12:19:15 +0900 [info]: parsing config file is succeeded path="/Users/config.yaml"
2024-05-02 12:19:15 +0900 [info]: gem 'fluentd' version '1.16.5'
2024-05-02 12:19:15 +0900 [warn]: define <match fluent.**> to capture fluentd logs in top level is deprecated. Use <label @FLUENT_LOG> instead
2024-05-02 12:19:15 +0900 [info]: using configuration file: <ROOT>
  <source>
    @type tail
    @log_level "debug"
    tag "sample"
    path "/tmp/test.log"
    pos_file "/tmp/tail-test.pos"
    <parse>
      @type "none"
      unmatched_lines 
    </parse>
  </source>
  <match **>
    @type stdout
  </match>
</ROOT>
2024-05-02 12:19:15 +0900 [info]: starting fluentd-1.16.5 pid=36950 ruby="3.3.0"
2024-05-02 12:19:15 +0900 [info]: spawn command to main:  cmdline=["/opt/homebrew/Cellar/ruby/3.3.0/bin/ruby", "-r/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/3.3.0/bundler/setup", "-Eascii-8bit:ascii-8bit", "/opt/homebrew/lib/ruby/gems/3.3.0/bin/fluentd", "-c", "/Users/nakayamashingo/Desktop/desktop/fluentd/config.yaml", "--under-supervisor"]
2024-05-02 12:19:15 +0900 [info]: #0 init worker0 logger path=nil rotate_age=nil rotate_size=nil
2024-05-02 12:19:15 +0900 [info]: adding match pattern="**" type="stdout"
2024-05-02 12:19:15 +0900 [info]: adding source type="tail"
2024-05-02 12:19:15 +0900 [warn]: #0 define <match fluent.**> to capture fluentd logs in top level is deprecated. Use <label @FLUENT_LOG> instead
2024-05-02 12:19:15 +0900 [info]: #0 starting fluentd worker pid=36953 ppid=36950 worker=0
2024-05-02 12:19:15 +0900 [debug]: #0 Compacted entries: ["/tmp/test.log"]
2024-05-02 12:19:15 +0900 [debug]: #0 Remove missing entries. existing_targets=["/tmp/test.log"] entries_after_removing=["/tmp/test.log"]
2024-05-02 12:19:15 +0900 [debug]: #0 tailing paths: target = /tmp/test.log | existing = 
2024-05-02 12:19:15 +0900 [info]: #0 following tail of /tmp/test.log
2024-05-02 12:19:15 +0900 [info]: #0 fluentd worker is now running worker=0
2024-05-02 12:19:15.954638000 +0900 fluent.info: {"pid":36953,"ppid":36950,"worker":0,"message":"starting fluentd worker pid=36953 ppid=36950 worker=0"}
2024-05-02 12:19:15.955250000 +0900 fluent.debug: {"message":"Compacted entries: [\"/tmp/test.log\"]"}
2024-05-02 12:19:15.955269000 +0900 fluent.debug: {"existing_targets":["/tmp/test.log"],"entries_after_removing":["/tmp/test.log"],"message":"Remove missing entries. existing_targets=[\"/tmp/test.log\"] entries_after_removing=[\"/tmp/test.log\"]"}
2024-05-02 12:19:15.955695000 +0900 fluent.debug: {"message":"tailing paths: target = /tmp/test.log | existing = "}
2024-05-02 12:19:15.955829000 +0900 fluent.info: {"message":"following tail of /tmp/test.log"}
2024-05-02 12:19:15.955898000 +0900 fluent.info: {"worker":0,"message":"fluentd worker is now running worker=0"}
^C2024-05-02 12:19:18 +0900 [info]: Received graceful stop
2024-05-02 12:19:18 +0900 [info]: #0 fluentd worker is now stopping worker=0
2024-05-02 12:19:18.996849000 +0900 fluent.info: {"worker":0,"message":"fluentd worker is now stopping worker=0"}
2024-05-02 12:19:18 +0900 [info]: #0 shutting down fluentd worker worker=0
2024-05-02 12:19:18 +0900 [info]: #0 shutting down input plugin type=:tail plugin_id="object:cf8"
2024-05-02 12:19:18 +0900 [info]: #0 shutting down output plugin type=:stdout plugin_id="object:cd0"
2024-05-02 12:19:19 +0900 [info]: Worker 0 finished with status 0

@daipom
Copy link
Contributor

daipom commented May 2, 2024

@Shingo-Nakayama Thanks!

Copy link
Contributor

@daipom daipom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@daipom daipom added this to the v1.16.6 milestone May 2, 2024
@ashie ashie merged commit 236d87d into master May 2, 2024
14 of 16 checks passed
@ashie ashie deleted the handle-specical-log_level-element branch May 2, 2024 07:03
@ashie
Copy link
Member

ashie commented May 2, 2024

Thanks!

@cosmo0920
Copy link
Contributor Author

BTW, Which versions will this feature be enabled? 1.17.1 or 1.16.6?

@daipom
Copy link
Contributor

daipom commented May 2, 2024

I will backport this to 1.16.6 if there is no objection.

@cosmo0920
Copy link
Contributor Author

OK. I don't have any objections. Let's backport this to v1.16.6.

ashie added a commit that referenced this pull request Jun 7, 2024
Backport(v1.16): config: yaml_parser: Handle $log_level element for special case (#4482)
@daipom daipom modified the milestones: v1.16.6, v1.17.1 Aug 15, 2024
@daipom daipom added the backport to LTS We will backport this fix to the LTS branch label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport to LTS We will backport this fix to the LTS branch
Projects
None yet
4 participants