Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit ca549f5

Browse files
authored
feat: Log base w/ configurable pid and hostname keys (#868)
* Log base w/ configurable pid and hostname keys - `hostname` isn't always desireable and is somewhat inaccurate given os.hostname is the pod name in kubernetes * Documentation for configurable log base
1 parent f4e5037 commit ca549f5

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

charts/kubernetes-external-secrets/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ The following table lists the configurable parameters of the `kubernetes-externa
4747
| `env.AWS_INTERMEDIATE_ROLE_ARN` | Specifies a role to be assumed before assuming role arn specified in external secrets | |
4848
| `env.LOG_LEVEL` | Set the application log level | `info` |
4949
| `env.LOG_MESSAGE_KEY` | Set the key for log messages log text, for example when running on GCP it might be nice to set to `message` | `msg` |
50+
| `env.LOG_BASE_PID_KEY` | Set the key for log messages process id | `pid` |
51+
| `env.LOG_BASE_HOSTNAME_KEY` | Set the key for log messages hostname, for example, you might choose to use `pod_name` | `hostname` |
5052
| `env.USE_HUMAN_READABLE_LOG_LEVELS` | Sets log levels as string instead of ints eg `info` instead of `30`, setting this to any value will switch | `nil` |
5153
| `env.METRICS_PORT` | Specify the port for the prometheus metrics server | `3001` |
5254
| `env.ROLE_PERMITTED_ANNOTATION` | Specify the annotation key where to lookup the role arn permission boundaries | `iam.amazonaws.com/permitted` |

config/environment.js

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const pollerIntervalMilliseconds = process.env.POLLER_INTERVAL_MILLISECONDS
3131
? Number(process.env.POLLER_INTERVAL_MILLISECONDS) : 10000
3232

3333
const logLevel = process.env.LOG_LEVEL || 'info'
34+
const os = require('os')
35+
const logBasePidKey = process.env.LOG_BASE_PID_KEY || 'pid'
36+
const logBaseHostnameKey = process.env.LOG_BASE_HOSTNAME_KEY || 'hostname'
37+
const logBase = { [logBasePidKey]: process.pid, [logBaseHostnameKey]: os.hostname() }
3438
const useHumanReadableLogLevels = 'USE_HUMAN_READABLE_LOG_LEVELS' in process.env
3539
const logMessageKey = process.env.LOG_MESSAGE_KEY || 'msg'
3640

@@ -70,6 +74,7 @@ module.exports = {
7074
enforceNamespaceAnnotation,
7175
pollingDisabled,
7276
logLevel,
77+
logBase,
7378
useHumanReadableLogLevels,
7479
logMessageKey,
7580
watchTimeout,

config/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const logger = pino({
4040
redact: ['err.options.headers', 'err.options.json.jwt'],
4141
messageKey: envConfig.logMessageKey || 'msg',
4242
level: envConfig.logLevel,
43+
base: envConfig.logBase,
4344
formatters: {
4445
level (label, number) {
4546
return { level: envConfig.useHumanReadableLogLevels ? label : number }

0 commit comments

Comments
 (0)