@@ -124,6 +124,7 @@ const (
124
124
epAlertManagers = apiPrefix + "/alertmanagers"
125
125
epQuery = apiPrefix + "/query"
126
126
epQueryRange = apiPrefix + "/query_range"
127
+ epLabels = apiPrefix + "/labels"
127
128
epLabelValues = apiPrefix + "/label/:name/values"
128
129
epSeries = apiPrefix + "/series"
129
130
epTargets = apiPrefix + "/targets"
@@ -227,6 +228,8 @@ type API interface {
227
228
DeleteSeries (ctx context.Context , matches []string , startTime time.Time , endTime time.Time ) error
228
229
// Flags returns the flag values that Prometheus was launched with.
229
230
Flags (ctx context.Context ) (FlagsResult , error )
231
+ // LabelNames returns all the unique label names present in the block in sorted order.
232
+ LabelNames (ctx context.Context ) ([]string , error )
230
233
// LabelValues performs a query for the values of the given label.
231
234
LabelValues (ctx context.Context , label string ) (model.LabelValues , error )
232
235
// Query performs a query for the given time.
@@ -622,6 +625,20 @@ func (h *httpAPI) Flags(ctx context.Context) (FlagsResult, error) {
622
625
return res , json .Unmarshal (body , & res )
623
626
}
624
627
628
+ func (h * httpAPI ) LabelNames (ctx context.Context ) ([]string , error ) {
629
+ u := h .client .URL (epLabels , nil )
630
+ req , err := http .NewRequest (http .MethodGet , u .String (), nil )
631
+ if err != nil {
632
+ return nil , err
633
+ }
634
+ _ , body , _ , err := h .client .Do (ctx , req )
635
+ if err != nil {
636
+ return nil , err
637
+ }
638
+ var labelNames []string
639
+ return labelNames , json .Unmarshal (body , & labelNames )
640
+ }
641
+
625
642
func (h * httpAPI ) LabelValues (ctx context.Context , label string ) (model.LabelValues , error ) {
626
643
u := h .client .URL (epLabelValues , map [string ]string {"name" : label })
627
644
req , err := http .NewRequest (http .MethodGet , u .String (), nil )
0 commit comments