Nextcloud prometheus integration via service monitor

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Hi, I’m facing some problems with metrics integration in prometheus

nextcloud intallation:

helm install nextcloud nextcloud/nextcloud --namespace nextcloud --values .\nextcloud-values.yaml --version 9.0.6

For the metrics usage I modified the yaml file as shown below:

metrics:
  enabled: true

  replicaCount: 1
  # Optional: becomes NEXTCLOUD_SERVER env var in the nextcloud-exporter container.
  # Without it, we will use the full name of the nextcloud service
  server: ""
  # The metrics exporter needs to know how you serve Nextcloud either http or https
  https: false
  # Use API token if set, otherwise fall back to password authentication
  # https://github.com/xperimental/nextcloud-exporter#token-authentication
  # Currently you still need to set the token manually in your nextcloud install
  token: ""
  timeout: 5s
  # if set to true, exporter skips certificate verification of Nextcloud server.
  tlsSkipVerify: false
  info:
    # Optional: becomes NEXTCLOUD_INFO_APPS env var in the nextcloud-exporter container.
    # Enables gathering of apps-related metrics. Defaults to false
    apps: false

  # image:
  #   repository: xperimental/nextcloud-exporter
  #   tag: 0.8.0
  #   pullPolicy: IfNotPresent
  #   # pullSecrets:
  #   #   - myRegistrKeySecretName

  ## Metrics exporter resource requests and limits
  ## ref: http://kubernetes.io/docs/user-guide/compute-resources/
  ##
  resources: {}

  # -- Metrics exporter pod Annotation
  podAnnotations: {}

  # -- Metrics exporter pod Labels
  podLabels: {}

  # -- Metrics exporter pod nodeSelector
  nodeSelector: {}

  # -- Metrics exporter pod tolerations
  tolerations: []

  # -- Metrics exporter pod affinity
  affinity: {}

  service:
    type: ClusterIP
    # Use serviceLoadBalancerIP to request a specific static IP,
    # otherwise leave blank
    loadBalancerIP:
    annotations:
      prometheus.io/scrape: "true"
      prometheus.io/port: "9205"
    labels: {}

  # -- security context for the metrics CONTAINER in the pod
  securityContext:
    runAsUser: 1000
    runAsNonRoot: true
    # allowPrivilegeEscalation: false
    # capabilities:
    #   drop:
    #     - ALL

  # -- security context for the metrics POD
  podSecurityContext: {}
  # runAsNonRoot: true
  # seccompProfile:
  #   type: RuntimeDefault

  ## Prometheus Operator ServiceMonitor configuration
  ##
prometheus:
  serviceMonitor:
    ## @param metrics.serviceMonitor.enabled Create ServiceMonitor Resource for scraping metrics using PrometheusOperator
    ##
    enabled: true

    ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running
    ##
    namespace: "monitoring"

    ## @param metrics.serviceMonitor.namespaceSelector The selector of the namespace where the target service is located (defaults to the release namespace)
    namespaceSelector:
      matchNames:
        - nextcloud

    ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.
    ##
    jobLabel: "nextcloud"

    ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped
    ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint
    ##
    interval: 30s

    ## @param metrics.serviceMonitor.scrapeTimeout Specify the timeout after which the scrape is ended
    ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint
    ##
    scrapeTimeout: 10s

    ## @param metrics.serviceMonitor.labels Extra labels for the ServiceMonitor
    ##
    labels:
      release: prometheus-stack

  rules:
    # @section -- Metrics
    enabled: true
    # -- Label on Prometheus Rules CRD Manifest
    # @section -- Metrics
    labels:
      prometheus: default
    defaults:
      # -- Add Default Rules
      # @section -- Metrics
      enabled: true
      # -- Label on the rules (the severity is already set)
      # @section -- Metrics
      labels:
        test: demo
      # -- Filter on metrics on alerts (default just for this helm-chart)
      # @section -- Metrics
      filter: ""
    # -- Add own Rules to Prometheus Rules
    # @section -- Metrics
    additionalRules: []

As result I got a service monitor in the namespace monitoring with the following content:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  annotations:
    meta.helm.sh/release-name: nextcloud
    meta.helm.sh/release-namespace: nextcloud
  creationTimestamp: "2026-09-23T14:34:07Z"
  generation: 4
  labels:
    app.kubernetes.io/instance: nextcloud
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: nextcloud
    app.kubernetes.io/version: 33.0.3
    helm.sh/chart: nextcloud-9.0.6
    release: prometheus-stack
  name: nextcloud
  namespace: monitoring
  resourceVersion: "295889"
  uid: 0361287d-98f9-4926-ba5b-c2e6f81b0f21
spec:
  endpoints:
  - interval: 30s
    path: /metrics
    port: http
    scrapeTimeout: 10s
  jobLabel: nextcloud
  namespaceSelector:
    matchNames:
    - nextcloud
  selector:
    matchLabels:
      app.kubernetes.io/instance: nextcloud
      app.kubernetes.io/monitor: enabled
      app.kubernetes.io/name: nextcloud

But I can’t see this monitor in the prometheus targets.

What do I miss ?

Many thanks in advace

Problem resolved: :grinning_face:

prometheus:
  serviceMonitor:
    ## @param metrics.serviceMonitor.enabled Create ServiceMonitor Resource for scraping metrics using PrometheusOperator
    ##
    enabled: true

    ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running
    ##
    namespace: "monitoring"

    ## @param metrics.serviceMonitor.namespaceSelector The selector of the namespace where the target service is located (defaults to the release namespace)
    namespaceSelector:
      # matchNames:
      #   - nextcloud

    ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.
    ##
    ### jobLabel: "nextcloud"

    ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped
    ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint
    ##
    ### interval: 30s

    ## @param metrics.serviceMonitor.scrapeTimeout Specify the timeout after which the scrape is ended
    ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint
    ##
    ### scrapeTimeout: 10s

    ## @param metrics.serviceMonitor.labels Extra labels for the ServiceMonitor
    ##
    labels:
      release: prometheus

rules:
 enabled: false