fix: report metrics to prometheus

This commit is contained in:
徐聪
2022-07-25 21:31:10 +08:00
parent 6a812c6374
commit 4784d16639
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()