Pārlūkot izejas kodu

Fixes from Nikos comments

Sean Holcomb 5 gadi atpakaļ
vecāks
revīzija
cd1f1115db
1 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 3 2
      pkg/prom/result.go

+ 3 - 2
pkg/prom/result.go

@@ -240,7 +240,7 @@ func (qr *QueryResult) GetLabels() map[string]string {
 			continue
 		}
 
-		label := k[6:]
+		label := strings.TrimPrefix(k, "label_")
 		value, ok := v.(string)
 		if !ok {
 			log.Warningf("Failed to parse label value for label: '%s'", label)
@@ -253,6 +253,7 @@ func (qr *QueryResult) GetLabels() map[string]string {
 	return result
 }
 
+// GetAnnotations returns all annotations and their values from the query result
 func (qr *QueryResult) GetAnnotations() map[string]string {
 	result := make(map[string]string)
 
@@ -262,7 +263,7 @@ func (qr *QueryResult) GetAnnotations() map[string]string {
 			continue
 		}
 
-		annotations := k[11:]
+		annotations := strings.TrimPrefix(k, "annotation_")
 		value, ok := v.(string)
 		if !ok {
 			log.Warningf("Failed to parse label value for label: '%s'", annotations)