Redundant queries made: SHOW RETENTION POLICIES

Hi Team,

Grafana version: 9.5.1
Database in use: Influx 2.7
Query Language: InfluxQL

Problem statement:
I don’t understand why the below GET request is being made when initially opening our dashboard:

https://grafana-dashboard.uat.robinson.systems:3001/api/datasources/proxy/uid/hTM8z3J0JW-WiHGaRovd3-nui1BJYWth-mjoPvipMkt-yEepxtR6iF/query?db=inventory_management&q=*SHOW%20RETENTION%20POLICIES*%20on%20%22inventory_management%22&epoch=ms

The InfluxQL query being made is:
SHOW RETENTION POLICIES on “inventory_management”

The above query is not written anywhere within the panel and I don’t understand what’s causing the creation of this query.

What I expect to happen:

I expect this request not to be made in the first place.

Online clues found:

Tried finding some clues from here:

But this seems to refer to this queries being redundantly made when using Flux.

Could you please advise on the above?

cc: @melori.arellano and @mattabrams tagging for attention please :pray:

I would say that is a feature of query editor

It will discover retention policies and then you can select exact retention policy names instead of guessing those names.

Hey Jan, I couldn’t find any reference to retention policy in the link you shared, could you please point me to the relevant section?

Also, do you think we can configure any settings such that this retention policy query is not made?

See:

That default in FROM section is retention policy. I bet UI will offer you all available retention policies when you click on “default”. And that retention policies list must be discovered somehow first - that’s via that query which you are referring.

But my query is edited and is as follows:

I don’t have default as part of the from statement, am I missing something here?

Yes, but that doesn’t mean that UI may not prepare data for the case when you switch to query editor instead of raw query editor.

@jangaraj Any reason why it doesn’t mean that the UI may not prepare the data for the case when I’ve switched to query editor?

Nowhere in the query editor is a query relating to retention policies so any idea on what basis the UI is persisting on making the retention policy query and how to stop it?

cc: @melori.arellano and @mattabrams tagging in case you have some ideas too please :pray:

You have very specific case, so I recommend to check source code to know more.

Anyway, is it causing you any trouble that Grafana executes this query?

Hi @ajetsharwin It is happening because of this lines https://github.com/grafana/grafana/blob/v9.5.x/public/app/plugins/datasource/influxdb/datasource.ts#L193-L214

Basically, for that version, I changed the code to load the retention policies in the beginning so I can show the “default” retention policy on the panel if there is none selected. Then I changed that behavior again. Not because it was wrong but I need to support the new influxdb engine. See here: InfluxDB: Fix retention policy handling for InfluxDB 3.0 engine by bringing back the hardcoded default by itsmylife · Pull Request #72467 · grafana/grafana · GitHub

So there is nothing wrong with having that query being made.

2 Likes