我正在尝试安装 loki,以便我可以在 Grafana 上读取日志,但我一直收到Data source connected, but no labels received. Verify that Loki and Promtail is configured properly.
(日志中没有任何内容)。
我在 Raspberry Pi 4 8Gb 上为每个服务(grafana、loki、promtail)使用 docker 镜像。
每项服务都正常工作。我可以连接到 Grafana ( localhost:3000
) 并查看 node_exporter 数据。我可以连接到 loki 本身并查看指标 ( localhost:3100/metrics
),我也可以连接到 promtail ( localhost:9080/targets
)。
在 Grafana 上,我尝试将 loki 指向10.88.0.1:3100/metrics
(因为 Grafana 是一个 docker 容器,我必须使用它10.88.0.1
来连接到主机)但是我收到了一个新错误Unable to fetch labels from Loki (Failed to call resource), please check the server logs for more details
这是我从该错误的日志中得到的:
logger=context userId=1 orgId=1 uname=admin t=2023-02-12T13:21:35.204508553Z level=error msg="Failed to call resource" error="404 page not found\n" traceID=
logger=context userId=1 orgId=1 uname=admin t=2023-02-12T13:21:35.204758623Z level=error msg="Request Completed" method=GET path=/api/datasources/2/resources/labels status=500 remote_addr=192.168.1.20 time_ms=7 duration=7.563973ms size=51 referer=http://raspberry.local:3000/datasources/edit/sgEZvn14k handler=/api/datasources/:id/resources/*
这很奇怪,因为没有/metrics
Grafana 确实会找到 loki。
我正在使用 ansible 来配置我的锉刀:
- name: Grafana - Run container using podman
containers.podman.podman_container:
name: grafana
image: grafana/grafana-oss:latest
state: started
recreate: true
restart_policy: on-failure
ports: "3000:3000"
memory: "2048m"
net:
- host
volume:
- "grafana-storage:/var/lib/grafana"
- name: Loki - Run container using podman
containers.podman.podman_container:
name: loki
image: grafana/loki:latest
state: started
recreate: true
restart_policy: on-failure
ports: "3100:3100"
memory: "2048m"
net:
- host
volume:
- "loki-storage:/loki"
- name: Promtail - Run container using podman
containers.podman.podman_container:
name: promtail
image: grafana/promtail:latest
state: started
recreate: true
restart_policy: on-failure
ports:
- "9080:9080"
- "1514:1514"
memory: "2048m"
net:
- host
volume:
- "{{ lokiData }}/promtail.yml:/etc/promtail/promtail-config.yml"
command: -config.file=/etc/promtail/promtail-config.yml
我的 promtail 配置:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://10.88.0.1:3100/loki/api/v1/push
scrape_configs:
- job_name: syslog
syslog:
listen_address: 0.0.0.0:1514
labels:
job: "syslog"
relabel_configs:
- source_labels: ['__syslog_message_hostname']
target_label: 'host'
我的洛基配置:
auth_enabled: false
server:
http_listen_port: 3100
common:
path_prefix: /loki
storage:
filesystem:
chunks_directory: /loki/chunks
rules_directory: /loki/rules
replication_factor: 1
ring:
kvstore:
store: inmemory
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
ruler:
alertmanager_url: http://localhost:9093
我真的不知道现在该怎么办,我是 Grafana 的新手,所以也许我错过了什么。我用谷歌搜索了这个错误,但没有发现任何有趣的东西(主要是配置错误)。