2015-03-22 14:14:00 -05:00
|
|
|
package metrics
|
|
|
|
|
2017-09-05 16:19:57 -05:00
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
|
2019-02-11 08:42:12 -06:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
|
2017-09-06 04:23:52 -05:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
2017-09-05 16:19:57 -05:00
|
|
|
)
|
2015-03-22 14:14:00 -05:00
|
|
|
|
2017-09-13 11:19:16 -05:00
|
|
|
const exporterName = "grafana"
|
|
|
|
|
2015-03-22 14:14:00 -05:00
|
|
|
var (
|
2017-09-06 15:24:10 -05:00
|
|
|
M_Instance_Start prometheus.Counter
|
|
|
|
M_Page_Status *prometheus.CounterVec
|
|
|
|
M_Api_Status *prometheus.CounterVec
|
|
|
|
M_Proxy_Status *prometheus.CounterVec
|
|
|
|
M_Http_Request_Total *prometheus.CounterVec
|
|
|
|
M_Http_Request_Summary *prometheus.SummaryVec
|
2017-09-06 04:23:52 -05:00
|
|
|
|
|
|
|
M_Api_User_SignUpStarted prometheus.Counter
|
|
|
|
M_Api_User_SignUpCompleted prometheus.Counter
|
|
|
|
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
|
|
|
|
M_Api_Dashboard_Snapshot_External prometheus.Counter
|
|
|
|
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
|
2018-04-16 02:50:13 -05:00
|
|
|
M_Aws_CloudWatch_GetMetricData prometheus.Counter
|
2017-09-06 04:23:52 -05:00
|
|
|
M_DB_DataSource_QueryById prometheus.Counter
|
2016-06-03 05:50:51 -05:00
|
|
|
|
2019-07-15 00:33:48 -05:00
|
|
|
// LDAPUsersSyncExecutionTime is a metric for
|
|
|
|
// how much time it took to sync the LDAP users
|
|
|
|
LDAPUsersSyncExecutionTime prometheus.Summary
|
|
|
|
|
2016-06-03 05:50:51 -05:00
|
|
|
// Timers
|
2017-09-06 04:23:52 -05:00
|
|
|
M_DataSource_ProxyReq_Timer prometheus.Summary
|
|
|
|
M_Alerting_Execution_Time prometheus.Summary
|
2019-06-06 09:39:35 -05:00
|
|
|
)
|
2016-09-22 04:16:19 -05:00
|
|
|
|
2019-06-06 09:39:35 -05:00
|
|
|
// StatTotals
|
|
|
|
var (
|
2017-09-06 04:23:52 -05:00
|
|
|
M_Alerting_Active_Alerts prometheus.Gauge
|
|
|
|
M_StatTotal_Dashboards prometheus.Gauge
|
|
|
|
M_StatTotal_Users prometheus.Gauge
|
2018-04-17 03:20:01 -05:00
|
|
|
M_StatActive_Users prometheus.Gauge
|
2017-09-06 04:23:52 -05:00
|
|
|
M_StatTotal_Orgs prometheus.Gauge
|
|
|
|
M_StatTotal_Playlists prometheus.Gauge
|
2018-10-30 05:18:43 -05:00
|
|
|
|
2019-06-06 09:39:35 -05:00
|
|
|
StatsTotalViewers prometheus.Gauge
|
|
|
|
StatsTotalEditors prometheus.Gauge
|
|
|
|
StatsTotalAdmins prometheus.Gauge
|
|
|
|
StatsTotalActiveViewers prometheus.Gauge
|
|
|
|
StatsTotalActiveEditors prometheus.Gauge
|
|
|
|
StatsTotalActiveAdmins prometheus.Gauge
|
|
|
|
|
2018-10-30 05:18:43 -05:00
|
|
|
// M_Grafana_Version is a gauge that contains build info about this binary
|
|
|
|
//
|
|
|
|
// Deprecated: use M_Grafana_Build_Version instead.
|
|
|
|
M_Grafana_Version *prometheus.GaugeVec
|
|
|
|
|
|
|
|
// grafanaBuildVersion is a gauge that contains build info about this binary
|
|
|
|
grafanaBuildVersion *prometheus.GaugeVec
|
2016-06-03 05:50:51 -05:00
|
|
|
)
|
2015-03-22 14:14:00 -05:00
|
|
|
|
2017-09-06 04:23:52 -05:00
|
|
|
func init() {
|
|
|
|
M_Instance_Start = prometheus.NewCounter(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "instance_start_total",
|
|
|
|
Help: "counter for started instances",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
httpStatusCodes := []string{"200", "404", "500", "unknown"}
|
|
|
|
M_Page_Status = newCounterVecStartingAtZero(
|
2017-09-06 04:23:52 -05:00
|
|
|
prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "page_response_status_total",
|
|
|
|
Help: "page http response status",
|
|
|
|
Namespace: exporterName,
|
2018-09-14 00:46:04 -05:00
|
|
|
}, []string{"code"}, httpStatusCodes...)
|
2017-09-06 04:23:52 -05:00
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Status = newCounterVecStartingAtZero(
|
2017-09-06 04:23:52 -05:00
|
|
|
prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_response_status_total",
|
|
|
|
Help: "api http response status",
|
|
|
|
Namespace: exporterName,
|
2018-09-14 00:46:04 -05:00
|
|
|
}, []string{"code"}, httpStatusCodes...)
|
2017-09-06 04:23:52 -05:00
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Proxy_Status = newCounterVecStartingAtZero(
|
2017-09-06 04:23:52 -05:00
|
|
|
prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "proxy_response_status_total",
|
|
|
|
Help: "proxy http response status",
|
|
|
|
Namespace: exporterName,
|
2018-09-14 00:46:04 -05:00
|
|
|
}, []string{"code"}, httpStatusCodes...)
|
2017-09-06 04:23:52 -05:00
|
|
|
|
2017-09-06 15:24:10 -05:00
|
|
|
M_Http_Request_Total = prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Name: "http_request_total",
|
|
|
|
Help: "http request counter",
|
|
|
|
},
|
2017-09-13 08:18:52 -05:00
|
|
|
[]string{"handler", "statuscode", "method"},
|
2017-09-06 15:24:10 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
M_Http_Request_Summary = prometheus.NewSummaryVec(
|
|
|
|
prometheus.SummaryOpts{
|
2017-09-18 17:56:17 -05:00
|
|
|
Name: "http_request_duration_milliseconds",
|
2017-09-06 15:24:10 -05:00
|
|
|
Help: "http request summary",
|
|
|
|
},
|
2017-09-13 08:18:52 -05:00
|
|
|
[]string{"handler", "statuscode", "method"},
|
2017-09-06 15:24:10 -05:00
|
|
|
)
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_User_SignUpStarted = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_user_signup_started_total",
|
|
|
|
Help: "amount of users who started the signup flow",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_User_SignUpCompleted = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_user_signup_completed_total",
|
|
|
|
Help: "amount of users who completed the signup flow",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_User_SignUpInvite = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_user_signup_invite_total",
|
|
|
|
Help: "amount of users who have been invited",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
M_Api_Dashboard_Save = prometheus.NewSummary(prometheus.SummaryOpts{
|
2017-09-18 17:56:17 -05:00
|
|
|
Name: "api_dashboard_save_milliseconds",
|
2017-09-13 11:19:16 -05:00
|
|
|
Help: "summary for dashboard save duration",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
M_Api_Dashboard_Get = prometheus.NewSummary(prometheus.SummaryOpts{
|
2017-09-18 17:56:17 -05:00
|
|
|
Name: "api_dashboard_get_milliseconds",
|
2017-09-13 11:19:16 -05:00
|
|
|
Help: "summary for dashboard get duration",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
M_Api_Dashboard_Search = prometheus.NewSummary(prometheus.SummaryOpts{
|
2017-09-18 17:56:17 -05:00
|
|
|
Name: "api_dashboard_search_milliseconds",
|
2017-09-13 11:19:16 -05:00
|
|
|
Help: "summary for dashboard search duration",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Admin_User_Create = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_admin_user_created_total",
|
|
|
|
Help: "api admin user created counter",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
2017-09-13 11:19:16 -05:00
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Login_Post = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_login_post_total",
|
|
|
|
Help: "api login post counter",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
2017-09-13 11:19:16 -05:00
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Login_OAuth = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_login_oauth_total",
|
|
|
|
Help: "api login oauth counter",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
2017-09-13 11:19:16 -05:00
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Org_Create = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_org_create_total",
|
|
|
|
Help: "api org created counter",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Dashboard_Snapshot_Create = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_dashboard_snapshot_create_total",
|
|
|
|
Help: "dashboard snapshots created",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
2017-09-13 11:19:16 -05:00
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Dashboard_Snapshot_External = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_dashboard_snapshot_external_total",
|
|
|
|
Help: "external dashboard snapshots created",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
2017-09-13 11:19:16 -05:00
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Dashboard_Snapshot_Get = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_dashboard_snapshot_get_total",
|
|
|
|
Help: "loaded dashboards",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Api_Dashboard_Insert = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "api_models_dashboard_insert_total",
|
|
|
|
Help: "dashboards inserted ",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
M_Alerting_Result_State = prometheus.NewCounterVec(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "alerting_result_total",
|
|
|
|
Help: "alert execution result counter",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
}, []string{"state"})
|
|
|
|
|
|
|
|
M_Alerting_Notification_Sent = prometheus.NewCounterVec(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "alerting_notification_sent_total",
|
|
|
|
Help: "counter for how many alert notifications been sent",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
}, []string{"type"})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Aws_CloudWatch_GetMetricStatistics = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "aws_cloudwatch_get_metric_statistics_total",
|
|
|
|
Help: "counter for getting metric statistics from aws",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Aws_CloudWatch_ListMetrics = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "aws_cloudwatch_list_metrics_total",
|
|
|
|
Help: "counter for getting list of metrics from aws",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_Aws_CloudWatch_GetMetricData = newCounterStartingAtZero(prometheus.CounterOpts{
|
2018-04-16 02:50:13 -05:00
|
|
|
Name: "aws_cloudwatch_get_metric_data_total",
|
|
|
|
Help: "counter for getting metric data time series from aws",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
2018-09-14 00:46:04 -05:00
|
|
|
M_DB_DataSource_QueryById = newCounterStartingAtZero(prometheus.CounterOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "db_datasource_query_by_id_total",
|
|
|
|
Help: "counter for getting datasource by id",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2019-07-15 00:33:48 -05:00
|
|
|
LDAPUsersSyncExecutionTime = prometheus.NewSummary(prometheus.SummaryOpts{
|
|
|
|
Name: "ldap_users_sync_execution_time",
|
|
|
|
Help: "summary for LDAP users sync execution duration",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
2017-09-06 04:23:52 -05:00
|
|
|
M_DataSource_ProxyReq_Timer = prometheus.NewSummary(prometheus.SummaryOpts{
|
2017-09-18 17:56:17 -05:00
|
|
|
Name: "api_dataproxy_request_all_milliseconds",
|
2017-10-30 06:50:57 -05:00
|
|
|
Help: "summary for dataproxy request duration",
|
2017-09-13 11:19:16 -05:00
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
2017-09-13 11:19:16 -05:00
|
|
|
|
2017-09-06 04:23:52 -05:00
|
|
|
M_Alerting_Execution_Time = prometheus.NewSummary(prometheus.SummaryOpts{
|
2017-09-14 12:28:54 -05:00
|
|
|
Name: "alerting_execution_time_milliseconds",
|
2017-09-13 11:19:16 -05:00
|
|
|
Help: "summary of alert exeuction duration",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
M_Alerting_Active_Alerts = prometheus.NewGauge(prometheus.GaugeOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "alerting_active_alerts",
|
|
|
|
Help: "amount of active alerts",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
M_StatTotal_Dashboards = prometheus.NewGauge(prometheus.GaugeOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "stat_totals_dashboard",
|
|
|
|
Help: "total amount of dashboards",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
M_StatTotal_Users = prometheus.NewGauge(prometheus.GaugeOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "stat_total_users",
|
|
|
|
Help: "total amount of users",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
2018-04-17 03:20:01 -05:00
|
|
|
M_StatActive_Users = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Name: "stat_active_users",
|
|
|
|
Help: "number of active users",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
2017-09-06 04:23:52 -05:00
|
|
|
M_StatTotal_Orgs = prometheus.NewGauge(prometheus.GaugeOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "stat_total_orgs",
|
|
|
|
Help: "total amount of orgs",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
M_StatTotal_Playlists = prometheus.NewGauge(prometheus.GaugeOpts{
|
2017-09-13 11:19:16 -05:00
|
|
|
Name: "stat_total_playlists",
|
|
|
|
Help: "total amount of playlists",
|
|
|
|
Namespace: exporterName,
|
2017-09-06 04:23:52 -05:00
|
|
|
})
|
2017-09-26 08:25:44 -05:00
|
|
|
|
2019-06-06 09:39:35 -05:00
|
|
|
StatsTotalViewers = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Name: "stat_totals_viewers",
|
|
|
|
Help: "total amount of viewers",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
|
|
|
StatsTotalEditors = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Name: "stat_totals_editors",
|
|
|
|
Help: "total amount of editors",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
|
|
|
StatsTotalAdmins = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Name: "stat_totals_admins",
|
|
|
|
Help: "total amount of admins",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
|
|
|
StatsTotalActiveViewers = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Name: "stat_totals_active_viewers",
|
|
|
|
Help: "total amount of viewers",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
|
|
|
StatsTotalActiveEditors = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Name: "stat_totals_active_editors",
|
|
|
|
Help: "total amount of active editors",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
|
|
|
StatsTotalActiveAdmins = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
|
|
Name: "stat_totals_active_admins",
|
|
|
|
Help: "total amount of active admins",
|
|
|
|
Namespace: exporterName,
|
|
|
|
})
|
|
|
|
|
2017-09-26 08:25:44 -05:00
|
|
|
M_Grafana_Version = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
|
Name: "info",
|
2018-10-30 05:18:43 -05:00
|
|
|
Help: "Information about the Grafana. This metric is deprecated. please use `grafana_build_info`",
|
2017-09-26 08:25:44 -05:00
|
|
|
Namespace: exporterName,
|
|
|
|
}, []string{"version"})
|
2018-10-30 05:18:43 -05:00
|
|
|
|
|
|
|
grafanaBuildVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
|
|
|
Name: "build_info",
|
|
|
|
Help: "A metric with a constant '1' value labeled by version, revision, branch, and goversion from which Grafana was built.",
|
|
|
|
Namespace: exporterName,
|
2019-02-11 08:42:12 -06:00
|
|
|
}, []string{"version", "revision", "branch", "goversion", "edition"})
|
2018-10-30 05:18:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetBuildInformation sets the build information for this binary
|
|
|
|
func SetBuildInformation(version, revision, branch string) {
|
2018-11-15 07:42:09 -06:00
|
|
|
// We export this info twice for backwards compatibility.
|
2018-10-30 05:18:43 -05:00
|
|
|
// 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.
|
2019-02-11 08:42:12 -06:00
|
|
|
edition := "oss"
|
|
|
|
if setting.IsEnterprise {
|
|
|
|
edition = "enterprise"
|
|
|
|
}
|
|
|
|
|
2018-10-30 05:18:43 -05:00
|
|
|
M_Grafana_Version.WithLabelValues(version).Set(1)
|
2019-02-11 08:42:12 -06:00
|
|
|
grafanaBuildVersion.WithLabelValues(version, revision, branch, runtime.Version(), edition).Set(1)
|
2017-09-06 04:23:52 -05:00
|
|
|
}
|
2016-09-22 04:16:19 -05:00
|
|
|
|
2018-05-02 12:54:07 -05:00
|
|
|
func initMetricVars() {
|
2017-09-06 04:23:52 -05:00
|
|
|
prometheus.MustRegister(
|
|
|
|
M_Instance_Start,
|
|
|
|
M_Page_Status,
|
|
|
|
M_Api_Status,
|
2017-09-06 15:24:10 -05:00
|
|
|
M_Proxy_Status,
|
|
|
|
M_Http_Request_Total,
|
|
|
|
M_Http_Request_Summary,
|
2017-09-06 04:23:52 -05:00
|
|
|
M_Api_User_SignUpStarted,
|
|
|
|
M_Api_User_SignUpCompleted,
|
|
|
|
M_Api_User_SignUpInvite,
|
|
|
|
M_Api_Dashboard_Save,
|
|
|
|
M_Api_Dashboard_Get,
|
|
|
|
M_Api_Dashboard_Search,
|
|
|
|
M_DataSource_ProxyReq_Timer,
|
|
|
|
M_Alerting_Execution_Time,
|
|
|
|
M_Api_Admin_User_Create,
|
|
|
|
M_Api_Login_Post,
|
|
|
|
M_Api_Login_OAuth,
|
|
|
|
M_Api_Org_Create,
|
|
|
|
M_Api_Dashboard_Snapshot_Create,
|
|
|
|
M_Api_Dashboard_Snapshot_External,
|
|
|
|
M_Api_Dashboard_Snapshot_Get,
|
|
|
|
M_Api_Dashboard_Insert,
|
|
|
|
M_Alerting_Result_State,
|
|
|
|
M_Alerting_Notification_Sent,
|
|
|
|
M_Aws_CloudWatch_GetMetricStatistics,
|
|
|
|
M_Aws_CloudWatch_ListMetrics,
|
2018-04-16 02:50:13 -05:00
|
|
|
M_Aws_CloudWatch_GetMetricData,
|
2017-09-06 04:23:52 -05:00
|
|
|
M_DB_DataSource_QueryById,
|
2019-07-15 00:33:48 -05:00
|
|
|
LDAPUsersSyncExecutionTime,
|
2017-09-06 04:23:52 -05:00
|
|
|
M_Alerting_Active_Alerts,
|
|
|
|
M_StatTotal_Dashboards,
|
|
|
|
M_StatTotal_Users,
|
2018-04-17 03:20:01 -05:00
|
|
|
M_StatActive_Users,
|
2017-09-06 04:23:52 -05:00
|
|
|
M_StatTotal_Orgs,
|
2017-09-26 08:25:44 -05:00
|
|
|
M_StatTotal_Playlists,
|
2018-10-30 05:18:43 -05:00
|
|
|
M_Grafana_Version,
|
2019-06-06 09:39:35 -05:00
|
|
|
StatsTotalViewers,
|
|
|
|
StatsTotalEditors,
|
|
|
|
StatsTotalAdmins,
|
|
|
|
StatsTotalActiveViewers,
|
|
|
|
StatsTotalActiveEditors,
|
|
|
|
StatsTotalActiveAdmins,
|
2019-07-15 00:33:48 -05:00
|
|
|
grafanaBuildVersion,
|
|
|
|
)
|
2017-09-05 16:19:57 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-02-07 06:13:01 -06:00
|
|
|
func newCounterVecStartingAtZero(opts prometheus.CounterOpts, labels []string, labelValues ...string) *prometheus.CounterVec {
|
|
|
|
counter := prometheus.NewCounterVec(opts, labels)
|
2018-09-12 12:27:21 -05:00
|
|
|
|
2019-02-07 06:13:01 -06:00
|
|
|
for _, label := range labelValues {
|
|
|
|
counter.WithLabelValues(label).Add(0)
|
2018-09-12 12:27:21 -05:00
|
|
|
}
|
|
|
|
|
2019-02-07 06:13:01 -06:00
|
|
|
return counter
|
|
|
|
}
|
2018-09-12 12:27:21 -05:00
|
|
|
|
2019-02-07 06:13:01 -06:00
|
|
|
func newCounterStartingAtZero(opts prometheus.CounterOpts, labelValues ...string) prometheus.Counter {
|
|
|
|
counter := prometheus.NewCounter(opts)
|
|
|
|
counter.Add(0)
|
2017-09-05 16:19:57 -05:00
|
|
|
|
2019-02-07 06:13:01 -06:00
|
|
|
return counter
|
2016-06-03 05:50:51 -05:00
|
|
|
}
|