oijkn / Docker-Raspberry-PI-Monitoring

A docker-compose stack solution for monitoring host and containers with Prometheus, Grafana, cAdvisor and NodeExporter.
MIT License
410 stars 61 forks source link

Access to GUI outside localhost #20

Closed kanintesova closed 1 year ago

kanintesova commented 1 year ago

This is probably more of a docker thing. But it would be nice to get a hint how to connect to the GUI from outside localhost. I run a headless server.

How can I connect to the docker internal IPs? I will try to ssh tunnel socks proxy and use firefox to check if it's possible to connect.

Thanks!

martadinata666 commented 1 year ago

Like usual, nothing special http://Hostip:port

kanintesova commented 1 year ago

I must be missing something. Neither Grafana or Prometheus has been assigned IPs in docker :/

Thanks for the quick reply.

And they are not on the host network.

martadinata666 commented 1 year ago

As i don't know the state of your grafana, by default it will be at hostip:3000, but maybe the grafana or prometheus not starting correctly you should check that'

kanintesova commented 1 year ago

Ok I will need to start it with my user ID. As so:

  grafana:
    container_name: monitoring-grafana
    user: root #or what you got

This solved it!

kanintesova commented 1 year ago

As for Prometheus had to run as user also: Omit where to look for the config file like so:

  prometheus:
    #command:
    # - '--config.file=/etc/prometheus/prometheus.yml'
    # - '--storage.tsdb.path=/prometheus'
    container_name: monitoring-prometheus
    user: root

Then point it at the mapped volume instead and put config file there:

volumes:
      # to be modified depending on your needs
      - /path/to/your/prometheus/data:/prometheus
      - /path/to/your/prometheus/config:/etc/prometheus/

Then no port showing: Published port in portainer afterwards. Now atleast they connect. Nut not sure what to do next. Will tinker on. Damn haha!

oijkn commented 1 year ago

I don't know if I understood everything but for Prometheus to work correctly you have to use the user nobody and for Grafana the user 472.

Of course it is necessary to make a chow -R <id> <directory> of the directories where the data are located.

C8opmBM commented 1 year ago

I don't think the user/permissions are locked down to that specific user. I run both graphana and prometheus with user 1000:1000 without issues Important thing is to create the folders and configs with the same user before starting the container.

As for accessing grafana outside, you can use a reverse proxy on your subdomain. I use caddy v2 with cloudflare plugin, this is my Caddyfile for grafana:

grafana.mydomain.com {
        reverse_proxy monitoring-grafana:3000
        tls {
                dns cloudflare {env.CLOUDFLARE_API_TOKEN}
        }
}
oijkn commented 1 year ago

This issue was closed because it has been open for 30 days with no activity.