mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Metrics: use consistent naming for exported variables (#18134)
* Metrics: remove unused metrics Metric `M_Grafana_Version` is not used anywhere, nor the mentioned `M_Grafana_Build_Version`. Seems to be an artefact? * Metrics: make the naming consistent * Metrics: add comments to exported vars * Metrics: use proper naming Fixes #18110
This commit is contained in:
parent
15ce5a68cf
commit
75fa1f0207
@ -34,7 +34,7 @@ func AdminCreateUser(c *models.ReqContext, form dtos.AdminCreateUserForm) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.M_Api_Admin_User_Create.Inc()
|
metrics.MApiAdminUserCreate.Inc()
|
||||||
|
|
||||||
user := cmd.Result
|
user := cmd.Result
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ func (hs *HTTPServer) GetDashboard(c *m.ReqContext) Response {
|
|||||||
Meta: meta,
|
Meta: meta,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.TimeRequest(metrics.M_Api_Dashboard_Get)
|
c.TimeRequest(metrics.MApiDashboardGet)
|
||||||
return JSON(200, dto)
|
return JSON(200, dto)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ func (hs *HTTPServer) PostDashboard(c *m.ReqContext, cmd m.SaveDashboardCommand)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.TimeRequest(metrics.M_Api_Dashboard_Save)
|
c.TimeRequest(metrics.MApiDashboardSave)
|
||||||
return JSON(200, util.DynMap{
|
return JSON(200, util.DynMap{
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"slug": dashboard.Slug,
|
"slug": dashboard.Slug,
|
||||||
|
@ -97,7 +97,7 @@ func CreateDashboardSnapshot(c *m.ReqContext, cmd m.CreateDashboardSnapshotComma
|
|||||||
cmd.ExternalDeleteUrl = response.DeleteUrl
|
cmd.ExternalDeleteUrl = response.DeleteUrl
|
||||||
cmd.Dashboard = simplejson.New()
|
cmd.Dashboard = simplejson.New()
|
||||||
|
|
||||||
metrics.M_Api_Dashboard_Snapshot_External.Inc()
|
metrics.MApiDashboardSnapshotExternal.Inc()
|
||||||
} else {
|
} else {
|
||||||
if cmd.Key == "" {
|
if cmd.Key == "" {
|
||||||
cmd.Key = util.GetRandomString(32)
|
cmd.Key = util.GetRandomString(32)
|
||||||
@ -109,7 +109,7 @@ func CreateDashboardSnapshot(c *m.ReqContext, cmd m.CreateDashboardSnapshotComma
|
|||||||
|
|
||||||
url = setting.ToAbsUrl("dashboard/snapshot/" + cmd.Key)
|
url = setting.ToAbsUrl("dashboard/snapshot/" + cmd.Key)
|
||||||
|
|
||||||
metrics.M_Api_Dashboard_Snapshot_Create.Inc()
|
metrics.MApiDashboardSnapshotCreate.Inc()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bus.Dispatch(&cmd); err != nil {
|
if err := bus.Dispatch(&cmd); err != nil {
|
||||||
@ -154,7 +154,7 @@ func GetDashboardSnapshot(c *m.ReqContext) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.M_Api_Dashboard_Snapshot_Get.Inc()
|
metrics.MApiDashboardSnapshotGet.Inc()
|
||||||
|
|
||||||
c.Resp.Header().Set("Cache-Control", "public, max-age=3600")
|
c.Resp.Header().Set("Cache-Control", "public, max-age=3600")
|
||||||
c.JSON(200, dto)
|
c.JSON(200, dto)
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (hs *HTTPServer) ProxyDataSourceRequest(c *m.ReqContext) {
|
func (hs *HTTPServer) ProxyDataSourceRequest(c *m.ReqContext) {
|
||||||
c.TimeRequest(metrics.M_DataSource_ProxyReq_Timer)
|
c.TimeRequest(metrics.MDataSourceProxyReqTimer)
|
||||||
|
|
||||||
dsId := c.ParamsInt64(":id")
|
dsId := c.ParamsInt64(":id")
|
||||||
ds, err := hs.DatasourceCache.GetDatasource(dsId, c.SignedInUser, c.SkipCache)
|
ds, err := hs.DatasourceCache.GetDatasource(dsId, c.SignedInUser, c.SkipCache)
|
||||||
|
@ -138,7 +138,7 @@ func (hs *HTTPServer) LoginPost(c *models.ReqContext, cmd dtos.LoginCommand) Res
|
|||||||
c.SetCookie("redirect_to", "", -1, setting.AppSubUrl+"/")
|
c.SetCookie("redirect_to", "", -1, setting.AppSubUrl+"/")
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.M_Api_Login_Post.Inc()
|
metrics.MApiLoginPost.Inc()
|
||||||
return JSON(200, result)
|
return JSON(200, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ func (hs *HTTPServer) OAuthLogin(ctx *m.ReqContext) {
|
|||||||
// login
|
// login
|
||||||
hs.loginUserWithUser(cmd.Result, ctx)
|
hs.loginUserWithUser(cmd.Result, ctx)
|
||||||
|
|
||||||
metrics.M_Api_Login_OAuth.Inc()
|
metrics.MApiLoginOAuth.Inc()
|
||||||
|
|
||||||
if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
|
if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
|
||||||
ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl+"/")
|
ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl+"/")
|
||||||
|
@ -88,7 +88,7 @@ func CreateOrg(c *m.ReqContext, cmd m.CreateOrgCommand) Response {
|
|||||||
return Error(500, "Failed to create organization", err)
|
return Error(500, "Failed to create organization", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.M_Api_Org_Create.Inc()
|
metrics.MApiOrgCreate.Inc()
|
||||||
|
|
||||||
return JSON(200, &util.DynMap{
|
return JSON(200, &util.DynMap{
|
||||||
"orgId": cmd.Result.Id,
|
"orgId": cmd.Result.Id,
|
||||||
|
@ -188,8 +188,8 @@ func (hs *HTTPServer) CompleteInvite(c *m.ReqContext, completeInvite dtos.Comple
|
|||||||
|
|
||||||
hs.loginUserWithUser(user, c)
|
hs.loginUserWithUser(user, c)
|
||||||
|
|
||||||
metrics.M_Api_User_SignUpCompleted.Inc()
|
metrics.MApiUserSignUpCompleted.Inc()
|
||||||
metrics.M_Api_User_SignUpInvite.Inc()
|
metrics.MApiUserSignUpInvite.Inc()
|
||||||
|
|
||||||
return Success("User created and logged in")
|
return Success("User created and logged in")
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,6 @@ func Search(c *m.ReqContext) Response {
|
|||||||
return Error(500, "Search failed", err)
|
return Error(500, "Search failed", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.TimeRequest(metrics.M_Api_Dashboard_Search)
|
c.TimeRequest(metrics.MApiDashboardSearch)
|
||||||
return JSON(200, searchQuery.Result)
|
return JSON(200, searchQuery.Result)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func SignUp(c *m.ReqContext, form dtos.SignUpForm) Response {
|
|||||||
Code: cmd.Code,
|
Code: cmd.Code,
|
||||||
})
|
})
|
||||||
|
|
||||||
metrics.M_Api_User_SignUpStarted.Inc()
|
metrics.MApiUserSignUpStarted.Inc()
|
||||||
|
|
||||||
return JSON(200, util.DynMap{"status": "SignUpCreated"})
|
return JSON(200, util.DynMap{"status": "SignUpCreated"})
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ func (hs *HTTPServer) SignUpStep2(c *m.ReqContext, form dtos.SignUpStep2Form) Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
hs.loginUserWithUser(user, c)
|
hs.loginUserWithUser(user, c)
|
||||||
metrics.M_Api_User_SignUpCompleted.Inc()
|
metrics.MApiUserSignUpCompleted.Inc()
|
||||||
|
|
||||||
return JSON(200, apiResponse)
|
return JSON(200, apiResponse)
|
||||||
}
|
}
|
||||||
|
@ -3,107 +3,177 @@ package metrics
|
|||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const exporterName = "grafana"
|
const exporterName = "grafana"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
M_Instance_Start prometheus.Counter
|
// MInstanceStart is a metric counter for started instances
|
||||||
M_Page_Status *prometheus.CounterVec
|
MInstanceStart prometheus.Counter
|
||||||
M_Api_Status *prometheus.CounterVec
|
|
||||||
M_Proxy_Status *prometheus.CounterVec
|
|
||||||
M_Http_Request_Total *prometheus.CounterVec
|
|
||||||
M_Http_Request_Summary *prometheus.SummaryVec
|
|
||||||
|
|
||||||
M_Api_User_SignUpStarted prometheus.Counter
|
// MPageStatus is a metric page http response status
|
||||||
M_Api_User_SignUpCompleted prometheus.Counter
|
MPageStatus *prometheus.CounterVec
|
||||||
M_Api_User_SignUpInvite prometheus.Counter
|
|
||||||
M_Api_Dashboard_Save prometheus.Summary
|
|
||||||
M_Api_Dashboard_Get prometheus.Summary
|
|
||||||
M_Api_Dashboard_Search prometheus.Summary
|
|
||||||
M_Api_Admin_User_Create prometheus.Counter
|
|
||||||
M_Api_Login_Post prometheus.Counter
|
|
||||||
M_Api_Login_OAuth prometheus.Counter
|
|
||||||
M_Api_Org_Create prometheus.Counter
|
|
||||||
|
|
||||||
M_Api_Dashboard_Snapshot_Create prometheus.Counter
|
// MApiStatus is a metric api http response status
|
||||||
M_Api_Dashboard_Snapshot_External prometheus.Counter
|
MApiStatus *prometheus.CounterVec
|
||||||
M_Api_Dashboard_Snapshot_Get prometheus.Counter
|
|
||||||
M_Api_Dashboard_Insert prometheus.Counter
|
|
||||||
M_Alerting_Result_State *prometheus.CounterVec
|
|
||||||
M_Alerting_Notification_Sent *prometheus.CounterVec
|
|
||||||
M_Aws_CloudWatch_GetMetricStatistics prometheus.Counter
|
|
||||||
M_Aws_CloudWatch_ListMetrics prometheus.Counter
|
|
||||||
M_Aws_CloudWatch_GetMetricData prometheus.Counter
|
|
||||||
M_DB_DataSource_QueryById prometheus.Counter
|
|
||||||
|
|
||||||
// LDAPUsersSyncExecutionTime is a metric for
|
// MProxyStatus is a metric proxy http response status
|
||||||
// how much time it took to sync the LDAP users
|
MProxyStatus *prometheus.CounterVec
|
||||||
|
|
||||||
|
// MHttpRequestTotal is a metric http request counter
|
||||||
|
MHttpRequestTotal *prometheus.CounterVec
|
||||||
|
|
||||||
|
// MHttpRequestSummary is a metric http request summary
|
||||||
|
MHttpRequestSummary *prometheus.SummaryVec
|
||||||
|
|
||||||
|
// MApiUserSignUpStarted is a metric amount of users who started the signup flow
|
||||||
|
MApiUserSignUpStarted prometheus.Counter
|
||||||
|
|
||||||
|
// MApiUserSignUpCompleted is a metric amount of users who completed the signup flow
|
||||||
|
MApiUserSignUpCompleted prometheus.Counter
|
||||||
|
|
||||||
|
// MApiUserSignUpInvite is a metric amount of users who have been invited
|
||||||
|
MApiUserSignUpInvite prometheus.Counter
|
||||||
|
|
||||||
|
// MApiDashboardSave is a metric summary for dashboard save duration
|
||||||
|
MApiDashboardSave prometheus.Summary
|
||||||
|
|
||||||
|
// MApiDashboardGet is a metric summary for dashboard get duration
|
||||||
|
MApiDashboardGet prometheus.Summary
|
||||||
|
|
||||||
|
// MApiDashboardSearch is a metric summary for dashboard search duration
|
||||||
|
MApiDashboardSearch prometheus.Summary
|
||||||
|
|
||||||
|
// MApiAdminUserCreate is a metric api admin user created counter
|
||||||
|
MApiAdminUserCreate prometheus.Counter
|
||||||
|
|
||||||
|
// MApiLoginPost is a metric api login post counter
|
||||||
|
MApiLoginPost prometheus.Counter
|
||||||
|
|
||||||
|
// MApiLoginOAuth is a metric api login oauth counter
|
||||||
|
MApiLoginOAuth prometheus.Counter
|
||||||
|
|
||||||
|
// MApiOrgCreate is a metric api org created counter
|
||||||
|
MApiOrgCreate prometheus.Counter
|
||||||
|
|
||||||
|
// MApiDashboardSnapshotCreate is a metric dashboard snapshots created
|
||||||
|
MApiDashboardSnapshotCreate prometheus.Counter
|
||||||
|
|
||||||
|
// MApiDashboardSnapshotExternal is a metric external dashboard snapshots created
|
||||||
|
MApiDashboardSnapshotExternal prometheus.Counter
|
||||||
|
|
||||||
|
// MApiDashboardSnapshotGet is a metric loaded dashboards
|
||||||
|
MApiDashboardSnapshotGet prometheus.Counter
|
||||||
|
|
||||||
|
// MApiDashboardInsert is a metric dashboards inserted
|
||||||
|
MApiDashboardInsert prometheus.Counter
|
||||||
|
|
||||||
|
// MAlertingResultState is a metric alert execution result counter
|
||||||
|
MAlertingResultState *prometheus.CounterVec
|
||||||
|
|
||||||
|
// MAlertingNotificationSent is a metric counter for how many alert notifications been sent
|
||||||
|
MAlertingNotificationSent *prometheus.CounterVec
|
||||||
|
|
||||||
|
// MAwsCloudWatchGetMetricStatistics is a metric counter for getting metric statistics from aws
|
||||||
|
MAwsCloudWatchGetMetricStatistics prometheus.Counter
|
||||||
|
|
||||||
|
// MAwsCloudWatchListMetrics is a metric counter for getting list of metrics from aws
|
||||||
|
MAwsCloudWatchListMetrics prometheus.Counter
|
||||||
|
|
||||||
|
// MAwsCloudWatchGetMetricData is a metric counter for getting metric data time series from aws
|
||||||
|
MAwsCloudWatchGetMetricData prometheus.Counter
|
||||||
|
|
||||||
|
// MDBDataSourceQueryByID is a metric counter for getting datasource by id
|
||||||
|
MDBDataSourceQueryByID prometheus.Counter
|
||||||
|
|
||||||
|
// LDAPUsersSyncExecutionTime is a metric summary for LDAP users sync execution duration
|
||||||
LDAPUsersSyncExecutionTime prometheus.Summary
|
LDAPUsersSyncExecutionTime prometheus.Summary
|
||||||
|
)
|
||||||
|
|
||||||
// Timers
|
// Timers
|
||||||
M_DataSource_ProxyReq_Timer prometheus.Summary
|
var (
|
||||||
M_Alerting_Execution_Time prometheus.Summary
|
// MDataSourceProxyReqTimer is a metric summary for dataproxy request duration
|
||||||
|
MDataSourceProxyReqTimer prometheus.Summary
|
||||||
|
|
||||||
|
// MAlertingExecutionTime is a metric summary of alert exeuction duration
|
||||||
|
MAlertingExecutionTime prometheus.Summary
|
||||||
)
|
)
|
||||||
|
|
||||||
// StatTotals
|
// StatTotals
|
||||||
var (
|
var (
|
||||||
M_Alerting_Active_Alerts prometheus.Gauge
|
// MAlertingActiveAlerts is a metric amount of active alerts
|
||||||
M_StatTotal_Dashboards prometheus.Gauge
|
MAlertingActiveAlerts prometheus.Gauge
|
||||||
M_StatTotal_Users prometheus.Gauge
|
|
||||||
M_StatActive_Users prometheus.Gauge
|
|
||||||
M_StatTotal_Orgs prometheus.Gauge
|
|
||||||
M_StatTotal_Playlists prometheus.Gauge
|
|
||||||
|
|
||||||
StatsTotalViewers prometheus.Gauge
|
// MStatTotalDashboards is a metric total amount of dashboards
|
||||||
StatsTotalEditors prometheus.Gauge
|
MStatTotalDashboards prometheus.Gauge
|
||||||
StatsTotalAdmins prometheus.Gauge
|
|
||||||
|
// MStatTotalUsers is a metric total amount of users
|
||||||
|
MStatTotalUsers prometheus.Gauge
|
||||||
|
|
||||||
|
// MStatActiveUsers is a metric number of active users
|
||||||
|
MStatActiveUsers prometheus.Gauge
|
||||||
|
|
||||||
|
// MStatTotalOrgs is a metric total amount of orgs
|
||||||
|
MStatTotalOrgs prometheus.Gauge
|
||||||
|
|
||||||
|
// MStatTotalPlaylists is a metric total amount of playlists
|
||||||
|
MStatTotalPlaylists prometheus.Gauge
|
||||||
|
|
||||||
|
// StatsTotalViewers is a metric total amount of viewers
|
||||||
|
StatsTotalViewers prometheus.Gauge
|
||||||
|
|
||||||
|
// StatsTotalEditors is a metric total amount of editors
|
||||||
|
StatsTotalEditors prometheus.Gauge
|
||||||
|
|
||||||
|
// StatsTotalAdmins is a metric total amount of admins
|
||||||
|
StatsTotalAdmins prometheus.Gauge
|
||||||
|
|
||||||
|
// StatsTotalActiveViewers is a metric total amount of viewers
|
||||||
StatsTotalActiveViewers prometheus.Gauge
|
StatsTotalActiveViewers prometheus.Gauge
|
||||||
|
|
||||||
|
// StatsTotalActiveEditors is a metric total amount of active editors
|
||||||
StatsTotalActiveEditors prometheus.Gauge
|
StatsTotalActiveEditors prometheus.Gauge
|
||||||
StatsTotalActiveAdmins prometheus.Gauge
|
|
||||||
|
|
||||||
// M_Grafana_Version is a gauge that contains build info about this binary
|
// StatsTotalActiveAdmins is a metric total amount of active admins
|
||||||
//
|
StatsTotalActiveAdmins prometheus.Gauge
|
||||||
// Deprecated: use M_Grafana_Build_Version instead.
|
|
||||||
M_Grafana_Version *prometheus.GaugeVec
|
|
||||||
|
|
||||||
// grafanaBuildVersion is a gauge that contains build info about this binary
|
// grafanaBuildVersion is a metric with a constant '1' value labeled by version, revision, branch, and goversion from which Grafana was built
|
||||||
grafanaBuildVersion *prometheus.GaugeVec
|
grafanaBuildVersion *prometheus.GaugeVec
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
M_Instance_Start = prometheus.NewCounter(prometheus.CounterOpts{
|
httpStatusCodes := []string{"200", "404", "500", "unknown"}
|
||||||
|
MInstanceStart = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
Name: "instance_start_total",
|
Name: "instance_start_total",
|
||||||
Help: "counter for started instances",
|
Help: "counter for started instances",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
httpStatusCodes := []string{"200", "404", "500", "unknown"}
|
MPageStatus = newCounterVecStartingAtZero(
|
||||||
M_Page_Status = newCounterVecStartingAtZero(
|
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: "page_response_status_total",
|
Name: "page_response_status_total",
|
||||||
Help: "page http response status",
|
Help: "page http response status",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
}, []string{"code"}, httpStatusCodes...)
|
}, []string{"code"}, httpStatusCodes...)
|
||||||
|
|
||||||
M_Api_Status = newCounterVecStartingAtZero(
|
MApiStatus = newCounterVecStartingAtZero(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: "api_response_status_total",
|
Name: "api_response_status_total",
|
||||||
Help: "api http response status",
|
Help: "api http response status",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
}, []string{"code"}, httpStatusCodes...)
|
}, []string{"code"}, httpStatusCodes...)
|
||||||
|
|
||||||
M_Proxy_Status = newCounterVecStartingAtZero(
|
MProxyStatus = newCounterVecStartingAtZero(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: "proxy_response_status_total",
|
Name: "proxy_response_status_total",
|
||||||
Help: "proxy http response status",
|
Help: "proxy http response status",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
}, []string{"code"}, httpStatusCodes...)
|
}, []string{"code"}, httpStatusCodes...)
|
||||||
|
|
||||||
M_Http_Request_Total = prometheus.NewCounterVec(
|
MHttpRequestTotal = prometheus.NewCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: "http_request_total",
|
Name: "http_request_total",
|
||||||
Help: "http request counter",
|
Help: "http request counter",
|
||||||
@ -111,7 +181,7 @@ func init() {
|
|||||||
[]string{"handler", "statuscode", "method"},
|
[]string{"handler", "statuscode", "method"},
|
||||||
)
|
)
|
||||||
|
|
||||||
M_Http_Request_Summary = prometheus.NewSummaryVec(
|
MHttpRequestSummary = prometheus.NewSummaryVec(
|
||||||
prometheus.SummaryOpts{
|
prometheus.SummaryOpts{
|
||||||
Name: "http_request_duration_milliseconds",
|
Name: "http_request_duration_milliseconds",
|
||||||
Help: "http request summary",
|
Help: "http request summary",
|
||||||
@ -119,121 +189,121 @@ func init() {
|
|||||||
[]string{"handler", "statuscode", "method"},
|
[]string{"handler", "statuscode", "method"},
|
||||||
)
|
)
|
||||||
|
|
||||||
M_Api_User_SignUpStarted = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiUserSignUpStarted = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_user_signup_started_total",
|
Name: "api_user_signup_started_total",
|
||||||
Help: "amount of users who started the signup flow",
|
Help: "amount of users who started the signup flow",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_User_SignUpCompleted = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiUserSignUpCompleted = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_user_signup_completed_total",
|
Name: "api_user_signup_completed_total",
|
||||||
Help: "amount of users who completed the signup flow",
|
Help: "amount of users who completed the signup flow",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_User_SignUpInvite = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiUserSignUpInvite = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_user_signup_invite_total",
|
Name: "api_user_signup_invite_total",
|
||||||
Help: "amount of users who have been invited",
|
Help: "amount of users who have been invited",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Dashboard_Save = prometheus.NewSummary(prometheus.SummaryOpts{
|
MApiDashboardSave = prometheus.NewSummary(prometheus.SummaryOpts{
|
||||||
Name: "api_dashboard_save_milliseconds",
|
Name: "api_dashboard_save_milliseconds",
|
||||||
Help: "summary for dashboard save duration",
|
Help: "summary for dashboard save duration",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Dashboard_Get = prometheus.NewSummary(prometheus.SummaryOpts{
|
MApiDashboardGet = prometheus.NewSummary(prometheus.SummaryOpts{
|
||||||
Name: "api_dashboard_get_milliseconds",
|
Name: "api_dashboard_get_milliseconds",
|
||||||
Help: "summary for dashboard get duration",
|
Help: "summary for dashboard get duration",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Dashboard_Search = prometheus.NewSummary(prometheus.SummaryOpts{
|
MApiDashboardSearch = prometheus.NewSummary(prometheus.SummaryOpts{
|
||||||
Name: "api_dashboard_search_milliseconds",
|
Name: "api_dashboard_search_milliseconds",
|
||||||
Help: "summary for dashboard search duration",
|
Help: "summary for dashboard search duration",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Admin_User_Create = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiAdminUserCreate = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_admin_user_created_total",
|
Name: "api_admin_user_created_total",
|
||||||
Help: "api admin user created counter",
|
Help: "api admin user created counter",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Login_Post = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiLoginPost = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_login_post_total",
|
Name: "api_login_post_total",
|
||||||
Help: "api login post counter",
|
Help: "api login post counter",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Login_OAuth = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiLoginOAuth = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_login_oauth_total",
|
Name: "api_login_oauth_total",
|
||||||
Help: "api login oauth counter",
|
Help: "api login oauth counter",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Org_Create = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiOrgCreate = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_org_create_total",
|
Name: "api_org_create_total",
|
||||||
Help: "api org created counter",
|
Help: "api org created counter",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Dashboard_Snapshot_Create = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiDashboardSnapshotCreate = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_dashboard_snapshot_create_total",
|
Name: "api_dashboard_snapshot_create_total",
|
||||||
Help: "dashboard snapshots created",
|
Help: "dashboard snapshots created",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Dashboard_Snapshot_External = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiDashboardSnapshotExternal = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_dashboard_snapshot_external_total",
|
Name: "api_dashboard_snapshot_external_total",
|
||||||
Help: "external dashboard snapshots created",
|
Help: "external dashboard snapshots created",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Dashboard_Snapshot_Get = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiDashboardSnapshotGet = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_dashboard_snapshot_get_total",
|
Name: "api_dashboard_snapshot_get_total",
|
||||||
Help: "loaded dashboards",
|
Help: "loaded dashboards",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Api_Dashboard_Insert = newCounterStartingAtZero(prometheus.CounterOpts{
|
MApiDashboardInsert = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "api_models_dashboard_insert_total",
|
Name: "api_models_dashboard_insert_total",
|
||||||
Help: "dashboards inserted ",
|
Help: "dashboards inserted ",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Alerting_Result_State = prometheus.NewCounterVec(prometheus.CounterOpts{
|
MAlertingResultState = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Name: "alerting_result_total",
|
Name: "alerting_result_total",
|
||||||
Help: "alert execution result counter",
|
Help: "alert execution result counter",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
}, []string{"state"})
|
}, []string{"state"})
|
||||||
|
|
||||||
M_Alerting_Notification_Sent = prometheus.NewCounterVec(prometheus.CounterOpts{
|
MAlertingNotificationSent = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Name: "alerting_notification_sent_total",
|
Name: "alerting_notification_sent_total",
|
||||||
Help: "counter for how many alert notifications been sent",
|
Help: "counter for how many alert notifications been sent",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
}, []string{"type"})
|
}, []string{"type"})
|
||||||
|
|
||||||
M_Aws_CloudWatch_GetMetricStatistics = newCounterStartingAtZero(prometheus.CounterOpts{
|
MAwsCloudWatchGetMetricStatistics = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "aws_cloudwatch_get_metric_statistics_total",
|
Name: "aws_cloudwatch_get_metric_statistics_total",
|
||||||
Help: "counter for getting metric statistics from aws",
|
Help: "counter for getting metric statistics from aws",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Aws_CloudWatch_ListMetrics = newCounterStartingAtZero(prometheus.CounterOpts{
|
MAwsCloudWatchListMetrics = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "aws_cloudwatch_list_metrics_total",
|
Name: "aws_cloudwatch_list_metrics_total",
|
||||||
Help: "counter for getting list of metrics from aws",
|
Help: "counter for getting list of metrics from aws",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Aws_CloudWatch_GetMetricData = newCounterStartingAtZero(prometheus.CounterOpts{
|
MAwsCloudWatchGetMetricData = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "aws_cloudwatch_get_metric_data_total",
|
Name: "aws_cloudwatch_get_metric_data_total",
|
||||||
Help: "counter for getting metric data time series from aws",
|
Help: "counter for getting metric data time series from aws",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_DB_DataSource_QueryById = newCounterStartingAtZero(prometheus.CounterOpts{
|
MDBDataSourceQueryByID = newCounterStartingAtZero(prometheus.CounterOpts{
|
||||||
Name: "db_datasource_query_by_id_total",
|
Name: "db_datasource_query_by_id_total",
|
||||||
Help: "counter for getting datasource by id",
|
Help: "counter for getting datasource by id",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
@ -245,49 +315,49 @@ func init() {
|
|||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_DataSource_ProxyReq_Timer = prometheus.NewSummary(prometheus.SummaryOpts{
|
MDataSourceProxyReqTimer = prometheus.NewSummary(prometheus.SummaryOpts{
|
||||||
Name: "api_dataproxy_request_all_milliseconds",
|
Name: "api_dataproxy_request_all_milliseconds",
|
||||||
Help: "summary for dataproxy request duration",
|
Help: "summary for dataproxy request duration",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Alerting_Execution_Time = prometheus.NewSummary(prometheus.SummaryOpts{
|
MAlertingExecutionTime = prometheus.NewSummary(prometheus.SummaryOpts{
|
||||||
Name: "alerting_execution_time_milliseconds",
|
Name: "alerting_execution_time_milliseconds",
|
||||||
Help: "summary of alert exeuction duration",
|
Help: "summary of alert exeuction duration",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Alerting_Active_Alerts = prometheus.NewGauge(prometheus.GaugeOpts{
|
MAlertingActiveAlerts = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "alerting_active_alerts",
|
Name: "alerting_active_alerts",
|
||||||
Help: "amount of active alerts",
|
Help: "amount of active alerts",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_StatTotal_Dashboards = prometheus.NewGauge(prometheus.GaugeOpts{
|
MStatTotalDashboards = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "stat_totals_dashboard",
|
Name: "stat_totals_dashboard",
|
||||||
Help: "total amount of dashboards",
|
Help: "total amount of dashboards",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_StatTotal_Users = prometheus.NewGauge(prometheus.GaugeOpts{
|
MStatTotalUsers = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "stat_total_users",
|
Name: "stat_total_users",
|
||||||
Help: "total amount of users",
|
Help: "total amount of users",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_StatActive_Users = prometheus.NewGauge(prometheus.GaugeOpts{
|
MStatActiveUsers = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "stat_active_users",
|
Name: "stat_active_users",
|
||||||
Help: "number of active users",
|
Help: "number of active users",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_StatTotal_Orgs = prometheus.NewGauge(prometheus.GaugeOpts{
|
MStatTotalOrgs = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "stat_total_orgs",
|
Name: "stat_total_orgs",
|
||||||
Help: "total amount of orgs",
|
Help: "total amount of orgs",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_StatTotal_Playlists = prometheus.NewGauge(prometheus.GaugeOpts{
|
MStatTotalPlaylists = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "stat_total_playlists",
|
Name: "stat_total_playlists",
|
||||||
Help: "total amount of playlists",
|
Help: "total amount of playlists",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
@ -329,72 +399,60 @@ func init() {
|
|||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
})
|
})
|
||||||
|
|
||||||
M_Grafana_Version = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
||||||
Name: "info",
|
|
||||||
Help: "Information about the Grafana. This metric is deprecated. please use `grafana_build_info`",
|
|
||||||
Namespace: exporterName,
|
|
||||||
}, []string{"version"})
|
|
||||||
|
|
||||||
grafanaBuildVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
grafanaBuildVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Name: "build_info",
|
Name: "build_info",
|
||||||
Help: "A metric with a constant '1' value labeled by version, revision, branch, and goversion from which Grafana was built.",
|
Help: "A metric with a constant '1' value labeled by version, revision, branch, and goversion from which Grafana was built",
|
||||||
Namespace: exporterName,
|
Namespace: exporterName,
|
||||||
}, []string{"version", "revision", "branch", "goversion", "edition"})
|
}, []string{"version", "revision", "branch", "goversion", "edition"})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetBuildInformation sets the build information for this binary
|
// SetBuildInformation sets the build information for this binary
|
||||||
func SetBuildInformation(version, revision, branch string) {
|
func SetBuildInformation(version, revision, branch string) {
|
||||||
// We export this info twice for backwards compatibility.
|
|
||||||
// Once this have been released for some time we should be able to remote `M_Grafana_Version`
|
|
||||||
// The reason we added a new one is that its common practice in the prometheus community
|
|
||||||
// to name this metric `*_build_info` so its easy to do aggregation on all programs.
|
|
||||||
edition := "oss"
|
edition := "oss"
|
||||||
if setting.IsEnterprise {
|
if setting.IsEnterprise {
|
||||||
edition = "enterprise"
|
edition = "enterprise"
|
||||||
}
|
}
|
||||||
|
|
||||||
M_Grafana_Version.WithLabelValues(version).Set(1)
|
|
||||||
grafanaBuildVersion.WithLabelValues(version, revision, branch, runtime.Version(), edition).Set(1)
|
grafanaBuildVersion.WithLabelValues(version, revision, branch, runtime.Version(), edition).Set(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initMetricVars() {
|
func initMetricVars() {
|
||||||
prometheus.MustRegister(
|
prometheus.MustRegister(
|
||||||
M_Instance_Start,
|
MInstanceStart,
|
||||||
M_Page_Status,
|
MPageStatus,
|
||||||
M_Api_Status,
|
MApiStatus,
|
||||||
M_Proxy_Status,
|
MProxyStatus,
|
||||||
M_Http_Request_Total,
|
MHttpRequestTotal,
|
||||||
M_Http_Request_Summary,
|
MHttpRequestSummary,
|
||||||
M_Api_User_SignUpStarted,
|
MApiUserSignUpStarted,
|
||||||
M_Api_User_SignUpCompleted,
|
MApiUserSignUpCompleted,
|
||||||
M_Api_User_SignUpInvite,
|
MApiUserSignUpInvite,
|
||||||
M_Api_Dashboard_Save,
|
MApiDashboardSave,
|
||||||
M_Api_Dashboard_Get,
|
MApiDashboardGet,
|
||||||
M_Api_Dashboard_Search,
|
MApiDashboardSearch,
|
||||||
M_DataSource_ProxyReq_Timer,
|
MDataSourceProxyReqTimer,
|
||||||
M_Alerting_Execution_Time,
|
MAlertingExecutionTime,
|
||||||
M_Api_Admin_User_Create,
|
MApiAdminUserCreate,
|
||||||
M_Api_Login_Post,
|
MApiLoginPost,
|
||||||
M_Api_Login_OAuth,
|
MApiLoginOAuth,
|
||||||
M_Api_Org_Create,
|
MApiOrgCreate,
|
||||||
M_Api_Dashboard_Snapshot_Create,
|
MApiDashboardSnapshotCreate,
|
||||||
M_Api_Dashboard_Snapshot_External,
|
MApiDashboardSnapshotExternal,
|
||||||
M_Api_Dashboard_Snapshot_Get,
|
MApiDashboardSnapshotGet,
|
||||||
M_Api_Dashboard_Insert,
|
MApiDashboardInsert,
|
||||||
M_Alerting_Result_State,
|
MAlertingResultState,
|
||||||
M_Alerting_Notification_Sent,
|
MAlertingNotificationSent,
|
||||||
M_Aws_CloudWatch_GetMetricStatistics,
|
MAwsCloudWatchGetMetricStatistics,
|
||||||
M_Aws_CloudWatch_ListMetrics,
|
MAwsCloudWatchListMetrics,
|
||||||
M_Aws_CloudWatch_GetMetricData,
|
MAwsCloudWatchGetMetricData,
|
||||||
M_DB_DataSource_QueryById,
|
MDBDataSourceQueryByID,
|
||||||
LDAPUsersSyncExecutionTime,
|
LDAPUsersSyncExecutionTime,
|
||||||
M_Alerting_Active_Alerts,
|
MAlertingActiveAlerts,
|
||||||
M_StatTotal_Dashboards,
|
MStatTotalDashboards,
|
||||||
M_StatTotal_Users,
|
MStatTotalUsers,
|
||||||
M_StatActive_Users,
|
MStatActiveUsers,
|
||||||
M_StatTotal_Orgs,
|
MStatTotalOrgs,
|
||||||
M_StatTotal_Playlists,
|
MStatTotalPlaylists,
|
||||||
M_Grafana_Version,
|
|
||||||
StatsTotalViewers,
|
StatsTotalViewers,
|
||||||
StatsTotalEditors,
|
StatsTotalEditors,
|
||||||
StatsTotalAdmins,
|
StatsTotalAdmins,
|
||||||
|
@ -46,7 +46,7 @@ func (im *InternalMetricsService) Run(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
M_Instance_Start.Inc()
|
MInstanceStart.Inc()
|
||||||
|
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
|
@ -161,11 +161,11 @@ func (uss *UsageStatsService) updateTotalStats() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.M_StatTotal_Dashboards.Set(float64(statsQuery.Result.Dashboards))
|
metrics.MStatTotalDashboards.Set(float64(statsQuery.Result.Dashboards))
|
||||||
metrics.M_StatTotal_Users.Set(float64(statsQuery.Result.Users))
|
metrics.MStatTotalUsers.Set(float64(statsQuery.Result.Users))
|
||||||
metrics.M_StatActive_Users.Set(float64(statsQuery.Result.ActiveUsers))
|
metrics.MStatActiveUsers.Set(float64(statsQuery.Result.ActiveUsers))
|
||||||
metrics.M_StatTotal_Playlists.Set(float64(statsQuery.Result.Playlists))
|
metrics.MStatTotalPlaylists.Set(float64(statsQuery.Result.Playlists))
|
||||||
metrics.M_StatTotal_Orgs.Set(float64(statsQuery.Result.Orgs))
|
metrics.MStatTotalOrgs.Set(float64(statsQuery.Result.Orgs))
|
||||||
metrics.StatsTotalViewers.Set(float64(statsQuery.Result.Viewers))
|
metrics.StatsTotalViewers.Set(float64(statsQuery.Result.Viewers))
|
||||||
metrics.StatsTotalActiveViewers.Set(float64(statsQuery.Result.ActiveViewers))
|
metrics.StatsTotalActiveViewers.Set(float64(statsQuery.Result.ActiveViewers))
|
||||||
metrics.StatsTotalEditors.Set(float64(statsQuery.Result.Editors))
|
metrics.StatsTotalEditors.Set(float64(statsQuery.Result.Editors))
|
||||||
|
@ -20,9 +20,9 @@ func RequestMetrics(handler string) macaron.Handler {
|
|||||||
|
|
||||||
code := sanitizeCode(status)
|
code := sanitizeCode(status)
|
||||||
method := sanitizeMethod(req.Method)
|
method := sanitizeMethod(req.Method)
|
||||||
metrics.M_Http_Request_Total.WithLabelValues(handler, code, method).Inc()
|
metrics.MHttpRequestTotal.WithLabelValues(handler, code, method).Inc()
|
||||||
duration := time.Since(now).Nanoseconds() / int64(time.Millisecond)
|
duration := time.Since(now).Nanoseconds() / int64(time.Millisecond)
|
||||||
metrics.M_Http_Request_Summary.WithLabelValues(handler, code, method).Observe(float64(duration))
|
metrics.MHttpRequestSummary.WithLabelValues(handler, code, method).Observe(float64(duration))
|
||||||
|
|
||||||
if strings.HasPrefix(req.RequestURI, "/api/datasources/proxy") {
|
if strings.HasPrefix(req.RequestURI, "/api/datasources/proxy") {
|
||||||
countProxyRequests(status)
|
countProxyRequests(status)
|
||||||
@ -37,39 +37,39 @@ func RequestMetrics(handler string) macaron.Handler {
|
|||||||
func countApiRequests(status int) {
|
func countApiRequests(status int) {
|
||||||
switch status {
|
switch status {
|
||||||
case 200:
|
case 200:
|
||||||
metrics.M_Api_Status.WithLabelValues("200").Inc()
|
metrics.MApiStatus.WithLabelValues("200").Inc()
|
||||||
case 404:
|
case 404:
|
||||||
metrics.M_Api_Status.WithLabelValues("404").Inc()
|
metrics.MApiStatus.WithLabelValues("404").Inc()
|
||||||
case 500:
|
case 500:
|
||||||
metrics.M_Api_Status.WithLabelValues("500").Inc()
|
metrics.MApiStatus.WithLabelValues("500").Inc()
|
||||||
default:
|
default:
|
||||||
metrics.M_Api_Status.WithLabelValues("unknown").Inc()
|
metrics.MApiStatus.WithLabelValues("unknown").Inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func countPageRequests(status int) {
|
func countPageRequests(status int) {
|
||||||
switch status {
|
switch status {
|
||||||
case 200:
|
case 200:
|
||||||
metrics.M_Page_Status.WithLabelValues("200").Inc()
|
metrics.MPageStatus.WithLabelValues("200").Inc()
|
||||||
case 404:
|
case 404:
|
||||||
metrics.M_Page_Status.WithLabelValues("404").Inc()
|
metrics.MPageStatus.WithLabelValues("404").Inc()
|
||||||
case 500:
|
case 500:
|
||||||
metrics.M_Page_Status.WithLabelValues("500").Inc()
|
metrics.MPageStatus.WithLabelValues("500").Inc()
|
||||||
default:
|
default:
|
||||||
metrics.M_Page_Status.WithLabelValues("unknown").Inc()
|
metrics.MPageStatus.WithLabelValues("unknown").Inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func countProxyRequests(status int) {
|
func countProxyRequests(status int) {
|
||||||
switch status {
|
switch status {
|
||||||
case 200:
|
case 200:
|
||||||
metrics.M_Proxy_Status.WithLabelValues("200").Inc()
|
metrics.MProxyStatus.WithLabelValues("200").Inc()
|
||||||
case 404:
|
case 404:
|
||||||
metrics.M_Proxy_Status.WithLabelValues("400").Inc()
|
metrics.MProxyStatus.WithLabelValues("400").Inc()
|
||||||
case 500:
|
case 500:
|
||||||
metrics.M_Proxy_Status.WithLabelValues("500").Inc()
|
metrics.MProxyStatus.WithLabelValues("500").Inc()
|
||||||
default:
|
default:
|
||||||
metrics.M_Proxy_Status.WithLabelValues("unknown").Inc()
|
metrics.MProxyStatus.WithLabelValues("unknown").Inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,5 +70,5 @@ func (e *DefaultEvalHandler) Eval(context *EvalContext) {
|
|||||||
context.EndTime = time.Now()
|
context.EndTime = time.Now()
|
||||||
|
|
||||||
elapsedTime := context.EndTime.Sub(context.StartTime).Nanoseconds() / int64(time.Millisecond)
|
elapsedTime := context.EndTime.Sub(context.StartTime).Nanoseconds() / int64(time.Millisecond)
|
||||||
metrics.M_Alerting_Execution_Time.Observe(float64(elapsedTime))
|
metrics.MAlertingExecutionTime.Observe(float64(elapsedTime))
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func (n *notificationService) sendAndMarkAsComplete(evalContext *EvalContext, no
|
|||||||
notifier := notifierState.notifier
|
notifier := notifierState.notifier
|
||||||
|
|
||||||
n.log.Debug("Sending notification", "type", notifier.GetType(), "uid", notifier.GetNotifierUID(), "isDefault", notifier.GetIsDefault())
|
n.log.Debug("Sending notification", "type", notifier.GetType(), "uid", notifier.GetNotifierUID(), "isDefault", notifier.GetIsDefault())
|
||||||
metrics.M_Alerting_Notification_Sent.WithLabelValues(notifier.GetType()).Inc()
|
metrics.MAlertingNotificationSent.WithLabelValues(notifier.GetType()).Inc()
|
||||||
|
|
||||||
err := notifier.Notify(evalContext)
|
err := notifier.Notify(evalContext)
|
||||||
|
|
||||||
|
@ -43,6 +43,6 @@ func (arr *defaultRuleReader) fetch() []*Rule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.M_Alerting_Active_Alerts.Set(float64(len(res)))
|
metrics.MAlertingActiveAlerts.Set(float64(len(res)))
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func (handler *defaultResultHandler) handle(evalContext *EvalContext) error {
|
|||||||
annotationData.Set("noData", true)
|
annotationData.Set("noData", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.M_Alerting_Result_State.WithLabelValues(string(evalContext.Rule.State)).Inc()
|
metrics.MAlertingResultState.WithLabelValues(string(evalContext.Rule.State)).Inc()
|
||||||
if evalContext.shouldUpdateAlertState() {
|
if evalContext.shouldUpdateAlertState() {
|
||||||
handler.log.Info("New state change", "alertId", evalContext.Rule.ID, "newState", evalContext.Rule.State, "prev state", evalContext.PrevAlertState)
|
handler.log.Info("New state change", "alertId", evalContext.Rule.ID, "newState", evalContext.Rule.State, "prev state", evalContext.PrevAlertState)
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ func saveDashboard(sess *DBSession, cmd *m.SaveDashboardCommand) error {
|
|||||||
dash.CreatedBy = userId
|
dash.CreatedBy = userId
|
||||||
dash.Updated = time.Now()
|
dash.Updated = time.Now()
|
||||||
dash.UpdatedBy = userId
|
dash.UpdatedBy = userId
|
||||||
metrics.M_Api_Dashboard_Insert.Inc()
|
metrics.MApiDashboardInsert.Inc()
|
||||||
affectedRows, err = sess.Insert(dash)
|
affectedRows, err = sess.Insert(dash)
|
||||||
} else {
|
} else {
|
||||||
dash.SetVersion(dash.Version + 1)
|
dash.SetVersion(dash.Version + 1)
|
||||||
|
@ -25,7 +25,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetDataSourceById(query *m.GetDataSourceByIdQuery) error {
|
func GetDataSourceById(query *m.GetDataSourceByIdQuery) error {
|
||||||
metrics.M_DB_DataSource_QueryById.Inc()
|
metrics.MDBDataSourceQueryByID.Inc()
|
||||||
|
|
||||||
datasource := m.DataSource{OrgId: query.OrgId, Id: query.Id}
|
datasource := m.DataSource{OrgId: query.OrgId, Id: query.Id}
|
||||||
has, err := x.Get(&datasource)
|
has, err := x.Get(&datasource)
|
||||||
|
@ -37,7 +37,7 @@ func (e *CloudWatchExecutor) executeGetMetricDataQuery(ctx context.Context, regi
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return queryResponses, err
|
return queryResponses, err
|
||||||
}
|
}
|
||||||
metrics.M_Aws_CloudWatch_GetMetricData.Add(float64(len(params.MetricDataQueries)))
|
metrics.MAwsCloudWatchGetMetricData.Add(float64(len(params.MetricDataQueries)))
|
||||||
|
|
||||||
for _, r := range resp.MetricDataResults {
|
for _, r := range resp.MetricDataResults {
|
||||||
if _, ok := mdr[*r.Id]; !ok {
|
if _, ok := mdr[*r.Id]; !ok {
|
||||||
|
@ -81,7 +81,7 @@ func (e *CloudWatchExecutor) executeQuery(ctx context.Context, query *CloudWatch
|
|||||||
resp = partResp
|
resp = partResp
|
||||||
|
|
||||||
}
|
}
|
||||||
metrics.M_Aws_CloudWatch_GetMetricStatistics.Inc()
|
metrics.MAwsCloudWatchGetMetricStatistics.Inc()
|
||||||
}
|
}
|
||||||
|
|
||||||
queryRes, err := parseResponse(resp, query)
|
queryRes, err := parseResponse(resp, query)
|
||||||
|
@ -642,7 +642,7 @@ func (e *CloudWatchExecutor) cloudwatchListMetrics(region string, namespace stri
|
|||||||
var resp cloudwatch.ListMetricsOutput
|
var resp cloudwatch.ListMetricsOutput
|
||||||
err = svc.ListMetricsPages(params,
|
err = svc.ListMetricsPages(params,
|
||||||
func(page *cloudwatch.ListMetricsOutput, lastPage bool) bool {
|
func(page *cloudwatch.ListMetricsOutput, lastPage bool) bool {
|
||||||
metrics.M_Aws_CloudWatch_ListMetrics.Inc()
|
metrics.MAwsCloudWatchListMetrics.Inc()
|
||||||
metrics, _ := awsutil.ValuesAtPath(page, "Metrics")
|
metrics, _ := awsutil.ValuesAtPath(page, "Metrics")
|
||||||
for _, metric := range metrics {
|
for _, metric := range metrics {
|
||||||
resp.Metrics = append(resp.Metrics, metric.(*cloudwatch.Metric))
|
resp.Metrics = append(resp.Metrics, metric.(*cloudwatch.Metric))
|
||||||
@ -722,7 +722,7 @@ func getAllMetrics(cwData *DatasourceInfo) (cloudwatch.ListMetricsOutput, error)
|
|||||||
var resp cloudwatch.ListMetricsOutput
|
var resp cloudwatch.ListMetricsOutput
|
||||||
err = svc.ListMetricsPages(params,
|
err = svc.ListMetricsPages(params,
|
||||||
func(page *cloudwatch.ListMetricsOutput, lastPage bool) bool {
|
func(page *cloudwatch.ListMetricsOutput, lastPage bool) bool {
|
||||||
metrics.M_Aws_CloudWatch_ListMetrics.Inc()
|
metrics.MAwsCloudWatchListMetrics.Inc()
|
||||||
metrics, _ := awsutil.ValuesAtPath(page, "Metrics")
|
metrics, _ := awsutil.ValuesAtPath(page, "Metrics")
|
||||||
for _, metric := range metrics {
|
for _, metric := range metrics {
|
||||||
resp.Metrics = append(resp.Metrics, metric.(*cloudwatch.Metric))
|
resp.Metrics = append(resp.Metrics, metric.(*cloudwatch.Metric))
|
||||||
|
Loading…
Reference in New Issue
Block a user