canonical / loki-k8s-operator

This charmed operator automates the operational procedures of ryunning Grafana Loki, an open-source logs backend, in monolithic mode
https://charmhub.io/loki-k8s
Apache License 2.0
8 stars 15 forks source link

LogForwader doesn't handle alert rules #403

Open saltiyazan opened 1 month ago

saltiyazan commented 1 month ago

Bug Description

LogForwarder in loki_push_api doesn't put the alert rules to relation data. I was trying to set some logging alert rules in vault-k8s that uses LogForwarder to forward its logs to Loki through grafana-agent. I couldn't find the alert rule in Grafana, doing some debugging I could not find the alert rules nor the path to the alert rules in the relation data. I looked at the code and found that LogForwarder doesn't do much with the alert rules path it receives in the init function.

Only the _handle_alert_rules function puts the alert rules to relation data and LogForwarder doesn't call that function.

To Reproduce

I faced this issue during development, while I was trying to add Loki alert rules to vault-k8s that uses LogForwarder, the rule I added looked like this and I added it under the default path used in the lib, this is not published to charmhub but any trying to add log alert rules to any charm that uses LogForwarder should have the same result.

  1. Deploy your charm that uses LogForwarder and has log alert rules, let's call
  2. juju deploy cos-lite --trust
  3. juju deploy grafana-agent-k8s
  4. juju integrate <your-charm>:logging grafana-agent-k8s
  5. juju integrate loki:logging grafana-agent-k8s:logging-consumer
  6. juju show-unit <your-charm>/0
  7. juju show-unit grafana-agent-k8s/0

Alert rules are not in the relation data.

Environment

LIBAPI = 1 LIBPATCH = 10

Relevant log output

N/A

Additional context

No response

dstathis commented 5 days ago

We need to call _handle_alert_rules in LogForwarder.