• 0 Posts
  • 4 Comments
Joined 1 year ago
cake
Cake day: July 1st, 2023

help-circle
  • Oh and one last thing (i promise) is that if you are using or will use ARM for loki, you have to build the docker driver for loki from source.

    A quick tutorial is here for anyone that needs it: Install go with sudo apt install go Then clone the github repo with git clone https://github.com/grafana/loki.git Then cd into it with cd loki Once you’re inside the directory, do GOOS=linux/windows/whatever GOARCH=arm-version(eg. armv7,arm64) go build ./clients/cmd/docker-driver and wait for it to finish. The resulting file should (if i remember correclty) be called either loki or docker-driver. It’s reccomended to do this on another machine then import it into your arm machine.


  • Sorry for the late reply. I followed a great tutorial on youtube by Techno Tim, it explains everything pretty well. It’s a bit long, but thorough.

    I used this docker-compose file as a base because it connects loki automatically, but you have to add the volumes manually and its not too hard to connect it manually. You can just use the one that Techno Tim uses in the video if you want less complexity in your compose files.

    My docker compose file for reference:

    version: "3"
    services:
      loki:
        container_name: 'loki'
        image: grafana/loki:2.8.0
        ports:
          - "20110:3100"
        command: -config.file=/etc/loki/loki-config.yaml
        volumes: 
          - ./loki:/etc/loki
        networks:
          - loki
    
      promtail:
        image: grafana/promtail:2.8.0
        volumes:
          - /var/log:/var/log
          - ./promtail:/etc/promtail
        command: -config.file=/etc/promtail/promtail-config.yaml
        networks:
          - loki
    
      grafana:
        container_name: 'grafana'
        image: grafana/grafana-oss:latest
        environment:
          GF_PATHS_PROVISIONING: /etc/grafana/provisioning
    
          GF_AUTH_ANONYMOUS_ENABLED: false
    #      GF_LOG_MODE: "console file" #optional, used if you want a log file
     #     GF_SERVER_ROOT_URL: "(Full url here eg. https://grafana.example.com") #optional, used for redirects
        entrypoint:
          - sh
          - -euc
          - |
            mkdir -p /etc/grafana/provisioning/datasources
            cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml
            apiVersion: 1
            datasources:
            - name: Loki
              type: loki
              access: proxy 
              orgId: 1
              url: http://loki:3100
              basicAuth: false
              isDefault: true
              version: 1
              editable: false
            EOF
            /run.sh
        volumes:
          - ./grafana/data:/var/lib/grafana
    #      - ./grafana/logs:/var/log/grafana #log file
        ports:
          - "20100:3000"
        networks:
          - loki
    
    networks:
      loki:
        name: loki
      frontend:
        external: true
    

    Sorry if the formatting looks bad, since I’m on mobile. I use frontend as a network that includes containers that connect to nginx proxy manager.

    If you have ARM then you might have problems, more info in the comment below

    Edit: Better wording Edit2:typo, edited refrence for clarity and added arm warning


  • You don’t have a logging stack? You should set one up, it helps greatly to see your servers long term snd short term status at a glance, especially if you hook it up with grafana to visualize. You can even use grafana with Home Assistant, and do some pretty crazy things with notifications, but i must say, it is a rabbit hole, especially grafana, and quite a large one at that.

    I’m currently using grafana with loki and looking to set up notifications with ntfy but if you have the resources you could set up some other logging stacks like elk, or greylog but they’re a bit resource hungry and you dont seem to have too many services set up to warrant a larger stack.

    Anyway you have a really nice setup, good job!

    Edit: typo