Extracting metric data from elasticsearch

Hi,

Let me start off with explaining what I’d like to do. I want to visualize the project metrics as graphs using grafana. I’m aware sonarqube has his own graphs, but I’d like some more
sexyness in their visualization.

My plan was to to use the elasticsearch in which sonarqube stores it data as a grafana datasource. However when browsing in the elasticsearch I can’t find any data about metrics.

The following indices are present:

health status index pri rep docs.count docs.deleted store.size pri.store.size
green open components 5 0 20626 5548 83.4mb 83.4mb
green open tests 5 0 9114 169 973.6kb 973.6kb
green open projectmeasures 5 0 1134 240 538.1kb 538.1kb
green open rules 2 0 10204 0 2mb 2mb
green open issues 5 0 946069 298053 389.1mb 389.1mb
green open users 1 0 2 0 9.8kb 9.8kb
green open views 5 0 0 0 805b 805b

The issues index is by far the larges, but that only stores the issues. I’d expect the metrics data to be in the projectmeasures index, but a search query returns this:

    {
            "_index": "projectmeasures",
            "_type": "projectmeasure",
            "_id": "AVjYbSCmsoiPkvzhVkmi",
            "_score": 1,
            "_routing": "AVjYbSCmsoiPkvzhVkmi",
            "_parent": "AVjYbSCmsoiPkvzhVkmi"
        },
        {
            "_index": "projectmeasures",
            "_type": "projectmeasure",
            "_id": "82f161d6-c379-4b31-ba60-6adccbd0df49",
            "_score": 1,
            "_routing": "82f161d6-c379-4b31-ba60-6adccbd0df49",
            "_parent": "82f161d6-c379-4b31-ba60-6adccbd0df49"
        }, ...

So my question is, where does sonarqube store it’s historical metrics data (The postgres db ony stores the most recent measures)?

EDIT: I’m using sonarqube version 6.5.0.2784

Hi,

The SonarQube Elastic search indexes and the database are not supposed to be queried, so I would not recommend you to continue on this way.

However, you should have a look on web services, such as api/measures/search_history.

Regards,
Julien Lancelot

1 Like