Code Monkey home page Code Monkey logo

sonarqube-prometheus-exporter's Introduction

Sonarqube Prometheus Exporter

Project to collect some Sonarqube metrics through the API and then expose such information for Prometheus collection.

With the intention of using Sonarqube for a range of projects, being able to increase or decrease the number of projects and directly their metrics, the project construction was thinking of several realities and not being directly linked to some metrics.

Importantly, Prometheus does not understand non-numeric values, so be aware if you want to add metrics that can return non-numeric values.

How to use

First make sure there is communication and be able to authenticate to Sonarqube:

curl -XGET -u {USER}:{PASSWORD} https://mysonarqube.example.com

Where {USER} and {PASSWORD}, replace with values that make sense in your reality.

Externalização dos valores requeridos para autenticar na API

Export the environment variables to the values required to connect to Sonarqube. In the file config.py, the variables are decoded:

  • SONAR_URL
  • SONAR_USER
  • SONAR_PASSWORD

To do this, run (Linux):

export SONAR_URL=https://mysonarqube.example.com
export SONAR_USER={USER}
export SONAR_PASSWORD={PASSWORD}

Where {USER} and {PASSWORD}, replace with values that make sense in your reality.

Add or remove Sonarqube metrics

In the config.py file, you will find a variable named SUPPORTED_KEYS, which loads an array of dicts containing the domain and keys that are captured by the script. If you just want to add a metric, identify your domain and then add it according to your domain. You can also add new ones as there is no restriction on the current ones.

Attention: non-numeric metrics will be collected, but Prometheus will not support the values. prometheus/prometheus#2227

Metric naming

Prometheus, as a best practice, includes a value for documentation and Sonarqube natively exposes descriptions of each metric. Thus, the description of Sonarqube was addressed as documentation of Prometheus.

Each metric will have its name preserved by just adding the prefix "sonar _", making it easy to identify in Prometheus.

Grafana

Within my reality, not all metrics were used, but some that made sense at the moment include in a dashboard.

In this dashboard, projects are captured from the sonar_bugs metric and collecting the project key. You can view all metrics, only one or more than one.

Import the grafana_dashboard.json file, changing the DataSource to your reality.

Dashboard screenshot

Simple dashboard with the possibility to filter by projects. For each selected project, a Gauge graph will be added and the others with line graphs will have one more line with that value. You can select all projects.

Simple dashboard

sonarqube-prometheus-exporter's People

Contributors

vinicelms avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.