Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 17 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/inputs/vsphere/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions plugins/inputs/vsphere/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()]
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion plugins/inputs/vsphere/tscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down