mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add leftover metrics for FolderID (#81246)
This commit is contained in:
parent
85429f7bd0
commit
0880a239f8
@ -65,7 +65,7 @@ func (hs *HTTPServer) GetFolders(c *contextmodel.ReqContext) response.Response {
|
||||
Title: f.Title,
|
||||
ParentUID: f.ParentUID,
|
||||
})
|
||||
metrics.MFolderIDsAPICount.WithLabelValues("GetFolders").Inc()
|
||||
metrics.MFolderIDsAPICount.WithLabelValues(metrics.GetFolders).Inc()
|
||||
}
|
||||
|
||||
return response.JSON(http.StatusOK, hits)
|
||||
@ -124,7 +124,7 @@ func (hs *HTTPServer) GetFolderByID(c *contextmodel.ReqContext) response.Respons
|
||||
if err != nil {
|
||||
return response.Error(http.StatusBadRequest, "id is invalid", err)
|
||||
}
|
||||
metrics.MFolderIDsAPICount.WithLabelValues("GetFolderByID").Inc()
|
||||
metrics.MFolderIDsAPICount.WithLabelValues(metrics.GetFolderByID).Inc()
|
||||
// nolint:staticcheck
|
||||
folder, err := hs.folderService.Get(c.Req.Context(), &folder.GetFolderQuery{ID: &id, OrgID: c.SignedInUser.GetOrgID(), SignedInUser: c.SignedInUser})
|
||||
if err != nil {
|
||||
@ -372,7 +372,7 @@ func (hs *HTTPServer) newToFolderDto(c *contextmodel.ReqContext, f *folder.Folde
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
metrics.MFolderIDsAPICount.WithLabelValues("newToFolderDto").Inc()
|
||||
metrics.MFolderIDsAPICount.WithLabelValues(metrics.NewToFolderDTO).Inc()
|
||||
return dtos.Folder{
|
||||
ID: f.ID, // nolint:staticcheck
|
||||
UID: f.UID,
|
||||
@ -472,7 +472,7 @@ func (hs *HTTPServer) searchFolders(c *contextmodel.ReqContext) ([]dtos.FolderSe
|
||||
UID: hit.UID,
|
||||
Title: hit.Title,
|
||||
})
|
||||
metrics.MFolderIDsAPICount.WithLabelValues("searchFolders").Inc()
|
||||
metrics.MFolderIDsAPICount.WithLabelValues(metrics.SearchFolders).Inc()
|
||||
}
|
||||
|
||||
return folderHits, nil
|
||||
|
@ -235,6 +235,8 @@ const (
|
||||
GetFolderACL string = "getFolderACL"
|
||||
Search string = "Search"
|
||||
GetDashboardACL string = "getDashboardACL"
|
||||
NewToFolderDTO string = "newToFolderDto"
|
||||
GetFolders string = "GetFolders"
|
||||
// FolderID services
|
||||
Folder string = "folder"
|
||||
Dashboard string = "dashboards"
|
||||
@ -245,13 +247,14 @@ const (
|
||||
PublicDashboards string = "publicdashboards"
|
||||
AccessControl string = "accesscontrol"
|
||||
Guardian string = "guardian"
|
||||
DashboardImport string = "dashboardimport"
|
||||
)
|
||||
|
||||
func init() {
|
||||
httpStatusCodes := []string{"200", "404", "500", "unknown"}
|
||||
objectiveMap := map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}
|
||||
apiFolderIDMethods := []string{GetAlerts, GetDashboard, RestoreDashboardVersion, GetFolderByID, GetFolderDescendantCounts, SearchFolders, GetFolderPermissionList, UpdateFolderPermissions, GetFolderACL, Search, GetDashboardACL}
|
||||
serviceFolderIDMethods := []string{Folder, Dashboard, LibraryElements, LibraryPanels, NGAlerts, Provisioning, PublicDashboards, AccessControl, Guardian, Search}
|
||||
apiFolderIDMethods := []string{GetAlerts, GetDashboard, RestoreDashboardVersion, GetFolderByID, GetFolderDescendantCounts, SearchFolders, GetFolderPermissionList, UpdateFolderPermissions, GetFolderACL, Search, GetDashboardACL, NewToFolderDTO, GetFolders}
|
||||
serviceFolderIDMethods := []string{Folder, Dashboard, LibraryElements, LibraryPanels, NGAlerts, Provisioning, PublicDashboards, AccessControl, Guardian, Search, DashboardImport}
|
||||
|
||||
MInstanceStart = prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Name: "instance_start_total",
|
||||
|
@ -84,7 +84,7 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb
|
||||
generatedDash.Del("__inputs")
|
||||
generatedDash.Del("__requires")
|
||||
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues("dashboardimport").Inc()
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.DashboardImport).Inc()
|
||||
// here we need to get FolderId from FolderUID if it present in the request, if both exist, FolderUID would overwrite FolderID
|
||||
if req.FolderUid != "" {
|
||||
folder, err := s.folderService.Get(ctx, &folder.GetFolderQuery{
|
||||
@ -139,7 +139,7 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb
|
||||
return nil, err
|
||||
}
|
||||
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues("dashboardimport").Inc()
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.DashboardImport).Inc()
|
||||
// nolint:staticcheck
|
||||
err = s.libraryPanelService.ImportLibraryPanelsForDashboard(ctx, req.User, libraryElements, generatedDash.Get("panels").MustArray(), req.FolderId)
|
||||
if err != nil {
|
||||
@ -152,7 +152,7 @@ func (s *ImportDashboardService) ImportDashboard(ctx context.Context, req *dashb
|
||||
}
|
||||
|
||||
revision := savedDashboard.Data.Get("revision").MustInt64(0)
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues("dashboardimport").Inc()
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.DashboardImport).Inc()
|
||||
return &dashboardimport.ImportDashboardResponse{
|
||||
UID: savedDashboard.UID,
|
||||
PluginId: req.PluginId,
|
||||
|
Loading…
Reference in New Issue
Block a user