Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option for log_level #217

Merged
merged 9 commits into from
Dec 10, 2024
Merged

Add config option for log_level #217

merged 9 commits into from
Dec 10, 2024

Conversation

MichaelThamm
Copy link
Contributor

@MichaelThamm MichaelThamm commented Dec 5, 2024

Closes #188

The addition of the log_level charm config option allows the user to filter classes of logs based on these allowable upstream levels: ["debug", "info", "warn", "error"]. This is useful in the event of a surge of info or debug logs that prevent the user from being able to filter for more important logs like level=error.

TODO

  • Add tests
    • Scenario test
      • Scenario dir root tests deleted due to errors running on main.
      • Use consistent naming of context vs. ctx
    • Bump to ops[testing] instead of ops-scenario.
  • Set Blocked status and centralised status settings because of model departure but let workload continue.
    • Open an issue in Prom for the same code here.

Testing

  1. Deploy and set config
juju deploy zookeeper --trust
juju deploy ./grafana-agent_ubuntu-22.04-amd64.charm gagent --trust
juju relate zookeeper gagent
# Wait for active/idle
juju config gagent log_level=error

Note: If you set an invalid log_level it will default to info and juju debug log will show:

unit-gagent-5: 15:10:07.219 WARNING unit.gagent/5.juju-log Invalid loglevel: panic given, debug/info/warn/error allowed. defaulting to INFO loglevel.
  1. Check if the Grafana Agent config file is updated
    juju ssh gagent/0 cat /etc/grafana-agent.yaml | grep log_level
  2. Check if the logs are filtered
    juju ssh gagent/0 "journalctl | grep grafana-agent"
  3. Scale the principal charm
    juju add-unit zookeeper -n 1
  4. Re-run the tests from before in the scaled scenario
  • All manual tests passed

Copy link
Contributor

@sed-i sed-i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!
A few minor comments.

src/grafana_agent.py Outdated Show resolved Hide resolved
src/grafana_agent.py Show resolved Hide resolved
tests/scenario/test_config.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add config option for the grafana-agent log level
3 participants