From 5f2658258289da71d68dda27085090061ee067d6 Mon Sep 17 00:00:00 2001 From: Pontus Rydin Date: Tue, 13 Apr 2021 17:07:54 -0400 Subject: [PATCH] Added MetricLookback setting (#9045) * Added MetricLookback setting * Fixed go mod issue --- plugins/inputs/vsphere/README.md | 6 ++++++ plugins/inputs/vsphere/endpoint.go | 4 +--- plugins/inputs/vsphere/vsphere.go | 8 ++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/plugins/inputs/vsphere/README.md b/plugins/inputs/vsphere/README.md index 108637bab05d7..9bb33211d29e4 100644 --- a/plugins/inputs/vsphere/README.md +++ b/plugins/inputs/vsphere/README.md @@ -181,6 +181,12 @@ vm_metric_exclude = [ "*" ] ## preserve the full precision when averaging takes place. # use_int_samples = true + ## The number of vSphere 5 minute metric collection cycles to look back for non-realtime metrics. In + ## some versions (6.7, 7.0 and possible more), certain metrics, such as cluster metrics, may be reported + ## with a significant delay (>30min). If this happens, try increasing this number. Please note that increasing + ## it too much may cause performance issues. + # metric_lookback = 3 + ## Custom attributes from vCenter can be very useful for queries in order to slice the ## metrics along different dimension and for forming ad-hoc relationships. They are disabled ## by default, since they can add a considerable amount of tags to the resulting metrics. To diff --git a/plugins/inputs/vsphere/endpoint.go b/plugins/inputs/vsphere/endpoint.go index bff3701653c8d..a9c226edf80bb 100644 --- a/plugins/inputs/vsphere/endpoint.go +++ b/plugins/inputs/vsphere/endpoint.go @@ -29,8 +29,6 @@ var isIPv4 = regexp.MustCompile("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$") var isIPv6 = regexp.MustCompile("^(?:[A-Fa-f0-9]{0,4}:){1,7}[A-Fa-f0-9]{1,4}$") -const metricLookback = 3 // Number of time periods to look back at for non-realtime metrics - const maxSampleConst = 10 // Absolute maximum number of samples regardless of period const maxMetadataSamples = 100 // Number of resources to sample for metric metadata @@ -901,7 +899,7 @@ func (e *Endpoint) chunkify(ctx context.Context, res *resourceKind, now time.Tim } start, ok := e.hwMarks.Get(object.ref.Value, metricName) if !ok { - start = latest.Add(time.Duration(-res.sampling) * time.Second * (metricLookback - 1)) + 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 diff --git a/plugins/inputs/vsphere/vsphere.go b/plugins/inputs/vsphere/vsphere.go index 7e688b73c55fc..b014f2f764c79 100644 --- a/plugins/inputs/vsphere/vsphere.go +++ b/plugins/inputs/vsphere/vsphere.go @@ -48,6 +48,7 @@ type VSphere struct { CustomAttributeExclude []string UseIntSamples bool IPAddresses []string + MetricLookback int MaxQueryObjects int MaxQueryMetrics int @@ -237,6 +238,12 @@ var sampleConfig = ` # custom_attribute_include = [] # custom_attribute_exclude = ["*"] + ## The number of vSphere 5 minute metric collection cycles to look back for non-realtime metrics. In + ## some versions (6.7, 7.0 and possible more), certain metrics, such as cluster metrics, may be reported + ## with a significant delay (>30min). If this happens, try increasing this number. Please note that increasing + ## it too much may cause performance issues. + # metric_lookback = 3 + ## Optional SSL Config # ssl_ca = "/path/to/cafile" # ssl_cert = "/path/to/certfile" @@ -363,6 +370,7 @@ func init() { MaxQueryMetrics: 256, CollectConcurrency: 1, DiscoverConcurrency: 1, + MetricLookback: 3, ForceDiscoverOnInit: true, ObjectDiscoveryInterval: config.Duration(time.Second * 300), Timeout: config.Duration(time.Second * 60),