当在Grafana里添加loki数据源时页面报如下错误:
Loki: Bad Gateway. 502. Bad Gateway
|
无论DataSource Url使用http://loki:3100
还是http://127.0.0.1:3100
均是这个错误。
[root@k8s-master ~]# kubectl get svc -n loki NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/loki-grafana NodePort 10.1.119.114 <none> 80:32472/TCP 29h service/loki-loki-distributed-distributor ClusterIP 10.1.7.112 <none> 3100/TCP,9095/TCP 29h service/loki-loki-distributed-gateway ClusterIP 10.1.68.155 <none> 80/TCP 29h service/loki-loki-distributed-ingester ClusterIP 10.1.3.43 <none> 3100/TCP,9095/TCP 29h service/loki-loki-distributed-ingester-headless ClusterIP None <none> 3100/TCP,9095/TCP 29h service/loki-loki-distributed-memberlist ClusterIP None <none> 7946/TCP 29h service/loki-loki-distributed-querier ClusterIP 10.1.173.220 <none> 3100/TCP,9095/TCP 29h service/loki-loki-distributed-querier-headless ClusterIP None <none> 3100/TCP,9095/TCP 29h service/loki-loki-distributed-query-frontend ClusterIP None <none> 3100/TCP,9095/TCP,9096/TCP 29h
|
进入到loki-loki-distributed-query-frontend这个容器内部,执行cat /etc/loki/config/config.yaml
命令,会发现如下:
frontend: compress_responses: true log_queries_longer_than: 5s tail_proxy_url: http://loki-loki-distributed-querier:3100 frontend_worker: frontend_address: loki-loki-distributed-query-frontend:9095
|
看到这里,是不是明白了,实际的DataSource Url应当是“http://loki-loki-distributed-querier:3100”,在页面上填入后保存并测试
Data source connected and labels found.
|
大功告成~