An open API service indexing awesome lists of open source software.

https://github.com/llaumgui/nextcloud2prom

Convert a Nextcloud monitoring in JSON to prom textfile
https://github.com/llaumgui/nextcloud2prom

nextcloud prometheus-metrics python python3 systemd systemd-service systemd-timer

Last synced: 28 days ago
JSON representation

Convert a Nextcloud monitoring in JSON to prom textfile

Awesome Lists containing this project

README

          

# Nextcloud to prom

> [!WARNING]
> Metrics is now a Nextcloud (>=33) feature. Please [use standard endpoint](https://docs.nextcloud.com/server/latest/admin_manual/configuration_monitoring/index.html).

[![Author][ico-bluesky]][link-bluesky]
[![Software License][ico-license]](LICENSE)

Get Nextcloud server's info in JSON and convert to [node_exporter textfile format](https://github.com/prometheus/node_exporter?tab=readme-ov-file#textfile-collector).

![image](https://github.com/user-attachments/assets/ad11f6a0-9924-4cb8-9481-4a24d06fe803)

## Install

### On Nextcloud

* Make sur that application server info is enable:

```bash
https://domain.ltd/settings/admin/serverinfo
```

* Set a token:

```bash
occ config:app:set serverinfo token --value MY_TOKEN
```

### On your server

* Create folder /var/lib/prometheus/node-exporter

```bash
mkdir /var/lib/prometheus/node-exporter
chown prometheus:prometheus /var/lib/prometheus/node-exporter
```

* Allow collect textfiles from it:

```bash
cat /etc/default/node_exporter
NODE_EXPORTER_OPTS="--collector.textfile.directory=/var/lib/prometheus/node-exporter"
```

* Get scripts:

```bash
cd /tmp
git clone https://github.com/llaumgui/nextcloud2prom.git
cd nextcloud2prom
```

* Install requirements from `dnf`, `apt`, etc. Or use `pip`:

```bash
pip install -r requirements.txt
```

* Install scripts:

```bash
cp prom_nextcloud.py /usr/local/bin
chmod +x /usr/local/bin/prom_nextcloud.py
cp system.d/prom* /etc/systemd/system
```

* Edit /etc/systemd/system/prom-nextcloud.service with your `NC_URL` and `NC_TOKEN` informations.
* Check:

```bash
systemd-analyze verify /etc/systemd/system/prom-nextcloud*
systemctl start prom-nextcloud.service
```

* and start systemd:

```bash
systemctl start prom-nextcloud.timer
systemctl enable prom-nextcloud.timer
```

## Develop

```bash
python -m venv env
source env/bin/activate
pip install -r requirements.txt
```

[ico-bluesky]: https://img.shields.io/static/v1?label=Author&message=llaumgui&color=208bfe&logo=bluesky&style=flat-square
[link-bluesky]: https://bsky.app/profile/llaumgui.kulakowski.fr
[ico-version]: https://img.shields.io/docker/v/llaumgui/httpd?sort=semver&color=%2496ed&logo=docker&style=flat-square
[ico-license]: https://img.shields.io/github/license/llaumgui/nextcloud2prom?style=flat-square