"No logs found" in grafana

3.6k Views Asked by At

I installed Loki, grafana and promtail and all three runing. on http://localhost:9080/targets Ready is True, but the logs are not displayed in Grafana and show in the explore section "No logs found"

promtail-local-config-yaml:

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://localhost:3100/loki/api/v1/push

scrape_configs:
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      host: ward_workstation
      agent: promtail
      __path__: D:/LOGs/*log

loki-local-config.yaml:

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096

common:
  path_prefix: /tmp/loki
  storage:
    filesystem:
      chunks_directory: /tmp/loki/chunks
      rules_directory: /tmp/loki/rules
  replication_factor: 1
  ring:
    instance_addr: 127.0.0.1
    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

How can i solve this problem?

2

There are 2 best solutions below

0
On

Perhaps you are using Loki in Windows ?

In your promtail varlogs job ,the Path "D:/LOGs/*log" is obviously wrong, you cannot access the windows file from your docker directly.

You shoud mount your windows file to your docker like this:

  promtail:
    image: grafana/promtail:2.5.0
    volumes:
      - D:/LOGs:/var/log
    command: -config.file=/etc/promtail/config.yml
    networks:
      - loki

Then everything will be ok.

Note that, in your promtail docker the config is like this: enter image description here

you can adjust both to make a match...

0
On

Here's a general advice how to debug Loki according to the question's title:

(1) Check promtail logs If you discover such as error sending batch you need to fix your Promtail configuration.

level=warn ts=2022-10-12T16:26:20.667560426Z caller=client.go:369 component=client host=monitor:3100 msg="error sending batch, will retry" status=-1 error="Post \"http://loki:3100/loki/api/v1/push\": dial tcp: lookup *Loki* on 10.96.0.10:53: no such host"

(2) Open the Promtail config page and check, if Promtail has read your given configuration: http://localhost:3101/config

(3) Open the Promtail targets page http://localhost:3101/targets and check

  1. if your service is listed as Ready
  2. if the log file contains the wanted contents and is readable by Promtail. If you're using docker or kubernetes I would log into the Promtail Container and would try to read the logfile manually.

To the specific problem of the questioner:

The questioner said, that the services are shown as READY in the targets page. So I recommend to check (1) Promtail configuration and (3b) access to log files (as Frank).