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

vSphere input: need to be able to configure the historical interval duration #9276

Merged
merged 7 commits into from
May 20, 2021
9 changes: 7 additions & 2 deletions plugins/inputs/vsphere/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ We can extend this to looking at a cluster level: ```/DC0/host/Cluster1/*/hadoop
vCenter keeps two different kinds of metrics, known as realtime and historical metrics.

* Realtime metrics: Available at a 20 second granularity. These metrics are stored in memory and are very fast and cheap to query. Our tests have shown that a complete set of realtime metrics for 7000 virtual machines can be obtained in less than 20 seconds. Realtime metrics are only available on **ESXi hosts** and **virtual machine** resources. Realtime metrics are only stored for 1 hour in vCenter.
* Historical metrics: Available at a 5 minute, 30 minutes, 2 hours and 24 hours rollup levels. The vSphere Telegraf plugin only uses the 5 minute rollup. These metrics are stored in the vCenter database and can be expensive and slow to query. Historical metrics are the only type of metrics available for **clusters**, **datastores** and **datacenters**.
* Historical metrics: Available at a (default) 5 minute, 30 minutes, 2 hours and 24 hours rollup levels. The vSphere Telegraf plugin only uses the most granular rollup which defaults to 5 minutes but can be changed in vCenter to other interval durations. These metrics are stored in the vCenter database and can be expensive and slow to query. Historical metrics are the only type of metrics available for **clusters**, **datastores** and **datacenters**.

For more information, refer to the vSphere documentation here: https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.pg.doc_50%2FPG_Ch16_Performance.18.2.html

Expand Down Expand Up @@ -315,7 +315,7 @@ This will disrupt the metric collection and can result in missed samples. The be
[[inputs.vsphere]]

interval = "300s"

vcenters = [ "https://someaddress/sdk" ]
username = "someuser@vsphere.local"
password = "secret"
Expand Down Expand Up @@ -355,6 +355,11 @@ The vSphere plugin allows you to specify two concurrency settings:

While a higher level of concurrency typically has a positive impact on performance, increasing these numbers too much can cause performance issues at the vCenter server. A rule of thumb is to set these parameters to the number of virtual machines divided by 1500 and rounded up to the nearest integer.

### Configuring historical_interval setting

When the vSphere plugin queries vCenter for historical statistics it queries for statistics that exist at a specific interval. The default historical interval duration is 5 minutes but if this interval has been changed then you must override the default query interval in the vSphere plugin.
* ```historical_interval```: The interval of the most granular statistics configured in vSphere represented in seconds.

## Measurements & Fields

- Cluster Stats
Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/vsphere/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func NewEndpoint(ctx context.Context, parent *VSphere, url *url.URL, log telegra
parentTag: "",
enabled: anythingEnabled(parent.DatacenterMetricExclude),
realTime: false,
sampling: 300,
sampling: int32(time.Duration(parent.HistoricalInterval).Seconds()),
objects: make(objectMap),
filters: newFilterOrPanic(parent.DatacenterMetricInclude, parent.DatacenterMetricExclude),
paths: parent.DatacenterInclude,
Expand All @@ -154,7 +154,7 @@ func NewEndpoint(ctx context.Context, parent *VSphere, url *url.URL, log telegra
parentTag: "dcname",
enabled: anythingEnabled(parent.ClusterMetricExclude),
realTime: false,
sampling: 300,
sampling: int32(time.Duration(parent.HistoricalInterval).Seconds()),
objects: make(objectMap),
filters: newFilterOrPanic(parent.ClusterMetricInclude, parent.ClusterMetricExclude),
paths: parent.ClusterInclude,
Expand Down Expand Up @@ -207,7 +207,7 @@ func NewEndpoint(ctx context.Context, parent *VSphere, url *url.URL, log telegra
pKey: "dsname",
enabled: anythingEnabled(parent.DatastoreMetricExclude),
realTime: false,
sampling: 300,
sampling: int32(time.Duration(parent.HistoricalInterval).Seconds()),
objects: make(objectMap),
filters: newFilterOrPanic(parent.DatastoreMetricInclude, parent.DatastoreMetricExclude),
paths: parent.DatastoreInclude,
Expand Down
6 changes: 6 additions & 0 deletions plugins/inputs/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type VSphere struct {
ForceDiscoverOnInit bool
ObjectDiscoveryInterval config.Duration
Timeout config.Duration
HistoricalInterval config.Duration

endpoints []*Endpoint
cancel context.CancelFunc
Expand Down Expand Up @@ -250,6 +251,10 @@ var sampleConfig = `
# ssl_key = "/path/to/keyfile"
## Use SSL but skip chain & host verification
# insecure_skip_verify = false

## The Historical Interval value must match EXACTLY the interval in the daily
# "Interval Duration" found on the VCenter server under Configure > General > Statistics > Statistic intervals
# historical_interval = "5m"
`

// SampleConfig returns a set of default configuration to be used as a boilerplate when setting up
Expand Down Expand Up @@ -374,6 +379,7 @@ func init() {
ForceDiscoverOnInit: true,
ObjectDiscoveryInterval: config.Duration(time.Second * 300),
Timeout: config.Duration(time.Second * 60),
HistoricalInterval: config.Duration(time.Second * 300),
}
})
}
7 changes: 7 additions & 0 deletions plugins/inputs/vsphere/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func defaultVSphere() *VSphere {
DiscoverConcurrency: 1,
CollectConcurrency: 1,
Separator: ".",
HistoricalInterval: config.Duration(time.Second * 300),
}
}

Expand Down Expand Up @@ -228,6 +229,12 @@ func TestParseConfig(t *testing.T) {
tab, err := toml.Parse([]byte(c))
require.NoError(t, err)
require.NotNil(t, tab)

}

func TestConfigDurationParsing(t *testing.T) {
v := defaultVSphere()
require.Equal(t, int32(300), int32(time.Duration(v.HistoricalInterval).Seconds()), "HistoricalInterval.Seconds() with default duration should resolve 300")
}

func TestMaxQuery(t *testing.T) {
Expand Down