sonarqube-exporter
by tina.junold
Exports the measures of every SonarQube project as Prometheus gauges, with the ideaplexus/sonarqube-exporter image. One instance per SonarQube, scraped through annotations or a ServiceMonitor.
About this chart
sonarqube-exporter
Exports the measures of every SonarQube project as Prometheus gauges, with the ideaplexus/sonarqube-exporter image. One instance per SonarQube, scraped through annotations or a ServiceMonitor.
Homepage: https://gitlab.com/ideaplexus/charts
Maintainers
| Name | Url | |
|---|---|---|
| Tina Junold | [email protected] | https://ideaplexus.com |
Source Code
- https://gitlab.com/ideaplexus/charts/-/tree/main/charts/sonarqube-exporter
- https://gitlab.com/ideaplexus/sonarqube-exporter
Requirements
Kubernetes: >=1.29.0-0
| Repository | Name | Version |
|---|---|---|
| https://charts.ideaplexus.com | common | 1.1.0 |
Quick start
sonarqube:
url: https://sonarqube.example.com
existingSecret: sonarqube-exporter-token
The exporter reads every project of that SonarQube, exports its measures on
/metrics and imports them again every scrapeInterval. The
exporter's README lists
every metric and its labels. sonar_scrape_success tells whether the last
import worked; on a failure the previous values stay exported.
Run one release per SonarQube. Every further exporter of the same instance
duplicates every series, which is why the chart has no replicaCount.
Token
The exporter authenticates with a SonarQube user token. It needs Browse on
the projects; Administer System additionally enables
sonar_last_analysis_timestamp_seconds. Without a token it only sees the
projects that are visible anonymously.
Keep the token out of your values and reference a secret you manage, for example one filled by External Secrets:
kubectl create secret generic sonarqube-exporter-token --from-literal=token=squ_...
sonarqube:
existingSecret: sonarqube-exporter-token
existingSecretTokenKey: token
sonarqube.token also works; the chart then keeps it in a secret of its own.
Either way it reaches the pod as a secretKeyRef, never as a plain value.
Selecting metrics
Every metric key costs one series per project, so a large instance quickly adds up to tens of thousands of series. Both lists accept shell style wildcards and are applied as "include, then exclude":
metrics:
# only the ratings, the quality gate and the size
included: [alert_status, ncloc, coverage, software_quality_*_rating]
# without the new code period
excluded: [new_*]
An empty included exports every supported key. Keys that are not selected
are not even requested from SonarQube, so the lists also reduce the API load.
Scraping
| Way | Values | For |
|---|---|---|
| Pod annotations (default) | metrics.annotations: true | an annotation based discovery, such as the Grafana Alloy annotation autodiscovery or the Prometheus kubernetes-pods job |
| ServiceMonitor | metrics.annotations: false, metrics.serviceMonitor.enabled: true | the Prometheus Operator, or Alloy reading its objects |
Use one of them. With both, a cluster that honours both scrapes the exporter twice and stores every series twice.
metrics:
annotations: false
serviceMonitor:
enabled: true
labels:
release: prometheus
The exporter only changes its values every scrapeInterval (default five
minutes), so scraping it more often costs storage without adding anything.
SonarQube behind a private CA
The image is built from scratch and only carries the public CA certificates.
Mount your CA bundle over them:
extraVolumes:
- name: ca
configMap:
name: internal-ca
extraVolumeMounts:
- name: ca
mountPath: /etc/ssl/certs/ca-certificates.crt
subPath: ca-certificates.crt
readOnly: true
The bundle replaces the public certificates, so it has to contain every CA the exporter needs.
Values
| Key | Type | Default | Description |
|---|---|---|---|
| affinity | object | {} | Affinity rules for the pod |
| commonAnnotations | object | {} | Annotations added to every resource |
| commonLabels | object | {} | Labels added to every resource |
| containerPorts.metrics | int | 9103 | Port of /metrics and /healthz, LISTEN_ADDR |
| containerSecurityContext.allowPrivilegeEscalation | bool | false | Disallow privilege escalation |
| containerSecurityContext.capabilities | object | {"drop":["ALL"]} | Linux capabilities |
| containerSecurityContext.enabled | bool | true | Enable the container security context |
| containerSecurityContext.readOnlyRootFilesystem | bool | true | Mount the root filesystem read-only. The exporter writes nothing. |
| containerSecurityContext.runAsGroup | int | 65532 | Group id to run as |
| containerSecurityContext.runAsNonRoot | bool | true | Run as a non-root user |
| containerSecurityContext.runAsUser | int | 65532 | User id to run as |
| customLivenessProbe | object | {} | A complete probe replacing the built-in liveness probe. Only used when livenessProbe.enabled is false. |
| customReadinessProbe | object | {} | A complete probe replacing the built-in readiness probe. Only used when readinessProbe.enabled is false. |
| extraDeploy | list | [] | Extra objects to deploy with the release. Evaluated as templates. |
| extraEnvVars | list | [] | Extra environment variables |
| extraEnvVarsCM | list | [] | ConfigMaps to take environment variables from |
| extraEnvVarsSecret | list | [] | Secrets to take environment variables from |
| extraVolumeMounts | list | [] | Extra volume mounts for the container |
| extraVolumes | list | [] | Extra volumes for the pod, eg. a CA bundle for a SonarQube behind a private CA |
| fullnameOverride | string | "" | Override the fully generated object names |
| global.imagePullSecrets | list | [] | Global Docker registry secret names |
| global.imageRegistry | string | "" | Global Docker image registry |
| httpTimeout | string | "1m" | Timeout of a single SonarQube request, HTTP_TIMEOUT, as a Go duration |
| image.digest | string | "" | Image digest in the form sha256:aa.... Overrides the tag when set. |
| image.pullPolicy | string | "IfNotPresent" | Image pull policy |
| image.pullSecrets | list | [] | Image pull secrets, as names or - name: my-secret |
| image.registry | string | "docker.io" | Image registry |
| image.repository | string | "ideaplexus/sonarqube-exporter" | Image repository |
| image.tag | string | "" | Image tag. Defaults to the chart appVersion. |
| livenessProbe.enabled | bool | true | Enable the liveness probe |
| livenessProbe.failureThreshold | int | 3 | Consecutive failures tolerated |
| livenessProbe.initialDelaySeconds | int | 5 | Seconds before the first check |
| livenessProbe.periodSeconds | int | 15 | Seconds between checks |
| livenessProbe.successThreshold | int | 1 | Consecutive successes needed after a failure. Must be 1 for a liveness probe. |
| livenessProbe.timeoutSeconds | int | 5 | Seconds after which a check times out |
| log.format | string | "json" | Log format, LOG_FORMAT |
| log.level | string | "info" | Log level, LOG_LEVEL |
| metrics.annotations | bool | true | Add prometheus.io/scrape, prometheus.io/port and prometheus.io/path to the pod, for an annotation based discovery such as Grafana Alloy or the Prometheus kubernetes-pods job. Turn it off with a ServiceMonitor. |
| metrics.excluded | list | [] | Metric keys never to export, SONAR_EXCLUDED_METRICS. Applied after included and always wins, eg. new_*. |
| metrics.included | list | [] | Metric keys to export, SONAR_INCLUDED_METRICS. Shell style wildcards, eg. software_quality_*_rating. Empty exports every supported key. |
| metrics.serviceMonitor.annotations | object | {} | Annotations of the ServiceMonitor |
| metrics.serviceMonitor.enabled | bool | false | Create a ServiceMonitor. Needs the monitoring.coreos.com CRDs. Turn metrics.annotations off with it. |
| metrics.serviceMonitor.honorLabels | bool | false | Keep the labels of the scraped series when they collide with the target labels |
| metrics.serviceMonitor.interval | string | "" | Scrape interval. Empty uses the Prometheus default. More often than scrapeInterval only repeats the same values. |
| metrics.serviceMonitor.labels | object | {} | Labels of the ServiceMonitor, eg. the one a Prometheus selects on |
| metrics.serviceMonitor.metricRelabelings | list | [] | Relabelings applied to the scraped series |
| metrics.serviceMonitor.namespace | string | "" | Namespace of the ServiceMonitor. Empty uses the release namespace. |
| metrics.serviceMonitor.relabelings | list | [] | Relabelings applied to the target before scraping |
| metrics.serviceMonitor.scrapeTimeout | string | "" | Scrape timeout. Empty uses the Prometheus default. |
| nameOverride | string | "" | Override the chart name used to construct object names |
| namespaceOverride | string | "" | Override the namespace the objects are created in |
| nodeSelector | object | {} | Node labels the pod is scheduled on |
| podAnnotations | object | {} | Annotations for the pod |
| podLabels | object | {} | Labels for the pod |
| podSecurityContext.enabled | bool | true | Enable the pod security context |
| podSecurityContext.fsGroup | int | 65532 | Group of the pod's volumes |
| podSecurityContext.seccompProfile | object | {"type":"RuntimeDefault"} | Seccomp profile |
| priorityClassName | string | "" | Priority class for the pod |
| readinessProbe.enabled | bool | true | Enable the readiness probe |
| readinessProbe.failureThreshold | int | 3 | Consecutive failures tolerated |
| readinessProbe.initialDelaySeconds | int | 5 | Seconds before the first check |
| readinessProbe.periodSeconds | int | 15 | Seconds between checks |
| readinessProbe.successThreshold | int | 1 | Consecutive successes needed after a failure |
| readinessProbe.timeoutSeconds | int | 5 | Seconds after which a check times out |
| resources | object | {} | Explicit container resources, which win over the preset |
| resourcesPreset | string | "nano" | Container resources preset, used when resources is empty (none, nano, micro, small, medium, large, xlarge, 2xlarge) |
| revisionHistoryLimit | int | 10 | Number of old ReplicaSets to retain |
| scrapeInterval | string | "5m" | Interval between two imports from SonarQube, SCRAPE_INTERVAL, as a Go duration |
| service.annotations | object | {} | Annotations for the Service. Do not add prometheus.io annotations here when metrics.annotations is on, a discovery of both would scrape twice. |
| service.ports.metrics | int | 9103 | Metrics port |
| service.type | string | "ClusterIP" | Service type |
| serviceAccount.annotations | object | {} | Annotations for the ServiceAccount |
| serviceAccount.automountServiceAccountToken | bool | false | Automount the API token. The exporter does not talk to the Kubernetes API. |
| serviceAccount.create | bool | true | Create a ServiceAccount |
| serviceAccount.name | string | "" | Name of the ServiceAccount. Generated when empty and create is true. |
| sonarqube.existingSecret | string | "" | Name of an existing secret holding the token, instead of letting the chart manage one. Evaluated as a template. |
| sonarqube.existingSecretTokenKey | string | "token" | Key inside that secret |
| sonarqube.token | string | "" | User token, SONAR_TOKEN, stored in a secret this chart creates. Prefer existingSecret, eg. filled by External Secrets. Needs Browse on the projects; Administer System additionally enables sonar_last_analysis_timestamp_seconds. Mutually exclusive with sonarqube.existingSecret. |
| sonarqube.url | string | "" | Base URL of the SonarQube instance, SONAR_URL, eg. https://sonarqube.example.com. Required: without it the exporter refuses to start. Evaluated as a template. |
| tolerations | list | [] | Tolerations for the pod |
| updateStrategy | object | {"type":"RollingUpdate"} | Update strategy. A rolling update has no gap in the metrics; old and new pod overlap for a few seconds. |
| updateStrategy.type | string | "RollingUpdate" | Strategy type. Recreate avoids the overlap at the price of a short gap. |
Autogenerated from chart metadata using helm-docs v1.14.2
Deploy sonarqube-exporter with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has sonarqube-exporter on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartsonarqube-exporter is pinned at v0.3.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply