fix: report metrics to prometheus

This commit is contained in:
徐聪
2022-07-25 21:31:10 +08:00
parent df5e985e2f
commit 6818d2cd43
4 changed files with 12 additions and 32 deletions
+5 -4
View File
@@ -475,7 +475,8 @@ type PrometheusPusherOutput struct {
// OnStart will register all prometheus metric collectors
func (o *PrometheusPusherOutput) OnStart() {
o.reset()
// reset all prometheus metrics
resetPrometheusMetrics()
log.Info().Msg("register prometheus metric collectors")
registry := prometheus.NewRegistry()
registry.MustRegister(
@@ -608,9 +609,9 @@ func (o *PrometheusPusherOutput) OnEvent(data map[string]interface{}) {
}
}
// reset will reset all metrics
func (o *PrometheusPusherOutput) reset() {
log.Info().Msg("reset metrics")
// resetPrometheusMetrics will reset all metrics
func resetPrometheusMetrics() {
log.Info().Msg("reset all prometheus metrics")
gaugeNumRequests.Reset()
gaugeNumFailures.Reset()
gaugeMedianResponseTime.Reset()