CloudMonitoring: Fix INT64 label unmarshal error (#39441)

This commit is contained in:
Benedikt Spellmeyer 2021-09-22 17:05:36 +02:00 committed by GitHub
parent c75737c808
commit f76a11c955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View File

@ -942,7 +942,7 @@ func TestCloudMonitoring(t *testing.T) {
query := &cloudMonitoringTimeSeriesQuery{
ProjectName: "test-proj",
Query: "test-query",
AliasBy: "{{project}} - {{resource.label.zone}} - {{resource.label.instance_id}}",
AliasBy: "{{project}} - {{resource.label.zone}} - {{resource.label.instance_id}} - {{metric.label.response_code_class}}",
timeRange: plugins.DataTimeRange{
From: fmt.Sprintf("%v", fromStart.Unix()*1000),
To: fmt.Sprintf("%v", fromStart.Add(34*time.Minute).Unix()*1000),
@ -952,7 +952,7 @@ func TestCloudMonitoring(t *testing.T) {
require.NoError(t, err)
frames, err := res.Dataframes.Decoded()
require.NoError(t, err)
assert.Equal(t, "test-proj - asia-northeast1-c - 6724404429462225363", frames[0].Fields[1].Name)
assert.Equal(t, "test-proj - asia-northeast1-c - 6724404429462225363 - 200", frames[0].Fields[1].Name)
})
})
})

View File

@ -9,6 +9,10 @@
},
{
"key": "resource.instance_id"
},
{
"key": "metric.response_code_class",
"valueType": "INT64"
}
],
"pointDescriptors": [
@ -30,6 +34,9 @@
},
{
"stringValue": "6724404429462225363"
},
{
"int64Value": "200"
}
],
"pointData": [

View File

@ -123,9 +123,8 @@ func (timeSeriesQuery cloudMonitoringTimeSeriesQuery) parseResponse(queryRes *pl
labels[key][strVal] = true
seriesLabels[key] = strVal
case "INT64":
intVal := strconv.FormatInt(labelValue.Int64Value, 10)
labels[key][intVal] = true
seriesLabels[key] = intVal
labels[key][labelValue.Int64Value] = true
seriesLabels[key] = labelValue.Int64Value
default:
labels[key][labelValue.StringValue] = true
seriesLabels[key] = labelValue.StringValue
@ -285,8 +284,7 @@ func (timeSeriesQuery cloudMonitoringTimeSeriesQuery) parseToAnnotations(queryRe
strVal := strconv.FormatBool(labelValue.BoolValue)
value = strVal
case "INT64":
intVal := strconv.FormatInt(labelValue.Int64Value, 10)
value = intVal
value = labelValue.Int64Value
default:
value = labelValue.StringValue
}

View File

@ -118,7 +118,7 @@ type timeSeriesDescriptor struct {
type timeSeriesData []struct {
LabelValues []struct {
BoolValue bool `json:"boolValue"`
Int64Value int64 `json:"int64Value"`
Int64Value string `json:"int64Value"`
StringValue string `json:"stringValue"`
} `json:"labelValues"`
PointData []struct {