Unable to fetch alert rules. Is the Loki data source properly configured?

Hi All,

i need help in resolving “Failed to load the data source configuration for Loki: Unable to fetch alert rules. Is the Loki data source properly configured”.

i followed below previous post but it did not helped: grafana/grafana#49618

Thanks

Hi,

Did you tried to check the loki query from Explorer?
I think you need to be sure that the loki query show the result first.

Regards,
Fadjar

i am not sure what do you mean since i am new to grafana, but after installing Grafana, Loki and Promtail then i simply added a Loki data source and connection was successful and i was able to see the logs. is this what you are suggesting. ty

What is the step to create the alert in the alert rule?
If there’s any screen shot, you can paste he, you can redacted the sensitive data for sure…

Please see the screen shot of the error i am getting. i get these errors when i go to Alert rules page.

You need to build Alert Dashboard first, using Loki query that you use before. Please make sure you use TimeSeries Panel, not to mention select the Loki as your datasource.
Then check the result. Afterward you can select the Alert and build the alert rule from this panel.
The query from the dashboard automatically created if you build this alert.
Preview the alert and create the rule that you want.

Regards,
Fadjar

Do you have an example or steps showing how to build alert dashboard using Loki Query and TimeSeries panel.
thank you

It depends what do you need:

1.) you need to remove error message
Just disable “Alerting” feature in your Loki datasource configuration

2.) you want to use Loki alerts (= alerts are stored in the Loki and not in the Grafana - I would say this is advance topic)
Investigate issue - there are topics about this type of issue on this forum

When I was first setting up Loki Ruler and managing Loki rules via Grafana UI, I had the problem that Loki query API did not share the same hostname as the ruler API.

This was what solved it for me Loki Alerting Issue · Issue #49618 · grafana/grafana · GitHub

Basically there is an Nginx reverse proxy that combines the Loki query and ruler API under the same hostname, which you then use as the datasource in Grafana.

1 Like