InfluxDB query with GROUP BY: filter by time range

Hello, community.

I am getting started with both Grafana (Enterprise 6.6.1) and InfluxDB and trying to design a dashboard that reacts when the time filter in the upper right corner of Grafana changes.

I am collecting SonarQube data for my company regarding developers performance. Right now I have an “issues” measurement that stores each issue returned by the SonarQube API in order to be able to apply grouping functions.

This measurement has a dummy field named point (I only use it because it is needed for some queries, but the real info is being stored in tags due to indexing) and some tags for storing the issue data, such as author, severity, type and so on.

I store one point per each issue, in this structure:

point=0 author="user1@server",severity="MAJOR",type="CODE_SMELL"
point=0 author="user1@server",severity="CRITICAL",type="BUG"
point=0 author="user1@server",severity="MAJOR",type="BUG"
point=0 author="user2@server",severity="MINOR",type="CODE_SMELL"
point=0 author="user12server",severity="CRITICAL",type="BUG"

This query does not change when the time range does, not even with a GROUP BY clause. It always shows the same value, which is the general amount of issues by a specific developer, no matter the time range. And I would like to count issues depending on the selected range (last 7 days, last month, last 3 months or whatever).

Any suggestions for accomplishing this?
Thanks.

1 Like

@nico4 I’ve requirement to collect Sonarqube metrics to Grafana. Could you please advise how you have implemented this setup.

Hi, @jaydeepuniverse.

I am using an InfluxDB instance to store metrics, but you could also use Prometheus or any other time-series database.

SonarQube has a rich API for providing a lot of info. You need an authorization token from a user with admin privileges to make sure your queries can have access to everything you need.

I use a Spring Boot application to send requests to the SonarQube endpoints, retrieve the data and store it on my Influx DB on demand or using scheduled jobs. This is the hardest work. Once done, all you need to to is configuring your DB source in Grafana and start writing queries to feed your dashboard panels.

If your use case matches mine somehow and you want more specific details, feel free to contact me.