Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure Loki as Prometheus datasource? #1222

Closed
vukor opened this issue Nov 1, 2019 · 12 comments
Closed

How to configure Loki as Prometheus datasource? #1222

vukor opened this issue Nov 1, 2019 · 12 comments

Comments

@vukor
Copy link

vukor commented Nov 1, 2019

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.

@vukor
Copy link
Author

vukor commented Nov 1, 2019

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
Copy link
Contributor

negbie commented Nov 1, 2019

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
Copy link
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
Copy link
Author

vukor commented Nov 1, 2019

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

@vukor vukor closed this as completed Nov 1, 2019
@lobatt
Copy link

lobatt commented Nov 16, 2019

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
Copy link
Contributor

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

@lobatt
Copy link

lobatt commented Nov 17, 2019

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
Copy link
Contributor

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

@guobei2028
Copy link

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
Copy link

frankyaorenjie commented Jan 13, 2021

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
Copy link

saibug commented May 9, 2022

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
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants