Browse Source

stackdriver: add support for int64 values

Erik Sundell 7 years ago
parent
commit
220f479ff8
2 changed files with 11 additions and 1 deletions
  1. 9 1
      pkg/tsdb/stackdriver/stackdriver.go
  2. 2 0
      pkg/tsdb/stackdriver/types.go

+ 9 - 1
pkg/tsdb/stackdriver/stackdriver.go

@@ -305,7 +305,15 @@ func (e *StackdriverExecutor) parseResponse(queryRes *tsdb.QueryResult, data Sta
 		// reverse the order to be ascending
 		// reverse the order to be ascending
 		for i := len(series.Points) - 1; i >= 0; i-- {
 		for i := len(series.Points) - 1; i >= 0; i-- {
 			point := series.Points[i]
 			point := series.Points[i]
-			points = append(points, tsdb.NewTimePoint(null.FloatFrom(point.Value.DoubleValue), float64((point.Interval.EndTime).Unix())*1000))
+			value := point.Value.DoubleValue
+			if series.ValueType == "INT64" {
+				parsedValue, err := strconv.ParseFloat(point.Value.IntValue, 64)
+				if err == nil {
+					value = parsedValue
+				}
+			}
+
+			points = append(points, tsdb.NewTimePoint(null.FloatFrom(value), float64((point.Interval.EndTime).Unix())*1000))
 		}
 		}
 
 
 		defaultMetricName := series.Metric.Type
 		defaultMetricName := series.Metric.Type

+ 2 - 0
pkg/tsdb/stackdriver/types.go

@@ -35,6 +35,8 @@ type StackdriverResponse struct {
 			Value struct {
 			Value struct {
 				DoubleValue float64 `json:"doubleValue"`
 				DoubleValue float64 `json:"doubleValue"`
 				StringValue string  `json:"stringValue"`
 				StringValue string  `json:"stringValue"`
+				BoolValue   bool    `json:"boolValue"`
+				IntValue    string  `json:"int64Value"`
 			} `json:"value"`
 			} `json:"value"`
 		} `json:"points"`
 		} `json:"points"`
 	} `json:"timeSeries"`
 	} `json:"timeSeries"`