Not able to add Loki as a data source to azure managed grafana

Hi,

This is same as my previous question but I have pin pointed to the exact issue.

I have added Loki through Helm to an AKS cluster to scrape the logs from pods and send them to Grafana. However, when I try to add the loki from the AKS as a data source to Azure Managed Grafana, I get the error below.

4.240.59.35 - - [16/Apr/2025:16:54:26 +0000] "GET /rewardsy-loki/loki/api/v1/query?direction=backward&query=vector%281%29%2Bvector%281%29&time=4000000000 HTTP/1.1" 400 65 "-" "Grafana/10.4.15 AzureManagedGrafana/latest" 398 0.001 [default-loki-stack-3100] [] 10.244.2.24:3100 65 0.004 400 191f934b7faa73922d49be8a00ad9d0e

I have exposed the Loki through an Ingress Controller.

Here is the ingress rule :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: rewardsy-dev-aks-ingress
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: nginx
  rules:
    - http:
        paths:
          - path: /rewardsy-loki(/|$)(.*)
            pathType: Prefix
            backend:
              service:
                name: loki
                port:
                  number: 3100

I can confirm ingress is working as I have checked the metrics and ready endpoints through the Ingress IP. The same Loki service is sending logs to the Grafana I have deployed in the AKS to test the functionality.