community-plugins icon indicating copy to clipboard operation
community-plugins copied to clipboard

🐛 Grafana: Plugin Fails to Retrieve Tags for Dashboards Beyond 1000

Open codehubmanish opened this issue 7 months ago • 3 comments

Workspace

grafana

📜 Description

The Grafana plugin is encountering an issue where it fails to read tags correctly when the number of dashboards exceeds 1000. Grafana's query mechanism returns only the first 1000 results in one go, necessitating the use of a loop to fetch additional results. This limitation causes a problem where tags associated with dashboards beyond the initial 1000 are not retrieved. For instance, if there are 10 dashboards with the tag "abc" and some of these dashboards are not included in the first 1000 results, the tag "abc" will not appear in Backstage.

👍 Expected behavior

When the Grafana plugin queries for dashboards, it should retrieve all dashboards regardless of the total number. Specifically, if there are more than 1000 dashboards, the plugin should use a loop to fetch additional results beyond the initial 1000. This ensures that all tags, including those associated with dashboards beyond the first 1000, are accurately retrieved and displayed in Backstage.

Key Points:

All dashboards should be fetched, not just the first 1000. Tags from all dashboards should be displayed in Backstage. Users should see complete and accurate tag information for all dashboards.

👎 Actual Behavior with Screenshots

only 1000 results

👟 Reproduction steps

Setup Grafana:

Ensure Grafana is installed and running. Create more than 1000 dashboards in Grafana. Assign Tags:

Assign the tag "abc" to 10 dashboards, ensuring some of these dashboards are beyond the first 1000 in the list. Query Dashboards:

Use the Grafana plugin to query for dashboards. Observe that the query returns only the first 1000 dashboards. Check Tags in Backstage:

Verify the tags displayed in Backstage. Notice that the tag "abc" is missing for dashboards beyond the first 1000.

📃 Provide the context for the Bug.

Is there a possibilty rather we using search API we can use another parameter in the API which can filter specific dashboard rather fetching using search PI

👀 Have you spent some time to check if this bug has been raised before?

  • [x] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

No, but I'm happy to collaborate on a PR with someone else

codehubmanish avatar Apr 18 '25 11:04 codehubmanish

Looking for contributions for this one, please!

awanlin avatar Apr 22 '25 14:04 awanlin

Ran into this as well recently: There is a dashboardsByTag function that searches by tag, but that is not directly compatible with the query evaluator.

One caveat is the upstream Grafana /api/search does not return any markers to say if there are more pages of results.

Partial solution parts:

  • pass higher limit (5000 is the max)
  • explicitly pass limit and manually paginate if it returns N == limit; join results
  • extract tags from the filter, pass those to the search API

Either the extract or higher limit partial solutions run into issues on their own, so need all 3 together for a reliable fix.

  • the match is on something OTHER than tags [e.g. title, url, folderTitle, folderUrl]
  • More than $MAXLIMIT dashboards match the tag in question

robbat2 avatar Apr 27 '25 01:04 robbat2

My fix is in https://github.com/backstage/community-plugins/pull/3909 - needs approvals

robbat2 avatar May 16 '25 14:05 robbat2

can you share the version of grafana you are using?

vinzscam avatar Jun 13 '25 07:06 vinzscam

Grafana 10.4.19 [also commented in the PR]

robbat2 avatar Jun 16 '25 23:06 robbat2

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 16 '25 00:08 github-actions[bot]