Skip to content

Commit

Permalink
Merge pull request #598 from kongfei605/gcp_fix
Browse files Browse the repository at this point in the history
gcp fix
  • Loading branch information
kongfei605 committed Aug 15, 2023
2 parents 3e75749 + da7d48f commit a18108e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions inputs/googlecloud/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,23 @@ func (ins *Instance) readTimeSeriesValue(slist *types.SampleList, filter string)
if labels["resource_type"] == "gce_instance" {
labels[ins.GceHostTag] = labels["instance_name"]
}
metric := strings.ReplaceAll(labels["metric_type"], ".googleapis.com/", "")
metric = strings.ReplaceAll(labels["metric_type"], "/", "_")
metric := strings.ReplaceAll(labels["metric_type"], "/", "_")
// metric = strings.ReplaceAll(labels["metric_type"], ".googleapis.com/", "")
samples := make([]*types.Sample, 0, len(resp.GetPoints()))
var val interface{}
for _, point := range resp.GetPoints() {
val = 0
switch point.GetValue().GetValue().(type) {
case *monitoringpb.TypedValue_DoubleValue:
val = point.GetValue().GetDoubleValue()
case *monitoringpb.TypedValue_Int64Value:
val = point.GetValue().GetInt64Value()
case *monitoringpb.TypedValue_DistributionValue:
val = point.GetValue().GetDistributionValue().GetCount()
metric = metric + "_sum"
}
samples = append(samples,
types.NewSample("gcp", metric, point.GetValue().GetDoubleValue(), labels).
types.NewSample("gcp", metric, val, labels).
SetTime(time.Unix(point.GetInterval().GetEndTime().GetSeconds(), 0)))
}
slist.PushFrontN(samples)
Expand Down

0 comments on commit a18108e

Please sign in to comment.