Skip to content

Commit

Permalink
Added MetricLookback setting (influxdata#9045)
Browse files Browse the repository at this point in the history
* Added MetricLookback setting

* Fixed go mod issue
  • Loading branch information
prydin authored Apr 13, 2021
1 parent 66e12e0 commit 5f26582
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions plugins/inputs/vsphere/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions plugins/inputs/vsphere/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type VSphere struct {
CustomAttributeExclude []string
UseIntSamples bool
IPAddresses []string
MetricLookback int

MaxQueryObjects int
MaxQueryMetrics int
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 5f26582

Please sign in to comment.