Browse Source

Metrics: add LDAP active sync summary metric (#18079)

Oleg Gaidarenko 6 years ago
parent
commit
09eb9a45ce
2 changed files with 15 additions and 2 deletions
  1. 2 1
      pkg/api/http_server.go
  2. 13 1
      pkg/infra/metrics/metrics.go

+ 2 - 1
pkg/api/http_server.go

@@ -269,7 +269,8 @@ func (hs *HTTPServer) metricsEndpoint(ctx *macaron.Context) {
 		return
 	}
 
-	promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}).
+	promhttp.
+		HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}).
 		ServeHTTP(ctx.Resp, ctx.Req.Request)
 }
 

+ 13 - 1
pkg/infra/metrics/metrics.go

@@ -40,6 +40,10 @@ var (
 	M_Aws_CloudWatch_GetMetricData       prometheus.Counter
 	M_DB_DataSource_QueryById            prometheus.Counter
 
+	// LDAPUsersSyncExecutionTime is a metric for
+	// how much time it took to sync the LDAP users
+	LDAPUsersSyncExecutionTime prometheus.Summary
+
 	// Timers
 	M_DataSource_ProxyReq_Timer prometheus.Summary
 	M_Alerting_Execution_Time   prometheus.Summary
@@ -235,6 +239,12 @@ func init() {
 		Namespace: exporterName,
 	})
 
+	LDAPUsersSyncExecutionTime = prometheus.NewSummary(prometheus.SummaryOpts{
+		Name:      "ldap_users_sync_execution_time",
+		Help:      "summary for LDAP users sync execution duration",
+		Namespace: exporterName,
+	})
+
 	M_DataSource_ProxyReq_Timer = prometheus.NewSummary(prometheus.SummaryOpts{
 		Name:      "api_dataproxy_request_all_milliseconds",
 		Help:      "summary for dataproxy request duration",
@@ -377,6 +387,7 @@ func initMetricVars() {
 		M_Aws_CloudWatch_ListMetrics,
 		M_Aws_CloudWatch_GetMetricData,
 		M_DB_DataSource_QueryById,
+		LDAPUsersSyncExecutionTime,
 		M_Alerting_Active_Alerts,
 		M_StatTotal_Dashboards,
 		M_StatTotal_Users,
@@ -390,7 +401,8 @@ func initMetricVars() {
 		StatsTotalActiveViewers,
 		StatsTotalActiveEditors,
 		StatsTotalActiveAdmins,
-		grafanaBuildVersion)
+		grafanaBuildVersion,
+	)
 
 }