Skip to content

feat(inputs.vsphere): Allow adding custom properties as fields#19161

Open
tguenneguez wants to merge 19 commits into
influxdata:masterfrom
tguenneguez:add-custom-properties-vsphere
Open

feat(inputs.vsphere): Allow adding custom properties as fields#19161
tguenneguez wants to merge 19 commits into
influxdata:masterfrom
tguenneguez:add-custom-properties-vsphere

Conversation

@tguenneguez

@tguenneguez tguenneguez commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Add the capabilitie to collecte properties of elements.

For sample :

  • host :
    • summary.runtime.powerState
    • summary.overallStatus
    • summary.runtime.inMaintenanceMode
    • summary.runtime.connectionState
  • vm :
    • runtime.powerState
  • cluster :
    • overallStatus
    • configuration.drsConfig.enabled
  • datastore :
    • summary.accessible
  • resource_pool :
    • overallStatus

This change collect data for VM Power Off. There was no information about this subtility.

Checklist

Related issues

resolves #18858

@tguenneguez tguenneguez changed the title feat(input.vsphere) : add custom properties feat(inputs.vsphere) : add custom properties Jun 25, 2026
@tguenneguez tguenneguez changed the title feat(inputs.vsphere) : add custom properties feat(inputs.vsphere): add custom properties Jun 29, 2026
@telegraf-tiger telegraf-tiger Bot added area/vsphere feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Jun 29, 2026
@srebhan

srebhan commented Jul 3, 2026

Copy link
Copy Markdown
Member

Thanks for your contribution @tguenneguez! Can you please check and fix the linter issues!? Furthermore, you can't check "I've used no AI" and "I've used AI" at the same time. :-) Please fix the checkboxes in the PR description. :-)

@srebhan srebhan self-assigned this Jul 3, 2026
@tguenneguez

Copy link
Copy Markdown
Contributor Author

Yes, I have seen it, but I do lot off think in the same time so, i change when I have time.
I think it will be good.

@telegraf-tiger

telegraf-tiger Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @tguenneguez! I do have some comments in the code. IMO, the most important issues are

  1. You are changing unrelated parts of the code resulting in a larger diff than necessary. Please avoid changing code you don't need to touch in this PR. If you want it changed, do it in a separate PR!
  2. Spelling and comments are French AFAICS. Please check spelling and convert everything to English please!

Looking forward to your update of the PR!

Comment thread plugins/inputs/vsphere/endpoint.go
Comment thread plugins/inputs/vsphere/endpoint.go Outdated
return cvs
}

func (e *endpoint) loadCustomProperties(entity interface{}, propertieInclude []string) map[string]interface{} {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

propertieInclude is a typo. Did you mean propertiesInclude? The same thing occurs in multiple places throughout the PR...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact, that's because of in config, you use :
CustomAttributeInclude
But it's a list of attibutes.

In this way I think it will be great to be "propertieInclude" every where ?

Comment thread plugins/inputs/vsphere/endpoint.go Outdated
Comment thread plugins/inputs/vsphere/endpoint.go Outdated
Comment thread plugins/inputs/vsphere/endpoint.go
// resourceInfo is a utility class grouping a type and relevant parameters.
type resourceInfo struct {
resType string
custoFields []string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This abbreviation saves one character while humpering readability a lot. Please be generous and add the m here. :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because of resourceFilter containe a resType

fields = append(fields, af...)
}
fields = append(fields, resourceInfo.custoFields...)
uniqueFields := removeDuplicates(fields)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fields are defined by resourceInfo.custoFields which in turn stem from user-settings, don't they? If so, wouldn't it be better to deduplicate those user-settings in Init instead of doing it in every gather cycle?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be, but they are agregate to addFields[resourceInfo.resType].
To be able to do this, it will be necessaire to agregate this info only one time...

Comment on lines 23 to 27

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change display ? Can you explain me ...

VMMetricExclude []string `toml:"vm_metric_exclude"`
VMInclude []string `toml:"vm_include"`
VMExclude []string `toml:"vm_exclude"`
VMPropertieInclude []string `toml:"vm_propertie_include"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo! Please fix spelling! Same for all other options you introduced.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You speak about :
VMMetricExclude vs VmMetricExclude ?

Comment thread plugins/inputs/vsphere/vsphere_test.go Outdated
err = f.find(t.Context(), "Datacenter", "/DC0", &dc)
ri := resourceInfo{
resType: "Datacenter",
custoFields: nil,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't explicitly set fields to values they have anyway by Golang's defaults. Same for all other instances.

@srebhan srebhan changed the title feat(inputs.vsphere): add custom properties feat(inputs.vsphere): Allow adding custom properties as fields Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/vsphere feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[inputs.vsphere] More informations about VMs

2 participants