Skip to content

Conversation

@edsiper
Copy link
Member

@edsiper edsiper commented Nov 19, 2024

This PR implements a new global Lua Table that register the Fluent Bit Environment variables.

Fixes #9585

example:

env:
  A: aaa
  B: bbb
  C: ccc

service:
    flush:           1
    log_level:       info

pipeline:
    inputs:
        - name:    random
          tag:     test
          samples: 10

    filters:
        - name:  lua
          match: "*"
          call:  append_tag
          code:  |
              function append_tag(tag, timestamp, record)
                 new_record = record
                 new_record["my_env"] = FLB_ENV
                 return 1, timestamp, new_record
              end

    outputs:
        - name:  stdout
          match: "*"

output:

test: [[1731990257.781970977, {}], {"my_env"=>{"A"=>"aaa", "C"=>"ccc", "HOSTNAME"=>"monox-2.lan", "B"=>"bbb"}, "rand_value"=>4805047635809401856}]

e.g: FLB_ENV['A'] access the string value aaa.


Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@edsiper edsiper added this to the Fluent Bit v3.2.2 milestone Nov 27, 2024
@edsiper edsiper merged commit 7cafc50 into master Nov 27, 2024
50 of 51 checks passed
@edsiper edsiper deleted the lua-flb-env branch November 27, 2024 00:25
@lecaros
Copy link
Contributor

lecaros commented Nov 28, 2024

Docs PR #1523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow accessing yaml configuration .env.xxx from lua module

4 participants