Skip to content

juaalta/sonarqube-prometheus-exporter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sonarqube Prometheus Exporter

Prometheus Exporter Plugin for SonarQube.

Build Status  SonarCloud Analysis Download License Semantic Versioning

InformationFeaturesRequirementsInstallationUsageScreenshots

Information

This plugin is a fork of dmeiners88 / sonarqube-prometheus-exporter, as I have seen that the repository has been stopped for a long time, I will evolve in this repository the plugin.

Features

  • Configure which metrics to export

Requirements

  • SonarQube 8.x

Installation

  1. Download latest snapshot release
  2. Drop sonar-prometheus-exporter-1.0.0-SNAPSHOT.jar into $SONARQUBE_HOME/extensions/plugins.
  3. Restart the SonarQube server.

Usage

  1. Configure which metrics you want to export under Administration → Configuration → General Settings → Prometheus Exporter
  2. Add a scrape config to your Prometheus instance similar to this:
scrape_configs:
  - job_name: 'sonarqube'
    metrics_path: '/api/prometheus/metrics'
    static_configs:
      - targets: ['localhost:9000']
  1. Alternatively, point your HTTP client to http://localhost:9000/api/prometheus/metrics

Screenshots

Configuration Page API Call Example Grafana Dashboard Example Grafana Dashboard

Local plugin testing

In order to test the plugin locally, a file has been created for docker-compose which starts the following docker programs:

  • Sonarqube 8.9-community
  • Prometheus 2.30.1
  • Grafana 8.1.5

Previous requirements

The previous steps to be able to test the plugin are the following:

  • Install docker and docker-compose, if they are not.
  • Generate the jar file, using the following command: mvn clean package
  • Make sure the volume mounted inside the docker-compose points to the correct jar filename (the one generated in the previous step).
  • Launch the following command: sudo sysctl -w vm.max_map_count = 262144, this command is necessary to start the internal Elasticsearch of Sonarqube.

Test execution

To run the test, you must enter the docker folder and execute the following command: docker-compose up -d or docker compose up -d, depending on the docker-compose installation performed.

To stop the test, you must enter the docker folder and execute the following command: docker-compose down or docker compose down, depending on the docker-compose installation performed.

Access to the applications is as follows:

In order to view data from Sonarqube, you can add the current project, using the command mvn sonar: sonar -Dsonar.host.url = http: // localhost: 9000 -Dsonar.login = <sonarqube user token>, it is recommended launch it at least 2 times, in this way all the data can be displayed.

About

Prometheus Exporter for SonarQube

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%