Skip to content

Add log level support and decrease info level verbosity#701

Open
michaelprice232 wants to merge 1 commit intonewrelic:mainfrom
michaelprice232:add-log-level-support
Open

Add log level support and decrease info level verbosity#701
michaelprice232 wants to merge 1 commit intonewrelic:mainfrom
michaelprice232:add-log-level-support

Conversation

@michaelprice232
Copy link

@michaelprice232 michaelprice232 commented Feb 12, 2026

Description

Aims to resolve #700

Following an investigation into log levels in our CI K8s cluster - which uses ephemeral CI runners so there are lots of pod create events - we uncovered the following:

  • The k8s-metadata-injection app was the heaviest logger out of all the nri-bundle components we use
  • For each pod create event there are 5 INFO level logs generated, which could lead to a performance overhead on larger clusters
  • There was no log level support (defaults to INFO)
  • In one of the logs userinfo is being returned at INFO level which might not be desirable in some environments

This PR aims to address the above concerns by:

  1. Adding log level support
  2. Dropping the existing 5 INFO level logs to DEBUG level
  3. Add a new single INFO level log which provides a summary

Also updated the Helm chart to add the new environment variable - NEW_RELIC_K8S_METADATA_INJECTION_LOG_LEVEL - which defaults to INFO level.

Added some basic unit and Helm tests. As part of manual testing locally I deployed the config into a Minikube cluster and then provisioned some pods.

Using the default INFO log level:

$ k logs nri-metadata-injection-6cfb7f868-gtzwf                                                                                                                                                   
{"level":"info","ts":"2026-02-11T16:17:25.767Z","caller":"server/main.go:83","msg":"starting the TLS readiness server"}
{"level":"info","ts":"2026-02-11T16:17:25.768Z","caller":"server/main.go:98","msg":"starting the webhook server"}
{"level":"info","ts":"2026-02-11T16:19:42.168Z","caller":"server/webhook.go:160","msg":"admission review received","operation":"CREATE","kind":"Pod","namespace":"default","podGenerateName":"nginx-66686b6766-","uid":"6d45b223-0f54-48c7-910f-fc994517596d","mutate":true}

Using the DEBUG log level you can see the previous log entries which have been left untouched.

I noted there are some docs which explicitly call out the log line entries. I've added a PR for that repo: newrelic/docs-website#23044.

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New feature / enhancement (non-breaking change which adds functionality)
  • Security fix
  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • Add changelog entry following the contributing guide
  • Documentation has been updated
  • This change requires changes in testing:
    • unit tests
    • E2E tests

@michaelprice232 michaelprice232 requested a review from a team as a code owner February 12, 2026 08:37
michaelprice232 added a commit to michaelprice232/docs-website that referenced this pull request Feb 16, 2026
Depends on newrelic/k8s-metadata-injection#701 being merged first, which updates the logging strategy of the k8s-metadata-injection mutating web hook component.
michaelprice232 added a commit to michaelprice232/docs-website that referenced this pull request Feb 16, 2026
Depends on newrelic/k8s-metadata-injection#701 being merged first, which updates the logging strategy of the k8s-metadata-injection mutating web hook component.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admission webhook logs high-volume request details (including userinfo) at INFO level with no log level configuration

1 participant

Comments