Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include nextcloud service in trusted domains for metrics exporter #483

Merged
merged 4 commits into from
Jun 9, 2024

Conversation

darkowlzz
Copy link
Contributor

Pull Request

Description of the change

When nextcloud-exporter is used by enabling metrics, it fails to fetch the serverinfo with 400 response code.

nextcloud-exporter log

level=error msg="Error during scrape: unexpected status code: 400"

nextcloud log

10.244.0.38 - admin [24/Nov/2023:22:34:50 +0000] "GET /ocs/v2.php/apps/serverinfo/api/v1/info?format=json HTTP/1.1" 400 11344 "-" "nextcloud-exporter/0.6.1"

This is related to the switch from ingress to local service endpoint for nextcloud-exporter in #388.

To fix this, in addition to .Values.nextcloud.host, the nextcloud service also needs to be included in the trusted domains.
In config/config.php

  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'nextcloud.kube.home',
    2 => 'nextcloud',
  ),

where nextcloud is the service name.

This solution is based on xperimental/nextcloud-exporter#14 , an upstream issue for the same problem.

Benefits

The nextcloud-exporter will be able to fetch and export the metrics properly.

Possible drawbacks

None

Applicable issues

None

Additional information

Without this, the metrics exporter exported metrics about itself only:

# HELP nextcloud_exporter_info Information about the nextcloud-exporter.
# TYPE nextcloud_exporter_info gauge
nextcloud_exporter_info{commit="98d4d4607e9d020dc19b8c21e1401b6b27a5d3a8",version="0.6.1"} 1
# HELP nextcloud_scrape_errors_total Counts the number of scrape errors by this collector.
# TYPE nextcloud_scrape_errors_total counter
nextcloud_scrape_errors_total{cause="other"} 2
# HELP nextcloud_up Indicates if the metrics could be scraped by the exporter.
# TYPE nextcloud_up gauge
nextcloud_up 0

Once the issue is fixed, it exports all the nextcloud app metrics:

# HELP nextcloud_active_users_daily_total Number of active users in the last 24 hours.
# TYPE nextcloud_active_users_daily_total gauge
nextcloud_active_users_daily_total 0
# HELP nextcloud_active_users_hourly_total Number of active users in the last hour.
# TYPE nextcloud_active_users_hourly_total gauge
nextcloud_active_users_hourly_total 0
# HELP nextcloud_active_users_total Number of active users for the last five minutes.
# TYPE nextcloud_active_users_total gauge
nextcloud_active_users_total 0
# HELP nextcloud_apps_installed_total Number of currently installed apps
# TYPE nextcloud_apps_installed_total gauge
nextcloud_apps_installed_total 42
# HELP nextcloud_apps_updates_available_total Number of apps that have available updates
# TYPE nextcloud_apps_updates_available_total gauge
nextcloud_apps_updates_available_total 0
...

Checklist

When nextcloud-exporter is used by enabling metrics, it fails to fetch
the serverinfo with 400 response code. This is related to the switch
from ingress to local service endpoint for nextcloud-exporter.
To fix this, in addition to .Values.nextcloud.host, the nextcloud
service also need to be included in the trusted domains.

Signed-off-by: Sunny <[email protected]>
@jessebot
Copy link
Collaborator

Thanks for submitting this! I've approved the workflow run, but do not have time to test this further, so I will add some other PR reviewers :)

@jessebot jessebot requested a review from tvories November 25, 2023 12:21
@jessebot jessebot added the 3. to review Waiting for reviews label Dec 15, 2023
Copy link
Collaborator

@wrenix wrenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to set the complete domain, since that was merged:
#505

(or we should use a public domain here).

so accept my suggestion it could be merged:

charts/nextcloud/templates/_helpers.tpl Outdated Show resolved Hide resolved
@christensenjairus
Copy link

Here's a quick fix for those (like me) that can't wait for the chart to be fixed. This file's values will override those in config/config.php.

nextcloud:
  configs: # I've taken the standard trusted domains and added one that's necessary for the exporter to work
    trusted-domains.config.php: |-
      <?php 
      $CONFIG = [
        'trusted_domains' =>
        array (
          0 => 'localhost',
          1 => 'nextcloud.example.com',
          2 => 'nextcloud.nextcloud.svc.cluster.local'
        ),
      ];
      ?>

jessebot and others added 2 commits June 9, 2024 09:06
…e and fix spacing for trusted domains

Co-authored-by: WrenIX <[email protected]>
Signed-off-by: JesseBot <[email protected]>
@jessebot jessebot self-requested a review June 9, 2024 07:07
@jessebot jessebot merged commit f8cf007 into nextcloud:main Jun 9, 2024
3 checks passed
SwitzerChees pushed a commit to SwitzerChees/helm that referenced this pull request Jun 27, 2024
…xtcloud#483)

* Include service in trusted domains for metrics

When nextcloud-exporter is used by enabling metrics, it fails to fetch
the serverinfo with 400 response code. This is related to the switch
from ingress to local service endpoint for nextcloud-exporter.
To fix this, in addition to .Values.nextcloud.host, the nextcloud
service also need to be included in the trusted domains.

Signed-off-by: Sunny <[email protected]>

* Update charts/nextcloud/templates/_helpers.tpl - use full service name and fix spacing for trusted domains

Co-authored-by: WrenIX <[email protected]>
Signed-off-by: JesseBot <[email protected]>

---------

Signed-off-by: Sunny <[email protected]>
Signed-off-by: JesseBot <[email protected]>
Co-authored-by: JesseBot <[email protected]>
Co-authored-by: WrenIX <[email protected]>
Signed-off-by: switzerchees <[email protected]>
raynay-r pushed a commit to raynay-r/nextcloud-helm that referenced this pull request Jun 28, 2024
…xtcloud#483)

* Include service in trusted domains for metrics

When nextcloud-exporter is used by enabling metrics, it fails to fetch
the serverinfo with 400 response code. This is related to the switch
from ingress to local service endpoint for nextcloud-exporter.
To fix this, in addition to .Values.nextcloud.host, the nextcloud
service also need to be included in the trusted domains.

Signed-off-by: Sunny <[email protected]>

* Update charts/nextcloud/templates/_helpers.tpl - use full service name and fix spacing for trusted domains

Co-authored-by: WrenIX <[email protected]>
Signed-off-by: JesseBot <[email protected]>

---------

Signed-off-by: Sunny <[email protected]>
Signed-off-by: JesseBot <[email protected]>
Co-authored-by: JesseBot <[email protected]>
Co-authored-by: WrenIX <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants