Dashboard Provisioning: Reduce db load #106114
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this feature?
This PR reduces the number of database calls when provisioning dashboards via file based provisioning. Currently, we are only indexing the name of the provisioner, so we have to search all dashboards created under that provisioner name, and then do a query for each provisioned dashboard to get that dashboard's provisioning information. Since these calls happen by default every 10s, this can be significant on instances with a lot of provisioned dashboards. Now that we are looking at making things indexed, but not searchable (so it is not as expensive to add more fields - cc @chaudyg), we can add those to be indexed and reduce this to 1 db call.
To support this in mode 0-2, I had to update some databases function to return the provisioning data as well.
Additionally, I removed the concurrency on getting the provisioned dashboards. This is a background job, and people were seeing "too many connection" errors. While the other optimizations in this PR will fix it, we do not want to be exhausting db connections for background provisioning.
Why do we need this feature?
When instances have a large number of provisioned dashboards, this is hammering the database.