fix(outputs.stackdriver): Regenerate time interval for unkown metrics (#13745)
This commit is contained in:
parent
61cf18c821
commit
1381513e61
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue