Commit 491e6897 by bergquist

metrics: set summary unit

we have to use milleseconds since graphite
doesnt support float64
parent 5b74bea4
...@@ -102,7 +102,7 @@ func init() { ...@@ -102,7 +102,7 @@ func init() {
M_Http_Request_Summary = prometheus.NewSummaryVec( M_Http_Request_Summary = prometheus.NewSummaryVec(
prometheus.SummaryOpts{ prometheus.SummaryOpts{
Name: "http_request_duration", Name: "http_request_duration_milleseconds",
Help: "http request summary", Help: "http request summary",
}, },
[]string{"handler", "statuscode", "method"}, []string{"handler", "statuscode", "method"},
...@@ -127,19 +127,19 @@ func init() { ...@@ -127,19 +127,19 @@ func init() {
}) })
M_Api_Dashboard_Save = prometheus.NewSummary(prometheus.SummaryOpts{ M_Api_Dashboard_Save = prometheus.NewSummary(prometheus.SummaryOpts{
Name: "api_dashboard_save", Name: "api_dashboard_save_milleseconds",
Help: "summary for dashboard save duration", Help: "summary for dashboard save duration",
Namespace: exporterName, Namespace: exporterName,
}) })
M_Api_Dashboard_Get = prometheus.NewSummary(prometheus.SummaryOpts{ M_Api_Dashboard_Get = prometheus.NewSummary(prometheus.SummaryOpts{
Name: "api_dashboard_get", Name: "api_dashboard_get_milleseconds",
Help: "summary for dashboard get duration", Help: "summary for dashboard get duration",
Namespace: exporterName, Namespace: exporterName,
}) })
M_Api_Dashboard_Search = prometheus.NewSummary(prometheus.SummaryOpts{ M_Api_Dashboard_Search = prometheus.NewSummary(prometheus.SummaryOpts{
Name: "api_dashboard_search", Name: "api_dashboard_search_milleseconds",
Help: "summary for dashboard search duration", Help: "summary for dashboard search duration",
Namespace: exporterName, Namespace: exporterName,
}) })
...@@ -223,13 +223,13 @@ func init() { ...@@ -223,13 +223,13 @@ func init() {
}) })
M_DataSource_ProxyReq_Timer = prometheus.NewSummary(prometheus.SummaryOpts{ M_DataSource_ProxyReq_Timer = prometheus.NewSummary(prometheus.SummaryOpts{
Name: "api_dataproxy_request_all", Name: "api_dataproxy_request_all_milleseconds",
Help: "summary for dashboard search duration", Help: "summary for dashboard search duration",
Namespace: exporterName, Namespace: exporterName,
}) })
M_Alerting_Execution_Time = prometheus.NewSummary(prometheus.SummaryOpts{ M_Alerting_Execution_Time = prometheus.NewSummary(prometheus.SummaryOpts{
Name: "alerting_execution_time_seconds", Name: "alerting_execution_time_milliseconds",
Help: "summary of alert exeuction duration", Help: "summary of alert exeuction duration",
Namespace: exporterName, Namespace: exporterName,
}) })
......
...@@ -21,7 +21,8 @@ func RequestMetrics(handler string) macaron.Handler { ...@@ -21,7 +21,8 @@ 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.M_Http_Request_Total.WithLabelValues(handler, code, method).Inc()
metrics.M_Http_Request_Summary.WithLabelValues(handler, code, method).Observe(time.Since(now).Seconds()) duration := time.Since(now).Nanoseconds() / int64(time.Millisecond)
metrics.M_Http_Request_Summary.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)
......
...@@ -63,8 +63,8 @@ func (e *DefaultEvalHandler) Eval(context *EvalContext) { ...@@ -63,8 +63,8 @@ func (e *DefaultEvalHandler) Eval(context *EvalContext) {
context.EndTime = time.Now() context.EndTime = time.Now()
context.Rule.State = e.getNewState(context) context.Rule.State = e.getNewState(context)
elapsedTime := context.EndTime.Sub(context.StartTime).Seconds() elapsedTime := context.EndTime.Sub(context.StartTime).Nanoseconds() / int64(time.Millisecond)
metrics.M_Alerting_Execution_Time.Observe(elapsedTime) metrics.M_Alerting_Execution_Time.Observe(float64(elapsedTime))
} }
// This should be move into evalContext once its been refactored. // This should be move into evalContext once its been refactored.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment