| 129 | } |
| 130 | |
| 131 | func (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 | |
| 154 | func (api *API) status(w http.ResponseWriter, r *http.Request) { |
| 155 | res := map[string]any{} |