Skip to content

feat(inputs.system): Add option to specify collected information#18533

Merged
skartikey merged 16 commits into
influxdata:masterfrom
bilkoua:master
Apr 30, 2026
Merged

feat(inputs.system): Add option to specify collected information#18533
skartikey merged 16 commits into
influxdata:masterfrom
bilkoua:master

Conversation

@bilkoua
Copy link
Copy Markdown
Contributor

@bilkoua bilkoua commented Mar 16, 2026

Summary

Add a collect option to the existing system input plugin, allowing users to selectively enable or disable metric groups.

Motivation

The system plugin currently always collects all metrics. Adding a collect option gives users control over which groups are gathered. When collect is omitted, the behaviour is identical to the previous version of the plugin.
The collect option is designed to be extensible - future metric groups can be added without changing the configuration interface.
By default both groups are enabled.

Checklist

@telegraf-tiger
Copy link
Copy Markdown
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@bilkoua
Copy link
Copy Markdown
Contributor Author

bilkoua commented Mar 16, 2026

!signed-cla

@bilkoua bilkoua changed the title Add inputs.node_info plugin feat(inputs.node_info): add node_info plugin Mar 16, 2026
@telegraf-tiger telegraf-tiger Bot added 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 Mar 16, 2026
@bilkoua
Copy link
Copy Markdown
Contributor Author

bilkoua commented Mar 20, 2026

@skartikey @srebhan @mstrandboge Hi, could you take a look at this PR when you have a moment?

@srebhan
Copy link
Copy Markdown
Member

srebhan commented Mar 20, 2026

First of all: Thank you for your nice contribution @bilkoua !

I like the basic idea and see this being helpful, however I feel like merging this into the system input plugin would make the features more discoverable.

What do you think @bilkoua?

@srebhan srebhan self-assigned this Mar 20, 2026
@bilkoua bilkoua changed the title feat(inputs.node_info): add node_info plugin feat(inputs.system): add collect option and node-identity metrics Mar 21, 2026
@bilkoua
Copy link
Copy Markdown
Contributor Author

bilkoua commented Mar 21, 2026

@srebhan I actually had the same idea at first. But then I figured a smaller, separate plugin would be easier to get merged.
That said, your comment gave me more confidence in the original approach, so I went ahead and reworked it.
Also, thanks for your work on this — really appreciate it!

@srebhan
Copy link
Copy Markdown
Member

srebhan commented Mar 23, 2026

Thanks for rebasing @bilkoua! As this PR is fairly large I suggest to cut it into more digestible pieces. My understanding is that this PR does

  1. Guard existing metrics with user settings
  2. Add metrics for the OS version (Linux only)
  3. Add metrics for DMI information (Linux only)

So my idea would be to split this PR into the three steps above. I'm not really sure if we need step 1 as the metrics exist right now and they can easily be filtered using metric filtering options.

For 2: I suggest you take a look at the gopsutil library as this library can extract the required information in an OS independent way instead of "hand-coding" the stuff.

For 3: How about using the smbios library to read DMI information in an platform independent way (at least for most platforms we support)? This reduces the amount of code we need to maintain and we gain support of at least Linux, Windows and BSD variants...

@bilkoua
Copy link
Copy Markdown
Contributor Author

bilkoua commented Mar 23, 2026

@srebhan Thanks for the feedback - splitting the PR into smaller pieces makes sense, and I can restructure it accordingly.

Regarding point 1: my reasoning for guarding existing metrics with user settings is that metric filtering does not fully replace the ability to disable entire metric groups. As I understand it, when filters are used the metrics are still collected and resources are still spent gathering them, even if they are later filtered out and not exposed. With the proposed approach, the metrics would not be collected at all, which avoids unnecessary resource usage. This approach is also already used by several existing metric plugins such as kernel, conntrack, and fritzbox. That said, I’m fine following the preferred approach if you think filtering is sufficient.

For points 2 and 3, I agree that using existing libraries instead of implementing everything manually would make sense.

However, the go-smbios library appears to be largely unmaintained. From a quick look, the alternatives seem to be either relatively unknown forks, platform-specific implementations, or larger libraries such as ghw. The latter might be somewhat heavier than what we need, although it could make sense if we plan to expose additional hardware-related metrics in the future.

What are your thoughts on this?

@srebhan
Copy link
Copy Markdown
Member

srebhan commented Mar 26, 2026

@bilkoua regarding filtering. Yes some plugins allow to enable feature sets but you seem to go down to a per-field level. From a resource-usage standpoint your approach might make sense, even though here the "cost" for the extra data is really low, but from a maintenance standpoint it is horrible to allow users to specify collection on a per-field basis.

So how about having load and uptime as an option for the two existing metrics and add a os and a hardware/dmi option for your new metrics? Maybe name the new metrics accordingly i.e. system_os and system_dmi?

Regarding usage of libraries, I'm not bound to a particular library, my only criterion is that is should be maintained if necessary (some "old" libraries are maintained but only rarely have issues...). However, using a library is highly encouraged!

@bilkoua bilkoua changed the title feat(inputs.system): add collect option and node-identity metrics feat(inputs.system): add collect option Apr 3, 2026
@bilkoua
Copy link
Copy Markdown
Contributor Author

bilkoua commented Apr 3, 2026

@srebhan Apologies for the delay - didn't have much time to get back to this sooner.

I've reworked the PR based on your suggestions:

What changed in this revision:

  • Simplified the collect option to two groups: load (gauge metrics: load averages, cpu counts, user counts) and uptime (uptime counter + uptime_format). This avoids per-field granularity as you suggested.
  • Removed all Linux-specific code (os-release, DMI, uname) from this PR.
  • Fixed a pre-existing nil-pointer dereference when load.Avg() returns "not implemented".

Plan for follow-up PRs:

  • os group - OS release and uname info, using gopsutil for cross-platform support.
  • hardware group - DMI/SMBIOS data, using a maintained library for cross-platform support.

Each will add a new value to the same collect option, so the configuration interface stays consistent.

Copy link
Copy Markdown
Contributor

@Hipska Hipska left a comment

Choose a reason for hiding this comment

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

I like the idea, however, I feel like there is too much added in the load group.

Comment thread plugins/inputs/system/system.go Outdated
Comment thread plugins/inputs/system/system.go Outdated
Comment thread plugins/inputs/system/README.md Outdated
@bilkoua
Copy link
Copy Markdown
Contributor Author

bilkoua commented Apr 7, 2026

@Hipska Initially, the existing metrics were split into groups: load, users, n_cpus, and uptime.
However, @srebhan pointed out that having that many groups wasn’t ideal, so I regrouped them as suggested here.

It’s possible I didn’t fully understand the original idea, but I’m happy to adjust the implementation however we agree. The main thing is to reach a clear consensus on the structure.

@Hipska
Copy link
Copy Markdown
Contributor

Hipska commented Apr 7, 2026

As I read the comment you're pointing at, it looks like the suggestion is to have these 4 groups: load, uptime, os and a hardware/dmi. It even suggests to have the last 2 options as a separate metric, so not including them in the already existing system metric. I don't see that reflected in the code yet.

Edit: Looking at the existing code, it doesn't look like you are adding any new fields, so I would not change metric name for existing ones for backward compatibility.

Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thanks for the update @bilkoua! The code looks a lot better now. However, I do have some additional comments...

Comment thread plugins/inputs/system/system.go Outdated
Comment thread plugins/inputs/system/system.go Outdated
Comment thread plugins/inputs/system/system.go Outdated
Comment thread plugins/inputs/system/system.go
Comment thread plugins/inputs/system/system_test.go Outdated
Comment thread plugins/inputs/system/system_test.go Outdated
Comment thread plugins/inputs/system/system_test.go Outdated
Comment thread plugins/inputs/system/system_test.go Outdated
Comment thread plugins/inputs/system/system_test.go Outdated
@bilkoua bilkoua force-pushed the master branch 3 times, most recently from 929d7b2 to b161aed Compare April 27, 2026 13:36
@bilkoua
Copy link
Copy Markdown
Contributor Author

bilkoua commented Apr 27, 2026

@srebhan Thanks for the review!
Could you take another look?

Copy link
Copy Markdown
Contributor

@Hipska Hipska left a comment

Choose a reason for hiding this comment

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

Looks very good! One small remark regarding the tests.

Comment thread plugins/inputs/system/system_test.go Outdated
Comment on lines +78 to +79
s := &System{Include: include, Log: &testutil.Logger{}}
require.NoError(t, s.Init())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use t.Run when looping over tests

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.

I agree, that would be better to avoid side effects between the tests.

Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thanks @bilkoua! Almost there, just some minor issues left...

Comment thread plugins/inputs/system/sample.conf Outdated
Comment thread plugins/inputs/system/system.go Outdated
Comment thread plugins/inputs/system/system_test.go Outdated
Comment on lines +78 to +79
s := &System{Include: include, Log: &testutil.Logger{}}
require.NoError(t, s.Init())
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.

I agree, that would be better to avoid side effects between the tests.

bilkoua and others added 2 commits April 29, 2026 14:41
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
@srebhan srebhan changed the title feat(inputs.system): add collect option feat(inputs.system): Add option to specify collected information Apr 29, 2026
Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thanks a lot @bilkoua!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Apr 29, 2026
@srebhan srebhan assigned skartikey and unassigned srebhan Apr 29, 2026
Copy link
Copy Markdown
Contributor

@skartikey skartikey left a comment

Choose a reason for hiding this comment

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

@bilkoua Thanks for the work on this! I have a few concerns before this can land.

Comment thread plugins/inputs/system/system.go Outdated
Comment thread plugins/inputs/system/system.go Outdated
Comment thread plugins/inputs/system/README.md Outdated
@telegraf-tiger
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

@skartikey skartikey left a comment

Choose a reason for hiding this comment

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

@bilkoua Thanks for the contribution!

@skartikey skartikey merged commit 471c840 into influxdata:master Apr 30, 2026
27 checks passed
@github-actions github-actions Bot added this to the v1.39.0 milestone Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/system 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 ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants