AjayTripathy пре 6 година
родитељ
комит
ee7f1e1860
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      costmodel/cluster.go

+ 3 - 0
costmodel/cluster.go

@@ -90,6 +90,9 @@ func resultToTotal(qr interface{}) ([][]string, error) {
 	if !ok {
 	if !ok {
 		return nil, fmt.Errorf("Improperly formatted results from prometheus, result field is not a slice")
 		return nil, fmt.Errorf("Improperly formatted results from prometheus, result field is not a slice")
 	}
 	}
+	if len(results) == 0 {
+		return nil, fmt.Errorf("Not enough data available in the selected time range")
+	}
 	val, ok := results[0].(map[string]interface{})["value"]
 	val, ok := results[0].(map[string]interface{})["value"]
 	totals := [][]string{}
 	totals := [][]string{}
 	if !ok {
 	if !ok {