Skip to content

How to configure Loki as Prometheus datasource? #1222

Closed
@vukor

Description

@vukor

Hello,
New v0.4.0 release version is support PromQL as I understand. Here proof link - https://grafana.com/blog/2019/10/28/whats-new-in-loki-v0.4.0/

I would like to add Loki as Prometheus datasource in Grafana (6.4.3 version) but can't find what is correct address? I already use Loki datasource (address is http://loki:3100) and it works.

I need to use PromQL to configure alert trigger for some log message regexp.
Thanks.

Activity

vukor

vukor commented on Nov 1, 2019

@vukor
Author

More details:

Inside grafana/loki:v0.4.0 container:

/ $ netstat -ltnup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 :::3100                 :::*                    LISTEN      1/loki
tcp        0      0 :::9095                 :::*                    LISTEN      1/loki

9095 - is some binary data
3100 - Loki datasource, http://loki:3100/loki return 404

negbie

negbie commented on Nov 1, 2019

@negbie
Contributor

Hi,
did you try it with curl like in the examples here? Just to make sure that you can reach the query endpoint.
https://github.com/grafana/loki/blob/master/docs/api.md#examples

slim-bean

slim-bean commented on Nov 1, 2019

@slim-bean
Collaborator

Append loki to the end of your URL, like this: http://loki:3100/loki and be sure to select the Prometheus data source type.

vukor

vukor commented on Nov 1, 2019

@vukor
Author

Thanks guys, http://loki:3100/loki looks working.

lobatt

lobatt commented on Nov 16, 2019

@lobatt

Append loki to the end of your URL, like this: http://loki:3100/loki and be sure to select the Prometheus data source type.

I know this issue has been closed, but I am having some issue setting this up.
I am thrilled to learn the support for metrics for Loki.

However, when I configure my Prometheus data source to use http://loki:3100/loki as server URL, with latest docker images.

My grafana UI got stucked "Loading metrics", hence not being able to perform any query.

image

Am I missing anything?

cyriltovena

cyriltovena commented on Nov 17, 2019

@cyriltovena
Contributor

No you’re not missing anything. This box doesn’t yet work (soon) but you can still make queries.

lobatt

lobatt commented on Nov 17, 2019

@lobatt

No you’re not missing anything. This box doesn’t yet work (soon) but you can still make queries.

Thanks @cyriltovena .

So for keep an eye on the progress, should I watch releases of Loki or Grafana itself?

cyriltovena

cyriltovena commented on Dec 6, 2019

@cyriltovena
Contributor

Grafana, there is already a version supporting this but not tagged I think

guobei2028

guobei2028 commented on Jan 12, 2021

@guobei2028

https://[my-loki-url]/loki in my 2.0 version seems to have no effect. Has anyone encountered the same situation?
I already use Loki datasource (address is http://loki:3100) and it works.

frankyaorenjie

frankyaorenjie commented on Jan 13, 2021

@frankyaorenjie

Yes, this solution doesn't work in new version. Grafana 7.4.0-pre. I found a video from Grafana officials to introduce Alert on your Loki logs with Grafana in Feb/2020. Can I say this feature is supported but somehow, doesn't work right now?

In 7.4.0-pre, Grafana will request two APIs:

  1. query_range
  2. query_exemplar

The request of query_exemplar will get a 404 return, and cancel then query_range is cancelled.

We also tested 7.0.4 and everything is working fine. There are no query_exemplar when Grafana requests backend data source.

The exemplar is used to correlate metrics and tracing, from TNS Observability Demo of Grafana/Loki/Prometheus/Tempo. And I guess it is a quite new feature and Loki didn't support it yet.

saibug

saibug commented on May 9, 2022

@saibug

Having same issue in production !
My loki version is : 2.4.2
From read instance, this is log output :
read_1 | level=error ts=2022-05-09T12:41:32.850473694Z caller=retry.go:73 org_id=fake msg="error processing request" try=4 err="rpc error: code = Code(500) desc = unsupported response type, got (scalar)" read_1 | level=info ts=2022-05-09T12:41:32.850559168Z caller=metrics.go:92 org_id=fake latency=fast query=1+1 query_type=metric range_type=instant length=0s step=0s duration=0s status=500 limit=100 returned_lines=0 throughput=0B total_bytes=0B

Thank you

KVInventoR

KVInventoR commented on May 12, 2022

@KVInventoR

Hey
same for me, I also got an issue:

loki-linux-amd64 --version
loki, version 2.5.0 (branch: HEAD, revision: 2d9d0ee23)
  build user:       root@4779f4b48f3a
  build date:       2022-04-07T21:50:00Z
  go version:       go1.17.6
  platform:         linux/amd64

grafana 7.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cyriltovena@lobatt@frankyaorenjie@vukor@KVInventoR

        Issue actions

          How to configure Loki as Prometheus datasource? · Issue #1222 · grafana/loki