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

[Auditbeat] Update process metricset #9139

Merged
merged 7 commits into from Dec 6, 2018

Conversation

cwurm
Copy link
Contributor

@cwurm cwurm commented Nov 16, 2018

(Sorry for the vague name - maybe I should have done this in multiple PRs, but since this is still going into the features branch I didn't want to make it too complicated.)

Following all our discussions and decisions the initial implementation of the processes metricset was rather outdated (same with host and packages). This PR basically updates it to follow the newest conventions (esp. those laid out in the now merged user metricset).

High-level changes:

  • Rename from processes to process
  • Change to single documents instead of arrays
  • Scheduled state reporting

Even though I used git mv it seems Github is showing process.go as completely new in the PR view. Since these are just two commits it might be easier to look at them directly:

  1. Rename system/processes to system/process.
  2. Change to single documents.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/secops

@cwurm cwurm mentioned this pull request Nov 16, 2018
21 tasks
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

Will finish reviewing tomorrow.

x-pack/auditbeat/module/system/process/_meta/data.json Outdated Show resolved Hide resolved
Copy link
Contributor

@webmat webmat left a comment

Choose a reason for hiding this comment

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

Please leverage process. as much as possible, and I'll be good with the PR 👍🏼

Note that I haven't looked at the code closely nor tried the module yet. I'll do that next week, when a few of the modules are available in one build.

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

Overall LGTM. We need to move some of the process fields up to the process namespace before merging.

}

func (ms *MetricSet) getProcessInfos() ([]*ProcessInfo, error) {
// TODO: Implement Processes() in go-sysinfo
Copy link
Member

Choose a reason for hiding this comment

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

When we merge to master we should collect a list of the open TODOs in the module and make sure we don't forget to address them. This one would be caught be CI once we have it running on darwin.

Copy link
Contributor Author

@cwurm cwurm Dec 4, 2018

Choose a reason for hiding this comment

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

You mean the CI will fail when there are TODO comments in the code? I've been using them quite liberally, also for minor things that we can address anytime (maybe never, to be honest).

Kind of as breadcrumbs meaning "If somebody ever touches this code again and has some spare cycles, maybe do this".

// e.g. https://github.com/elastic/go-sysinfo/blob/master/providers/darwin/process_darwin_amd64.go#L41
pids, err := process.Pids()
if err != nil {
return nil, errors.Wrap(err, "Failed to fetch the list of PIDs")
Copy link
Member

Choose a reason for hiding this comment

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

Error strings should not be capitalized. This occurs in a few places. https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - done. I seem to be doing this a lot, so I built myself a patched version of golint that works with errors.Wrap(f). Hopefully I caught all of them this time.

Copy link
Member

Choose a reason for hiding this comment

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

Nice. Hound needs this.

@cwurm
Copy link
Contributor Author

cwurm commented Dec 4, 2018

Fields are moved to top-level process. @webmat, @andrewkroh - let me know if it looks good now.

As a follow-up, process.working_directory needs to be added to fields.ecs.yml - I've added it to the existing issue.

Copy link
Contributor

@webmat webmat left a comment

Choose a reason for hiding this comment

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

Yes, this looks good. Only one last json file that seems to use start_time

x-pack/auditbeat/module/system/process/_meta/data.json Outdated Show resolved Hide resolved
@cwurm cwurm merged commit 50c0c7d into elastic:feature-auditbeat-host Dec 6, 2018
cwurm pushed a commit to cwurm/beats that referenced this pull request Dec 16, 2018
Updates the `process` metricset to follow newest conventions:

- Rename from `processes` to `process`
- Change to single documents instead of arrays
- Scheduled state reporting
- Use top-level ECS fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants