GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add JSON logging format support for scan jobs and enforcer by moshemorad · Pull Request #539 · robusta-dev/krr

Conversation

@moshemorad

@moshemorad moshemorad commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Add opt-in JSON log output (one object per line) so KRR logs are easier to index, search, and filter with log scrapers such as Filebeat. This aligns KRR with the logging approach used across the other Robusta services (runner, Holmes, relay), all driven by the same ENABLE_JSON_LOGS_FORMAT toggle. Part of ROB-459.

Key Changes

  • Scanner (robusta_krr/core/models/config.py): set_config() emits a python-json-logger JsonFormatter (with levelname → severity) when ENABLE_JSON_LOGS_FORMAT is set. This is read from the environment only — never a CLI flag — so the interactive CLI keeps its Rich output. The runner sets this env var on the KRR scan Job (only when KRR_PUSH_SCAN is enabled, since the non-push path parses the result out of the job's combined stdout/stderr logs).
  • Enforcer (enforcer/enforcer_main.py): the resident enforcer pod swaps its plain formatter for the same JSON formatter when the toggle is set.
  • Helm (helm/krr-enforcer): new enableJsonLogsFormat value (with global.enableJsonLogsFormat honored as a fallback) wired to the ENABLE_JSON_LOGS_FORMAT container env var.
  • Dependencies: add python-json-logger; poetry.lock regenerated with Poetry 1.8.5 (matching the committed lock's generator) so the change is limited to adding the new package.

Notes

  • Default behavior is unchanged: with the toggle off, the scanner keeps Rich output and the enforcer keeps its plain text format.
  • The interactive CLI is intentionally never switched to JSON.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AozEpN8uwPRQuF8FPRX4Jy


Generated by Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0a683bf2-9ca4-4aea-aef3-9e5653bdf0bb

📥 Commits

Reviewing files that changed from the base of the PR and between 2657080 and cefb2b2.

📒 Files selected for processing (2)
  • enforcer/enforcer_main.py
  • robusta_krr/core/models/config.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • enforcer/enforcer_main.py
  • robusta_krr/core/models/config.py

Walkthrough

Adds optional JSON log formatting controlled by ENABLE_JSON_LOGS_FORMAT, updates both Python logging paths, adds the JSON logger dependency, and wires the setting through Helm values into the enforcer Deployment.

Changes

JSON logging configuration

Layer / File(s) Summary
Runtime JSON logging setup
pyproject.toml, requirements.txt, enforcer/requirements.txt, robusta_krr/core/models/config.py, enforcer/enforcer_main.py
Adds python-json-logger and selects JSON or existing plain-text formatting based on the environment variable, including the severity field mapping.
Helm logging value wiring
helm/krr-enforcer/values.yaml, helm/krr-enforcer/templates/enforcer.yaml
Adds the logging toggle and injects ENABLE_JSON_LOGS_FORMAT into the Deployment using global, local, and default values.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding JSON logging support for scan jobs and the enforcer.
Description check ✅ Passed The description is directly related to the changes and accurately summarizes the JSON logging work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/json-log-format-runner-vqbzst

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

claude added 3 commits July 14, 2026 11:00
@claude
Add JSON log format for scan jobs and enforcer (ROB-459)
7bba816
Add an opt-in ENABLE_JSON_LOGS_FORMAT toggle so KRR emits logs as JSON
(one object per line) instead of the default output, matching the format
used across Robusta services. This makes logs easier to index and filter
with scrapers like Filebeat.

- config.py set_config(): env-driven JSON branch (never a CLI flag, so
  the interactive CLI keeps its Rich output); used when KRR runs as an
  in-cluster scan job
- enforcer_main.py: JSON formatter branch for the enforcer pod
- helm/krr-enforcer: enableJsonLogsFormat value + env var
- add python-json-logger dependency

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AozEpN8uwPRQuF8FPRX4Jy
Signed-off-by: Claude <[email protected]>
@claude
Regenerate poetry.lock with Poetry 1.8.5
4c697dd
Re-lock with the same Poetry version that generated the committed lock
(1.8.5) so the change is limited to adding python-json-logger instead of
rewriting the whole file in the 2.x lock format.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AozEpN8uwPRQuF8FPRX4Jy
Signed-off-by: Claude <[email protected]>
@claude
Add python-json-logger to pip requirements files
2657080
The scanner and enforcer Docker images install dependencies with
`pip install -r requirements.txt`, not Poetry, so adding the package to
pyproject.toml/poetry.lock alone did not make it available at runtime —
the scanner crashed with `ModuleNotFoundError: No module named
'pythonjsonlogger'` when ENABLE_JSON_LOGS_FORMAT was enabled.

Add python-json-logger==3.3.0 to both requirements.txt (scanner) and
enforcer/requirements.txt so the module is present in the images.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AozEpN8uwPRQuF8FPRX4Jy
Signed-off-by: Claude <[email protected]>
@moshemorad
moshemorad force-pushed the claude/json-log-format-runner-vqbzst branch from a49795e to 2657080 Compare July 14, 2026 11:00
naomi-robusta
naomi-robusta previously approved these changes Jul 14, 2026
View reviewed changes
Comment thread enforcer/enforcer_main.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread robusta_krr/core/models/config.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@claude
Move pythonjsonlogger import to module top level
cefb2b2
Address review: import JsonFormatter at the top of enforcer_main.py and
config.py instead of inside the ENABLE_JSON_LOGS_FORMAT branch. In
enforcer_main.py it goes after the custom-certificate setup, since the
JSON formatter does not initialize any HTTP client.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AozEpN8uwPRQuF8FPRX4Jy
Signed-off-by: Claude <[email protected]>
@moshemorad
moshemorad dismissed naomi-robusta’s stale review via cefb2b2 July 14, 2026 11:31
@moshemorad
moshemorad requested a review from naomi-robusta July 14, 2026 12:49
naomi-robusta
naomi-robusta approved these changes Jul 14, 2026
View reviewed changes
@moshemorad
moshemorad merged commit 437d81f into main Jul 15, 2026
3 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@moshemorad
moshemorad deleted the claude/json-log-format-runner-vqbzst branch July 15, 2026 08:54
@clanker-claude clanker-claude Bot mentioned this pull request Jul 21, 2026
feat(container): update image robustadev/krr ( v1.28.0 ➔ v1.29.0 ) mrdynamo/home-ops#2395
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@naomi-robusta naomi-robusta naomi-robusta approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@moshemorad @naomi-robusta @claude
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.