xperimental / nextcloud-exporter

Prometheus exporter for Nextcloud servers.
MIT License
226 stars 34 forks source link

token auth, status code 429 #74

Closed mator closed 2 years ago

mator commented 2 years ago

created token with

a=$(openssl rand -hex 32)
php occ config:app:set serverinfo token --value $a

added token to config file and run exporter. Getting the following in the logs of exporter:

nextcloud-exporter-0.5.1-amd64[16735]: level=info msg="nextcloud-exporter 0.5.1"
nextcloud-exporter-0.5.1-amd64[16735]: level=info msg="Nextcloud server: https://x.y.z Authentication using token."
nextcloud-exporter-0.5.1-amd64[16735]: level=info msg="Listen on 10.1.2.3:9205..."
nextcloud-exporter-0.5.1-amd64[16735]: level=error msg="Error during scrape: unexpected status code: 429"

is there any way to debug this error status code? thanks

xperimental commented 2 years ago

Hi. Sorry for the delay.

HTTP status code 429 indicates that the server has been hit with too many requests. Every time the /metrics endpoint of the exporter is queried it will try to get the latest serverinfo from Nextcloud. If this happens too often, then the Nextcloud server will react by responding with status code 429.

The solution is to limit the requests to the exporter, so that the Nextcloud server is not queried too often. Looking at the Nextcloud code it seems like the limit is reset after 30 minutes.

xperimental commented 2 years ago

This question seems to be answered. Closing.