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

Debug log for failed validation of alert rules needs to be decoded from bytes #648

Open
sed-i opened this issue Nov 26, 2024 · 0 comments
Open

Comments

@sed-i
Copy link
Contributor

sed-i commented Nov 26, 2024

When rules validation via cos-tool fails, we get a debug log like this:

Validating the rules failed: b'error validating /tmp/... (very long output)'

In charm code, we return the errors decoded, but when we print to debug-log, we do not decode:

except subprocess.CalledProcessError as e:
logger.debug("Validating the rules failed: %s", e.output)
return False, ", ".join(
[
line
for line in e.output.decode("utf8").splitlines()
if "error validating" in line
]
)

Also, the debug log line includes golang references that are not useful here.

This is repeated also here:

logger.debug("Validating the rules failed: %s", e.output)

logger.debug("Validating the rules failed: %s", e.output)

Summary

  1. When validation fails, cos-tool shouldn't dump golang exception log.
  2. When validation fails, we should print to debug-log the decoded error, not the bytes.
  3. The CosTool class should be migrated to cos-lib, to remove duplication in prometheus_scrape, prometheus_remote_write, grafana_dashboard.
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

No branches or pull requests

1 participant