Skip to content

Commit

Permalink
fix(outputs.stackdriver): Regenerate time interval for unkown metrics (
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj authored Aug 11, 2023
1 parent 61cf18c commit 1381513
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion plugins/outputs/stackdriver/counter_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (cc *counterCache) GetStartTime(key string, value *monpb.TypedValue, endTim
// ...but...
// start times cannot be over 25 hours old; reset after 1 day to be safe
age := endTime.GetSeconds() - lastObserved.StartTime.GetSeconds()
cc.log.Debugf("age: %d", age)
if age > 86400 {
lastObserved.Reset(endTime)
}
Expand Down
12 changes: 12 additions & 0 deletions plugins/outputs/stackdriver/stackdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ func (s *Stackdriver) sendBatch(batch []telegraf.Metric) error {
// do some heuristics to know which one to use for queries. This
// only occurs when using the official name format.
if s.MetricNameFormat == "official" && strings.HasSuffix(timeSeries.Metric.Type, "unknown") {
metricKind := metricpb.MetricDescriptor_CUMULATIVE
startTime, endTime := getStackdriverIntervalEndpoints(metricKind, value, m, f, s.counterCache)
timeInterval, err := getStackdriverTimeInterval(metricKind, startTime, endTime)
if err != nil {
s.Log.Errorf("Get time interval failed: %s", err)
continue
}
dataPoint := &monitoringpb.Point{
Interval: timeInterval,
Value: value,
}

counterTimeSeries := &monitoringpb.TimeSeries{
Metric: &metricpb.Metric{
Type: s.generateMetricName(m, f.Key) + ":counter",
Expand Down

0 comments on commit 1381513

Please sign in to comment.