Add MFolderIDsAPICount metric to count FolderIDs in api package (#80866)

* Add MFolderIDsAPICount metric to cound FolderIDs in api package

* Change counter to counter vector with method names as string values
This commit is contained in:
idafurjes
2024-01-24 12:39:11 +01:00
committed by GitHub
parent 5576731332
commit 6b4eaa0d18
7 changed files with 42 additions and 3 deletions
+25
View File
@@ -113,6 +113,9 @@ var (
// MPublicDashboardDatasourceQuerySuccess is a metric counter for successful queries labelled by datasource
MPublicDashboardDatasourceQuerySuccess *prometheus.CounterVec
// MFolderIDsAPICount is a metric counter for folder ids count in the api package
MFolderIDsAPICount *prometheus.CounterVec
)
// Timers
@@ -216,9 +219,24 @@ var (
MStatTotalCorrelations prometheus.Gauge
)
const (
GetAlerts string = "GetAlerts"
GetDashboard string = "GetDashboard"
RestoreDashboardVersion string = "RestoreDashboardVersion"
GetFolderByID string = "GetFolderByID"
GetFolderDescendantCounts string = "GetFolderDescendantCounts"
SearchFolders string = "searchFolders"
GetFolderPermissionList string = "GetFolderPermissionList"
UpdateFolderPermissions string = "UpdateFolderPermissions"
GetFolderACL string = "getFolderACL"
Search string = "Search"
GetDashboardACL string = "getDashboardACL"
)
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}
MInstanceStart = prometheus.NewCounter(prometheus.CounterOpts{
Name: "instance_start_total",
@@ -456,6 +474,12 @@ func init() {
Namespace: ExporterName,
}, []string{"datasource", "status"}, map[string][]string{"status": pubdash.QueryResultStatuses})
MFolderIDsAPICount = metricutil.NewCounterVecStartingAtZero(prometheus.CounterOpts{
Name: "folder_id_api_count",
Help: "counter for folder id usage in api package",
Namespace: ExporterName,
}, []string{"method"}, map[string][]string{"method": apiFolderIDMethods})
MStatTotalDashboards = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "stat_totals_dashboard",
Help: "total amount of dashboards",
@@ -747,5 +771,6 @@ func initMetricVars(reg prometheus.Registerer) {
MPublicDashboardRequestCount,
MPublicDashboardDatasourceQuerySuccess,
MStatTotalCorrelations,
MFolderIDsAPICount,
)
}