diff --git a/plugins/inputs/vsphere/README.md b/plugins/inputs/vsphere/README.md index 15cddd9b5d0a6..30dc66d2d0db3 100644 --- a/plugins/inputs/vsphere/README.md +++ b/plugins/inputs/vsphere/README.md @@ -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) diff --git a/plugins/inputs/vsphere/endpoint.go b/plugins/inputs/vsphere/endpoint.go index 279306da8b66e..821a9a085310f 100644 --- a/plugins/inputs/vsphere/endpoint.go +++ b/plugins/inputs/vsphere/endpoint.go @@ -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) diff --git a/plugins/inputs/vsphere/tscache.go b/plugins/inputs/vsphere/tscache.go index 78303b45df3c0..a2a81111282ce 100644 --- a/plugins/inputs/vsphere/tscache.go +++ b/plugins/inputs/vsphere/tscache.go @@ -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 {