Code Monkey home page Code Monkey logo

sonarqube-exporter's Introduction

SonarQube metrics exporter to InfluxDB

Simple script that ships all project metrics from SonarQube to InfluxDB.

This can be later graph with (Grafana)[https://grafana.com/]

Requirements

  • Python >= 3
  • InfluxDB python module
  • Python Requests

Python requirements can be installed with pip

pip install -r requirements.txt

Usage

Secrets such as users and passwords are handled via environment variables for simplicity.

Required ones are:

USER = os.environ['SONAR_USER']
PASSWORD = os.environ['SONAR_PASSWORD']
INFLUX_USER = os.environ['INFLUX_USER']
INFLUX_PASSWORD = os.environ['INFLUX_PASSWORD']
INFLUX_DB = os.environ['INFLUX_DB']

You can simply execute it like:

$ SONAR_USER=user SONAR_PASSWORD=passwd INFLUX_USER=user INFLUX_PASSWORD=passwd INFLUX_DB=db python sonar-client.py

This will export all the metrics in the following json

[
    {
        "fields": {
            "value": "75"
        },
        "measurement": "coverage",
        "tags": {
            "id": "somekey",
            "key": "org.sonarqube:example-generic-coverage-sonar-scanner"
        },
        "time": "2017-05-17T13:02:43.597894"
    }
]

Author: Pedro Diaz [email protected]

sonarqube-exporter's People

Contributors

multiservicio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sonarqube-exporter's Issues

How to export the metrics to grafana?

Hi,

I have run the script and it prints the project name and project id on terminal. What is the next step? How to actually display these metrics in Grafana?

KeyError: 'component' message

mineuser@jbehave:/opt/sonarqube-exporter > python3 sonar-client.py
com.g-dev.jbehave:BUM_PLUS GWgG1xtnhxQdf62aHxuD
com.g-dev.jbehave:nokey AXfjcTCwhxWdx62aHguI
com.g-dev.jbehave:Vuln_Node AKqKAsdjPjpAgud
Traceback (most recent call last):
File "sonar-client.py", line 115, in
measures = client.get_measures_by_component_id(uri + '?' + component_id_query_param + '&' + metric_key_query_param)
File "sonar-client.py", line 54, in get_measures_by_component_id
return data['component']['measures']
KeyError: 'component'
mineuser@jbehave:/opt/sonarqube-exporter >

about sonarqube metric value type

Sonarqube default have many datatype:

for example

{ "types": [ "INT", "FLOAT", "PERCENT", "BOOL", "STRING", "MILLISEC", "DATA", "LEVEL", "DISTRIB", "RATING", "WORK_DUR" ]

I see you code and not convert metric datatype,
I want to know how you do it.

finally,Can you provide a grafana dashboard templates.

thx.

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.