mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 11:44:26 -06:00
d42a5b2561
* FrontendMetrics: Adds new backend api that frontend can use to push frontend measurements and counters to prometheus * FrontendMetrics: Adds new backend api that frontend can use to push frontend measurements and counters to prometheus * Fix naming * change to histogram * Fixed go lint
22 lines
579 B
Go
22 lines
579 B
Go
package api
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
"github.com/grafana/grafana/pkg/infra/metrics"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
func (hs *HTTPServer) PostFrontendMetrics(c *models.ReqContext, cmd metrics.PostFrontendMetricsCommand) response.Response {
|
|
for _, event := range cmd.Events {
|
|
name := strings.Replace(event.Name, "-", "_", -1)
|
|
if recorder, ok := metrics.FrontendMetrics[name]; ok {
|
|
recorder(event)
|
|
} else {
|
|
c.Logger.Debug("Received unknown frontend metric", "metric", name)
|
|
}
|
|
}
|
|
return response.Empty(200)
|
|
}
|