Using a standalone Grafana for ncp metrics

Hey together,
i think the ncp metrics app is awesome.

I already use a grafana instance on a different vm.
It is used with InfluxDB for proxmox.
So it would be awesome to use the standalone instance as well for ncp metrics.

If we would could get a how to and help us together I would appreciate it.

  • How to connect
  • Prometheus (or can I use the InfluxDB?)
  • Dashboard ID
  • ā€¦

At the kind of my questions I probably donā€™t have to mention, that Iā€™m very motivated but not very skilled ;).

Hi,
in order to consume the metrics generated by NCP in your grafana instance, you will need a prometheus server and add it as data source in grafana. The easiest way to get one up and running is in my opinion the official docker image (prom/prometheus).

You need to mount a directory into the container where your configuration will live.
Letā€™s say you have your configuration in /opt/prometheus on the host. Then you could start the container with docker run -p localhost:9090:9090 -v /opt/prometheus:/etc/prometheus prom/prometheus. Prometheus will now be listening locally on port 9090.
Now you need to add this prometheus server as data source in Grafana. For this, have a look at the official documentation (1, 2).
Finally, you need to configure prometheus. You can use this config as reference. Just replace the variables with the actual values (i.e. ${NEXTCLOUD_HOST} with your nextcloud address, ${NCP_METRICS_USERNAME} and ${NCP_METRICS_PASSWORD} with the credentials from the ncp metrics app).

In this config, there is one job that needs an extra prometheus collector (not part of ncp), which is responsible for the nextcloud specific metrics. You can run it as docker container as well. Thatā€™s xperimental/nextcloud-exporter (Setup instructions at the link).


Now that Iā€™ve explained the manual setup process, let me give you a faster way :smiley: (Iā€™ve actually just considered it after writing all of the above).

You can still use the ncp-monitoring-dashboard project just fine. Simply follow itā€™s setup instructions, but before running ./start.sh, do some modifications to the docker-compose.yml:

  • comment or delete all services except prometheus and ncp-nextcloud-exporter
  • uncomment the ā€˜portsā€™ section of the prometheus service.

That should give you everything you need. Now just add localhost:9090 as prometheus data source to Grafana.

Your final docker-compose.yml should look like this:

version: '3.5'

services:
#  nginx:
#    image: nginx:latest
#    ports:
      # Replace 8443 and 8080 with your desired ports here
#      - 8443:443
#      - 8080:80
#    volumes:
#      - type: bind
#        source: ./config/nginx/nginx.conf
#        target: /etc/nginx/nginx.conf
#        read_only: true
#      - type: bind
#        source: ./config/nginx/monitoring-dashboard.conf
#        target: /etc/nginx/monitoring-dashboard.conf
#        read_only: true
#      - type: bind
#        source: ./config/nginx/cert
#        target: /etc/nginx/cert
#    networks:
#      - ncp-monitoring
  prometheus:
    image: prom/prometheus
    volumes:
      - prometheus:/data
      - type: bind
        source: ./config/prometheus
        target: /etc/prometheus
        read_only: true
    networks:
      - ncp-monitoring
    depends_on:
      - ncp-nextcloud-exporter
    # Uncomment to expose prometheus directly
    ports:
      - "localhost:9090:9090"
  ncp-nextcloud-exporter:
    image: xperimental/nextcloud-exporter
    env_file:
      - .env
    environment:
      - NEXTCLOUD_LISTEN_ADDRESS=:9025
      - NEXTCLOUD_TIMEOUT=5s
    networks:
      - ncp-monitoring
#  grafana:
#    image: grafana/grafana:latest
#    hostname: grafana
#    volumes:
#      - grafana:/var/lib/grafana
#      - type: bind
#        source: ./config/grafana
#        target: /etc/grafana
    # Uncomment to expose grafana directly
    # ports:
    #   - localhost:3000:3000
#    networks:
#      - ncp-monitoring



networks:
   ncp-monitoring:
      name: ncp-monitoring

volumes:
  prometheus:
#  grafana:

Oh and for the dashboard: You could import it from this json file. It might need a few adjustments for your specific ncp instance, but should be a good starting point

Thank you very much. WIll try it tomorrow

Hey @theCalcaholic,
-where do I find the prometheus config file?
As far as I can see it is not at /etc/prometheus.-
Edit: Found the file. Its the .yml file in /etc/prometheus.

Next question is: Where do I need the ngnix webserver for?

Thanks!

I recommend to follow the setup instructions at GitHub - theCalcaholic/ncp-monitoring-dashboard: A Grafana dashboard for nextcloudpi and do the mentioned adjustments .

Then you should have everything you need to wire up the prometheus container with your grafana instance.

If you do that, you already have the prometheus config in the right place and you donā€™t need the nginx server

Hm, please let me know if the import works for you. Afaik, it contains the prometheus data source, but it will probably be misconfigured for your setup.

If so, you can probably fix it by replacing prometheus:9090 with localhost:9090 throughout the file.

If i use the docker compose stack in portainer
i get this feedback:
Deplyment error

failed to deploy a stack: Creating volume ā€œncpmonitoring_prometheusā€ with default driver Creating ncpmonitoring_ncp-nextcloud-exporter_1 ā€¦ e[1Ae[2K Creating ncpmonitoring_ncp-nextcloud-exporter_1 ā€¦ e[32mdonee[0m e[1BCreating ncpmonitoring_prometheus_1 ā€¦ e[1Ae[2K Creating ncpmonitoring_prometheus_1 ā€¦ e[31merrore[0m e[1B ERROR: for ncpmonitoring_prometheus_1 Cannot create container for service prometheus: invalid mount config for type ā€œbindā€: bind source path does not exist: /data/compose/17/config/prometheus ERROR: for prometheus Cannot create container for service prometheus: invalid mount config for type ā€œbindā€: bind source path does not exist: /data/compose/17/config/prometheus Encountered errors while bringing up the project. : exit status 1

The second way I tried was to install everything manually. Got the prometheus container up and running. The connection between prometheus and grafana was easy.
Didnā€™t get the nextcloud exporter running yet :frowning: .
I try further.

You need to execute the start script from within the directory where you cloned (or downloaded) the ncp monitoring dashboard repository. Otherwise it wonā€™t find the required config files.

Try:

wget -O ncp-dashboard.zip https://github.com/theCalcaholic/ncp-monitoring-dashboard/archive/refs/heads/main.zip
unzip ncp-dashboard.zip
cd ncp-monitoring-dashboard-main
# Follow the instructions in https://github.com/theCalcaholic/ncp-monitoring-dashboard#readme until:
sudo ./start.sh
1 Like

2 posts were split to a new topic: How do I install Grafana without docker? Is there a guide?

It would be nice when metrics want start. It didnā€™t start anymore. I have to try my server address, my ip an Nextcloud.local:8443 I think so. Nothing.

The .env file I have configurated.

I doesnā€™t have a Idea. When I use one of these Adresses, my browser switch to the nc login page.