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