Docker Loki PLugin


Recommended Posts

Hi all, 

 

has anyone tried to add the loki docker plugin?  https://grafana.com/docs/loki/latest/clients/docker-driver/configuration/

 

I have installed it using

 

Quote

docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions

 

i can see the plugin listed 

 

Quote

root@Tower:/mnt/user/appdata/loki# docker plugin ls
ID             NAME          DESCRIPTION           ENABLED
d18f5eaea7c6   loki:latest   Loki Logging Driver   true

 

 

per the instructions, i need to edit file: /etc/docker/daemon.json 

 

nano /etc/docker/daemon.json

My file currently contains the following: 

Quote

{
    "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}


 

I've tried to merge the config then disable and enable docker, however, i just get errors

 

Merged: 

Quote

{
    "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    },
    "debug" : true,
    "log-driver": "loki",
    "log-opts": {
        "loki-url": "http://host.docker.internal:3100/loki/api/v1/push"
    }
}

 

 

Error:

 

Quote

Warning: stream_socket_client(): unable to connect to unix:///var/run/docker.sock (No such file or directory) in /usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php on line 693
Couldn't create socket: [2] No such file or directory
Warning: Invalid argument supplied for foreach() in /usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php on line 877

 

 

Im guessing my json is badly formed and i've merged the changes incorreclty 

 

cheers!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
  • 4 weeks later...
  • 2 months later...

I've been fumbling around at this for a while and I will say to make sure when trying to set this up you do not have "Docker LOG rotation" enabled in the Unraid Docker settings.

The issue is that when you add this config docker has `log-opts` passed in as both flags (at runtime by the docker service `/etc/rc.d/rc.docker`) and in the file you've updated.

 

The error you are showing is that the docker daemon failed to start and as a result the UI wont work.

Link to comment
  • 1 year later...
On 3/18/2022 at 9:05 AM, absent said:

I've been fumbling around at this for a while and I will say to make sure when trying to set this up you do not have "Docker LOG rotation" enabled in the Unraid Docker settings.

The issue is that when you add this config docker has `log-opts` passed in as both flags (at runtime by the docker service `/etc/rc.d/rc.docker`) and in the file you've updated.

 

The error you are showing is that the docker daemon failed to start and as a result the UI wont work.

Wow thanks man. I was banging my head into the wall for this. I've got a script setup on array start now:
 

#!/bin/bash

DAEMON_CONFIG="/etc/docker/daemon.json"
NEW_CONFIG='{ "log-driver": "loki", "log-opts": { "loki-url": "http://localhost:3100/loki/api/v1/push", "loki-batch-size": "400" } }'

update_config() {
    jq --argjson newConfig "$NEW_CONFIG" '. += $newConfig' "$DAEMON_CONFIG" > tmp.$$ && mv tmp.$$ "$DAEMON_CONFIG"
}

if [ -f "$DAEMON_CONFIG" ]; then
    update_config
else
    echo "$NEW_CONFIG" > "$DAEMON_CONFIG"
fi

/etc/rc.d/rc.docker stop
while pgrep -x docker > /dev/null; do sleep 1; done
/etc/rc.d/rc.docker start

Let's see how it will work over time.
At least docker is starting again :).

Next issue, is that all containers need to be recreated, for them to actually run their logs through loki. Maybe if I make sure loki gets created first. It will work properly.

Edited by Kees Fluitman
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.