Error while adding the loki datasource in grafana

Hi,
I am trying to add the loki datasource in grafana and I am getting the following error :-


Loki: Internal Server Error. 500. rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 127.0.0.1:9095: connect: permission denied"

The following is my loki config file :-

auth_enabled: false

server:
  http_listen_port: 3100
#  grpc_listen_port: 0
ingester:
  lifecycler:
    address: 127.0.0.1
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 5m
  chunk_retain_period: 30s
  max_transfer_retries: 0

schema_config:
  configs:
    - from: 2018-04-15
      store: boltdb
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 168h

storage_config:
  boltdb:
    directory: /data/loki/index

  filesystem:
    directory: /data/loki/chunks

limits_config:
  enforce_metric_name: false
  reject_old_samples: true
  reject_old_samples_max_age: 168h

chunk_store_config:
  max_look_back_period: 0s

table_manager:
  retention_deletes_enabled: false
  retention_period: 0s

The port is open.

[root@syslog loki]# netstat -nlp | grep loki
tcp        0      0 127.0.0.1:9095          0.0.0.0:*               LISTEN      2577498/loki-linux-
tcp6       0      0 :::3100                 :::*                    LISTEN      2577498/loki-linux-

I have been stuck here for sometime now. Any help is appreciated. Thanks in advance.

Hi,

Your grafana server and Loki are on the same server ?

Can you display you grafana datasource configuration ?

Do you use right port ?

It’s maybe iptables or firewalld restriction.
Use iptables -L (see if rules block your request) and systemctl stop firewalld
commands.

Regards

Yes they’re both in the same VM.

I think so. I am using port 3100 and it is open. So is 9095.

This is what I get

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

I don’t think I’ll be allowed to stop firewalld completely.
I have already done :-

sudo firewall-cmd --zone=public --permanent --add-port=9095/tcp
sudo firewall-cmd --zone=public --permanent --add-port=3100/tcp
sudo firewall-cmd --reload

Thanks.

The problem got solved using this loki config file :-

auth_enabled: false

server:
  http_listen_port: 3100

ingester:
  lifecycler:
    address: 127.0.0.1
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 5m
  chunk_retain_period: 30s

schema_config:
  configs:
  - from: 2020-05-15
    store: boltdb
    object_store: filesystem
    schema: v11
    index:
      prefix: index_
      period: 168h

storage_config:
  boltdb:
    directory: /tmp/loki/index

  filesystem:
    directory: /tmp/loki/chunks

limits_config:
  enforce_metric_name: false
  reject_old_samples: true
  reject_old_samples_max_age: 168h