Envoy: [Feature Request] Support environment variables in log formatting

Created on 21 Aug 2020  路  5Comments  路  Source: envoyproxy/envoy

Adding a request to support environment variables in our log formatting, perhaps using the ENV key (similar to REQ, RESP, etc). HOSTNAME is an already supported keyword pulled from the environment--this feature would expand on that.

Some values are known ahead of time and can be baked into the log format. However, the use case would be for logging runtime values (host IP, AZ, etc) that are only known when the container is deployed. Our current solution is to parse the config file, injecting selected envvars, etc before booting the service.

access_log:
  - name: envoy.access_loggers.file
    config:
      path: /dev/stdout
      json_format:
        hostname: "%HOSTNAME%"
        method: "%REQ(:METHOD)%"
        app_version: "%ENV(APP_VERSION)%"
        private_ip: "%ENV(PRIVATE_IP)%"
        region: "%ENV(REGION)%"
export APP_VERSION=0.1.0
export PRIVATE_IP=192.168.1.5
export REGION=us-east-1
envoy -c envoy.yaml

#=> {
  "hostname":"macbook-pro",
  "method":"GET",
  "app_version": "0.1.0",
  "private_ip": "192.168.1.5",
  "region": "us-east-1"
}
areaccess_log enhancement help wanted

All 5 comments

https://github.com/envoyproxy/envoy/blob/b7138814dde530b8c2957e806ea40879a4fdce32/source/common/common/logger.h#L252-L263

Do we just have to add the new params here?

( I am completely new here and if you know of another c++ project that would be easier for me to start with, I would go there before trying to contribute here)

Hi @yozaam! Have you already started to work on this?
I also got an interest in this feature request, so if you haven't, I would like to take it. (never mind if you have:+1:)

Hi @yozaam! Have you already started to work on this?
I also got an interest in this feature request, so if you haven't, I would like to take it. (never mind if you have馃憤)

Hey @musaprg go ahead :D

/assign @Shikugawa

Was this page helpful?
0 / 5 - 0 ratings

Related issues

boncheo picture boncheo  路  3Comments

justConfused picture justConfused  路  3Comments

hzxuzhonghu picture hzxuzhonghu  路  3Comments

weixiao-huang picture weixiao-huang  路  3Comments

hawran picture hawran  路  3Comments