Introduce new unauthenticated endpoint /metric (#5723) (#5829)

/metric exposes Promethus compatible data for scraping metrics

Fixes: #5723
This commit is contained in:
Ashish Kumar Sinha
2018-04-19 04:31:42 +05:30
committed by Harshavardhana
parent 9f31da5d57
commit 9ebb72aa99
92 changed files with 17886 additions and 1 deletions

View File

@@ -21,6 +21,8 @@ import (
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
)
@@ -188,6 +190,10 @@ func (st *HTTPStats) updateStats(r *http.Request, w *httpResponseRecorder, durat
st.successDELETEs.Duration.Add(durationSecs)
}
}
// Increment the prometheus http request count with appropriate label
httpRequests.With(prometheus.Labels{"request_type": r.Method}).Inc()
// Increment the prometheus http request response histogram with appropriate label
httpRequestsDuration.With(prometheus.Labels{"request_type": r.Method}).Observe(durationSecs)
}
// Prepare new HTTPStats structure