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

fearful-symmetry commented Jun 5, 2019

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 requested a review from elastic/integrations Jun 5, 2019
@fearful-symmetry fearful-symmetry requested a review from elastic/beats as a code owner Jun 5, 2019
@fearful-symmetry fearful-symmetry self-assigned this Jun 5, 2019
Copy link
Member

exekias left a comment

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),

This comment has been minimized.

Copy link
@exekias

exekias Jun 6, 2019

Member

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

This comment has been minimized.

Copy link
@fearful-symmetry

fearful-symmetry Jun 6, 2019

Author Contributor

It is!

This comment has been minimized.

Copy link
@jsoriano

jsoriano Jun 7, 2019

Member

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 fearful-symmetry force-pushed the fearful-symmetry:entropy-metricset branch from beb2aad to 1611337 Jun 6, 2019
@fearful-symmetry fearful-symmetry requested review from exekias and elastic/integrations Jun 6, 2019
@fearful-symmetry

This comment has been minimized.

Copy link
Contributor Author

fearful-symmetry commented Jun 6, 2019

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

@exekias
exekias approved these changes Jun 6, 2019
@fearful-symmetry fearful-symmetry requested review from kaiyan-sheng and elastic/integrations Jun 6, 2019
@sayden
sayden approved these changes Jun 7, 2019
Copy link
Contributor

sayden left a comment

LGTM

Copy link
Member

jsoriano left a comment

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": {

This comment has been minimized.

Copy link
@jsoriano

jsoriano Jun 7, 2019

Member

Do we want this double entropy level?

This comment has been minimized.

Copy link
@exekias

exekias Jun 7, 2019

Member

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),

This comment has been minimized.

Copy link
@jsoriano

jsoriano Jun 7, 2019

Member

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.

This comment has been minimized.

Copy link
@jsoriano

jsoriano Jun 7, 2019

Member

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

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

This comment has been minimized.

Copy link
Contributor Author

fearful-symmetry commented Jun 7, 2019

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 fearful-symmetry requested a review from jsoriano Jun 7, 2019
@fearful-symmetry

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

fearful-symmetry commented Jun 7, 2019

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

@fearful-symmetry

This comment has been minimized.

Copy link
Contributor Author

fearful-symmetry commented Jun 7, 2019

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

Copy link
Member

jsoriano left a comment

LGTM, wait for green

Copy link
Contributor

kaiyan-sheng left a comment

👍 LGTM now!

@fearful-symmetry fearful-symmetry requested review from elastic/integrations, exekias, sayden, kaiyan-sheng and jsoriano and removed request for kaiyan-sheng Jun 11, 2019
@fearful-symmetry

This comment has been minimized.

Copy link
Contributor Author

fearful-symmetry commented Jun 11, 2019

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

@fearful-symmetry fearful-symmetry merged commit 260f095 into elastic:master Jun 12, 2019
5 checks passed
5 checks passed
CLA All commits in pull request signed
Details
Hound No violations found. Woof!
beats-ci Build finished.
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@zube zube bot added [zube]: Done and removed [zube]: In Review labels Jun 12, 2019
@andresrc andresrc removed the [zube]: Done label Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.