Alerts with LOKI issue : Failed to load the data source configuration for Loki: Unable to fetch alert rules. Is the Loki data source properly configured?

Hi, when I try to create an alert on loki I get always the same error:

Failed to load the data source configuration for Loki: Unable to fetch alert rules. Is the Loki data source properly configured?

What is wrong here?

In my loki-config.yml:

ruler:
storage:
type: local
local:
directory: /etc/loki/rules/fake
rule_path: /loki/rules
alertmanager_url: http://XXXX:9093
ring:
kvstore:
store: inmemory
enable_api: true

And in my docker:

docker run -dp 3100:3100 --restart=unless-stopped --name loki -v /opt/loki-data/loki-config.yml:/mnt/config/loki-config.yml -v /opt/loki-data:/loki -v /opt/loki-data/rules:/etc/loki/rules/fake grafana/loki:2.0.0 --config.file=/mnt/config/loki-config.yml

Any idea or help please???

THANK YOU!!

~ the grafana team

Hi @claclin73,

Welcome to the :grafana: community forum !!

Though I have limited knowledge on this topic, I will try my best to help here.

So, I found exact same issue in our Github repo. and the reported user found the solution by setting the correct storage type inside Loki’s config.yml file.

Can you please check your Loki config file as it might be that the issue is in there (or just a classic YAML syntax issue)?

I also found this reference link where it describes how to set up Loki with the Alertmanager and it contains the example snippet for the Loki config file.

I hope this helps.

1 Like

Thanks for your answer. I have tried what is posted there but it still doesn´t work…

Can you please tell me what Grafana and Loki versions you are running?

Also, these alerts which are getting error messages, did you create them newly or were created in a previous version of the Grafana server?

I am using th V9.0.2 of Grafana and for Loki 2.0.0. I have tried with latest of Loki but I have the same issue.

What io your datasource for Alerting ?