Can't make it work
chapa opened this issue · 5 comments
Hi,
I don't understand why, but I can't make this exporter working.
Here is the docker-compose.yaml file I use to setup a nextcloud and this exporter :
version: '2'
services:
app:
image: nextcloud:18.0.3-apache
volumes:
- ./volumes/nextcloud:/var/www/html
ports:
- "8000:80"
prometheus-exporter:
image: xperimental/nextcloud-exporter:v0.1.0
environment:
- NEXTCLOUD_SERVERINFO_URL=http://app
- NEXTCLOUD_USERNAME=nextcloud
- NEXTCLOUD_PASSWORD=nextcloud
ports:
- "9205:9205"Just after the first docker-compose up -d, go to http://localhost:8000 and create a user nextcloud with the password nextcloud.
See that http://localhost:8000/ocs/v2.php/apps/serverinfo/api/v1/info is working correctly.
But http://localhost:9205/metrics doesn't write nextcloud values because it can't get data from nextcloud.
Here is the result of docker-compose logs :
app_1 | 172.20.0.2 - nextcloud [29/Apr/2020:09:15:53 +0000] "GET /ocs/v2.php/apps/serverinfo/api/v1/info HTTP/1.1" 400 5488 "-" "Go-http-client/1.1"
prometheus-exporter_1 | 2020/04/29 09:15:53 Error during scrape: unexpected status code: 400
Is there something I'm missing ?
Hi @chapa,
Thanks for your report! Unfortunately I'm currently a bit busy on non-coding work, but I'm sure I'll be able to give your configuration a test in the coming week (might be tomorrow, might be next weekend) and see if I can help you.
No problem take your time, I'm not in a hurry. Thanks!
Sorry for the wait, I had time to investigate now.
The issue is with the "trusted domains" configuration of Nextcloud. The default configuration only allows "localhost:8000" as domain, as this is the one that was configured during startup. The exporter will try to access the Nextcloud instance using the hostname "app" though, which Nextcloud will then deny.
You can make the above configuration work if you change the config/config.php in Nextcloud. There should be the following configuration present:
'trusted_domains' =>
array (
0 => 'localhost:8000',
),If you add another entry for "app" then the exporter will work properly:
'trusted_domains' =>
array (
0 => 'localhost:8000',
1 => 'app',
),Does this work for you, @chapa ?
Ah yes, good point!
I hadn't thought of that, thanks, it works perfectly now 👍
Hi
?php
$CONFIG = array (
'instanceid' => 'ocmhmtdgxivf',
'passwordsalt' => 'bfn7dpKUgIeP9TLi7bcIBzPgAK1qFu',
'secret' => 'G0yoMGZtVDw+j9pz5SfYU+BTNMQdM77teGmZ0PEq12cA2T5K',
'trusted_domains' =>
array (
0 => 'localhost:8080',
1=> 'app',
),
'datadirectory' => '/var/www/html/nextcloud/data',
'dbtype' => 'mysql',
'version' => '25.0.1.1',
'overwrite.cli.url' => 'http://localhost/nextcloud',
'dbname' => 'nextcloud',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
);
this is my cofiguration file & when i am checking logs then show this error
vivek@vivekkumar:~$ podman logs nextcloud_exporter
level=info msg="nextcloud-exporter 0.7.0"
level=info msg="Nextcloud server: http://localhost:8080 User: vivekraj2002"
level=info msg="Listen on :9205..."
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
level=error msg="Error during scrape: Get "http://localhost:8080/ocs/v2.php/apps/serverinfo/api/v1/info?format=json&skipApps=true\": dial tcp 127.0.0.1:8080: connect: connection refused"
what is the error can you define