Alerting: Optimize prometheus api permission checks (#106299)

* Alerting: Optimize prometheus api permission checks

This improves the performance of the Prometheus API by performing the permission checks for rule read permission in a folder upfront, rather than checking permissions for each rule group individually. This reduces the number of permission checks and should speed up the API response time.

* refactor vars

---------

Co-authored-by: Konrad Lalik <konradlalik@gmail.com>
This commit is contained in:
Moustafa Baiou
2025-06-05 09:43:06 -04:00
committed by GitHub
co-authored by Konrad Lalik
parent 6fd66dd690
commit 941162ca79
2 changed files with 30 additions and 31 deletions
+4
View File
@@ -129,6 +129,10 @@ var _ ac.AccessControl = &recordingAccessControlFake{}
type fakeRuleAccessControlService struct {
}
func (f *fakeRuleAccessControlService) HasAccessInFolder(ctx context.Context, user identity.Requester, folder models.Namespaced) (bool, error) {
return true, nil
}
func (f fakeRuleAccessControlService) HasAccessToRuleGroup(ctx context.Context, user identity.Requester, rules models.RulesGroup) (bool, error) {
return true, nil
}