MCPcopy
hub / github.com/prometheus/client_golang / LabelNames

Method LabelNames

api/prometheus/v1/api.go:1027–1048  ·  view source on GitHub ↗
(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option)

Source from the content-addressed store, hash-verified

1025}
1026
1027func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) ([]string, Warnings, error) {
1028 u := h.client.URL(epLabels, nil)
1029 q := addOptionalURLParams(u.Query(), opts)
1030
1031 if !startTime.IsZero() {
1032 q.Set("start", formatTime(startTime))
1033 }
1034 if !endTime.IsZero() {
1035 q.Set("end", formatTime(endTime))
1036 }
1037 for _, m := range matches {
1038 q.Add("match[]", m)
1039 }
1040
1041 _, body, w, err := h.client.DoGetFallback(ctx, u, q)
1042 if err != nil {
1043 return nil, w, err
1044 }
1045 var labelNames []string
1046 err = json.Unmarshal(body, &labelNames)
1047 return labelNames, w, err
1048}
1049
1050func (h *httpAPI) LabelValues(ctx context.Context, label string, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelValues, Warnings, error) {
1051 u := h.client.URL(epLabelValues, map[string]string{"name": label})

Callers 1

TestAPIsFunction · 0.95

Calls 7

addOptionalURLParamsFunction · 0.85
formatTimeFunction · 0.85
URLMethod · 0.65
QueryMethod · 0.65
SetMethod · 0.65
AddMethod · 0.65
DoGetFallbackMethod · 0.65

Tested by 1

TestAPIsFunction · 0.76