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

[metricbeat] Add system/entropy metricset #12450

Merged
merged 9 commits into from
Jun 12, 2019

Conversation

fearful-symmetry
Copy link
Contributor

This PR adds a system/entropy metricset, which monitors and reports the state of /proc/sys/kernel/random/entropy_avail Many other monitoring solutions have this, including node_exporter and netdata.

This is a (comparatively) small metricset, as there really isn't a lot going on. Most of the other files in random aren't particularly interesting as far as monitoring, although y'all are free to disagree if you think we should add others. *bsd also generates entropy differently, meaning there's no equivalent to entropy_avail, and most of the metrics exposed by kern.random I didn't think were particularly interesting, although, again, if we decide they're valuable I can add them.

Because the full path (/proc/sys/kernel/random/entropy_avail) is a tad long-winded, I wasn't sure if we wanted to add a custom config option for the metricset to specify a path to entropy_avail, so for now I'm piggy-backing off of the system hostfs option.

@fearful-symmetry fearful-symmetry added enhancement Metricbeat Metricbeat Team:Integrations Label for the Integrations team labels Jun 5, 2019
@fearful-symmetry fearful-symmetry requested a review from a team June 5, 2019 16:32
@fearful-symmetry fearful-symmetry requested a review from a team as a code owner June 5, 2019 16:32
@fearful-symmetry fearful-symmetry self-assigned this Jun 5, 2019
Copy link
Contributor

@exekias exekias left a comment

Choose a reason for hiding this comment

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

Awesome! can you also add a changelog entry?

metricbeat/module/system/entropy/_meta/fields.yml Outdated Show resolved Hide resolved
MetricSetFields: common.MapStr{
"entropy": common.MapStr{
"available_bits": entropy,
"pct": float64(entropy) / float64(4096),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this max of 4096 is hardcoded in linux, can you confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is!

Copy link
Member

Choose a reason for hiding this comment

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

Is it the value available in /proc/sys/kernel/random/poolsize? Should we get it from there in case it changes somewhere at some moment?

@fearful-symmetry
Copy link
Contributor Author

@exekias added the changelog, and (hopefully) fixed the fields.

@fearful-symmetry fearful-symmetry requested review from kaiyan-sheng and a team June 6, 2019 15:12
Copy link
Contributor

@sayden sayden left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Sorry for the late review 😬, it LGTM in general, the only thing I'd change now is the release level in the docs and maybe the build tags, the rest are open questions.

},
"system": {
"entropy": {
"entropy": {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this double entropy level?

Copy link
Contributor

Choose a reason for hiding this comment

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

ups, I missed this when we talked about object vs group, +1 to one level only

MetricSetFields: common.MapStr{
"entropy": common.MapStr{
"available_bits": entropy,
"pct": float64(entropy) / float64(4096),
Copy link
Member

Choose a reason for hiding this comment

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

Is it the value available in /proc/sys/kernel/random/poolsize? Should we get it from there in case it changes somewhere at some moment?

// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

Copy link
Member

Choose a reason for hiding this comment

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

I guess we should exclude this metricset from non-linux builds.

metricbeat/docs/modules/system/entropy.asciidoc Outdated Show resolved Hide resolved
@fearful-symmetry
Copy link
Contributor Author

Yah, @jsoriano I was sorta ambivalent about /proc/sys/kernel/random/poolsize since on one hand, yes, that's where the 4096 comes from, on the other hand, the kernel docs seem very insistent that on kernels 2.6 and newer, it'll always be 4096.

@fearful-symmetry
Copy link
Contributor Author

fearful-symmetry commented Jun 7, 2019

Updated a bunch of things, and ended up using the poolsize var, since why not.

However, I can't for the life of me fix the fields. The TestData function is still generating two entropy fields.

@fearful-symmetry
Copy link
Contributor Author

Okay, latest commit should fix the field formatting issues, and the build issues.

@fearful-symmetry
Copy link
Contributor Author

Oops, forgot to change the tests after I fixed the mapping.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

LGTM, wait for green

Copy link
Contributor

@kaiyan-sheng kaiyan-sheng left a comment

Choose a reason for hiding this comment

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

👍 LGTM now!

@fearful-symmetry fearful-symmetry requested review from a team, exekias, sayden, kaiyan-sheng and jsoriano and removed request for kaiyan-sheng June 11, 2019 15:29
@fearful-symmetry
Copy link
Contributor Author

Okay, that should be the last of the bugfixes and updates.

@fearful-symmetry fearful-symmetry merged commit 260f095 into elastic:master Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Metricbeat Metricbeat Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants