fix(inputs.vsphere): Eliminated duplicate samples (#12259)

This commit is contained in:
Pontus Rydin 2022-12-07 11:02:02 -05:00 committed by GitHub
parent d7d1f8b3f0
commit dae0d82b9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View File

@ -11,8 +11,9 @@ vCenter servers.
## Supported versions of vSphere
This plugin supports vSphere version 6.5, 6.7 and 7.0. It may work with versions
5.1, 5.5 and 6.0, but neither are officially supported.
This plugin supports vSphere version 6.5, 6.7, 7.0 and 8.0.
It may work with versions 5.1, 5.5 and 6.0, but neither are
officially supported.
Compatibility information is available from the govmomi project
[here](https://github.com/vmware/govmomi/tree/v0.26.0#compatibility)

View File

@ -257,7 +257,7 @@ func anythingEnabled(ex []string) bool {
func newFilterOrPanic(include []string, exclude []string) filter.Filter {
f, err := filter.NewIncludeExcludeFilter(include, exclude)
if err != nil {
panic(fmt.Sprintf("Include/exclude filters are invalid: %s", err))
panic(fmt.Sprintf("Include/exclude filters are invalid: %v", err))
}
return f
}
@ -969,7 +969,10 @@ func (e *Endpoint) chunkify(ctx context.Context, res *resourceKind, now time.Tim
if !ok {
start = latest.Add(time.Duration(-res.sampling) * time.Second * (time.Duration(e.Parent.MetricLookback) - 1))
}
start = start.Truncate(20 * time.Second) // Truncate to maximum resolution
if !start.Truncate(time.Second).Before(now.Truncate(time.Second)) {
e.log.Debugf("Start >= end (rounded to seconds): %s > %s", start, now)
}
// Create bucket if we don't already have it
bucket, ok := timeBuckets[start.Unix()]
@ -1243,7 +1246,8 @@ func (e *Endpoint) collectChunk(
count++
// Update hiwater marks
e.hwMarks.Put(moid, name, ts)
adjTs := ts.Add(interval).Truncate(interval).Add(-time.Second)
e.hwMarks.Put(moid, name, adjTs)
}
if nValues == 0 {
e.log.Debugf("Missing value for: %s, %s", name, objectRef.name)

View File

@ -62,7 +62,10 @@ func (t *TSCache) Get(key string, metricName string) (time.Time, bool) {
func (t *TSCache) Put(key string, metricName string, timestamp time.Time) {
t.mux.Lock()
defer t.mux.Unlock()
t.table[makeKey(key, metricName)] = timestamp
k := makeKey(key, metricName)
if timestamp.After(t.table[k]) {
t.table[k] = timestamp
}
}
func makeKey(resource string, metric string) string {