MCPcopy
hub / github.com/prometheus/pushgateway / metrics

Method metrics

api/v1/api.go:131–152  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

129}
130
131func (api *API) metrics(w http.ResponseWriter, r *http.Request) {
132 familyMaps := api.MetricStore.GetMetricFamiliesMap()
133 res := []any{}
134 for _, v := range familyMaps {
135 metricResponse := map[string]any{}
136 metricResponse["labels"] = v.Labels
137 metricResponse["last_push_successful"] = v.LastPushSuccess()
138 for name, metricValues := range v.Metrics {
139 metricFamily := metricValues.GetMetricFamily()
140 uniqueMetrics := metrics{
141 Type: metricFamily.GetType().String(),
142 Help: metricFamily.GetHelp(),
143 Timestamp: metricValues.Timestamp,
144 Metrics: makeEncodableMetrics(metricFamily.GetMetric(), metricFamily.GetType()),
145 }
146 metricResponse[name] = uniqueMetrics
147 }
148 res = append(res, metricResponse)
149 }
150
151 api.respond(w, res)
152}
153
154func (api *API) status(w http.ResponseWriter, r *http.Request) {
155 res := map[string]any{}

Callers 1

TestMetricsAPIFunction · 0.80

Calls 5

respondMethod · 0.95
makeEncodableMetricsFunction · 0.85
LastPushSuccessMethod · 0.80
GetMetricFamilyMethod · 0.80
GetMetricFamiliesMapMethod · 0.65

Tested by 1

TestMetricsAPIFunction · 0.64