Skip to content

fix(ops): add logrotate installer and stack rotation validation (#100) - #106

Merged
JJediny merged 1 commit into
mainfrom
fix/osquery-log-rotation
Oct 4, 2026
Merged

JJediny merged 1 commit into
mainfrom
fix/osquery-log-rotation

Conversation

@JJediny

@JJediny JJediny commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #100.

Adds scripts/install-logrotate.sh and tests/test_stack_rotation.py to support, verify, and automate host log rotation for LocalObserve log files (.data/osquery/osqueryd.results.log, .data/falco/events.jsonl, etc.).

Context & Implementation

  • .data/osquery/osqueryd.results.log grows unbounded if host logrotate is unconfigured.
  • scripts/logrotate-localobserve.conf defines weekly rotation and a 50M maxsize ceiling with copytruncate to preserve the inode and ensure the OpenTelemetry Collector's file_log receiver continues tailing across rotations without gap or desynchronization.
  • Added scripts/install-logrotate.sh supporting:
    • --dry-run: validates configuration syntax without making changes.
    • --status: displays active log sizes and installation status.
    • --force: forces immediate log rotation using an isolated status file.
    • --install: installs /etc/logrotate.d/localobserve with dynamically resolved repository paths.
  • Added tests/test_stack_rotation.py verifying:
    • Configuration existence and syntax (logrotate -d).
    • Mandatory copytruncate across all log sections.
    • maxsize boundary enforcement (<= 50M for osquery).
    • Copytruncate tailing continuity simulation.
  • Updated Taskfile.yml rotate-logs task to utilize the installer script.

Verification

  • bash scripts/install-logrotate.sh --dry-run: exit=0, valid syntax.
  • bash scripts/install-logrotate.sh --status: output verified.
  • uv run pytest tests/test_stack_rotation.py: 7 passed in 0.08s.
  • uv run pytest tests/: 361 passed, 40 skipped across the full test suite.

Provides scripts/install-logrotate.sh to install and verify the host
logrotate drop-in (/etc/logrotate.d/localobserve) for bounding results.log
and other OTel-tailed files to 50M/100M via copytruncate.
Adds tests/test_stack_rotation.py verifying config syntax, copytruncate
semantics, bounded maxsize directives, and tailing continuity.
Updates Taskfile.yml rotate-logs task to use the installer helper.
@JJediny
JJediny merged commit d61d114 into main Oct 4, 2026
9 checks passed
@JJediny
JJediny deleted the fix/osquery-log-rotation branch October 4, 2026 00:42
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.

osqueryd.results.log grows unbounded (161MB) - apply rotation

1 participant