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

Add process monitor capabilities to flows (#541) #7507

Merged
merged 1 commit into from
Jul 9, 2018

Conversation

adriansr
Copy link
Contributor

@adriansr adriansr commented Jul 4, 2018

Flows are updated to include information about the local processes that generate them.

When one or both ends of a flow is identified as a local process, this feature will add the following fields:

  • "proc": Process name for the server-side of the flow, as set up in packetbeat.procs.monitored.

  • "cmdline": Command-line for the local process on the server-side of the flow.

  • "client_proc": Process name for the client-side of the flow, as set up in packetbeat.procs.monitored.

  • "client_cmdline": Command-line for the local process on the client-side of the flow.

Partially addresses #541

Flows are updated to include information about the local processes that
generate them.

When one or both ends of a flow is identified as a local process, this
feature will add the following fields:

"proc": Process name for the server-side of the flow, as set up in packetbeat.procs.monitored.
"cmdline": Command-line for the local process on the server-side of the flow.
"client_proc": Process name for the client-side of the flow, as set up in packetbeat.procs.monitored.
"client_cmdline": Command-line for the local process on the client-side of the flow.
@adriansr adriansr force-pushed the feature/pb/flow_procs branch from 3d621df to c3cfb67 Compare July 4, 2018 09:45
@adriansr adriansr added the review label Jul 4, 2018
@ruflin
Copy link
Contributor

ruflin commented Jul 6, 2018

I wonder if we should use ECS fields here where applicable?

@adriansr
Copy link
Contributor Author

adriansr commented Jul 6, 2018

That makes complete sense, @ruflin. In this PR I just mimicked the fields names used in the other packetbeat protocols, we should create an issue to rename them all to conform to ECS

@webmat
Copy link
Contributor

webmat commented Jul 6, 2018

I'm not terribly familiar with the Beats code base yet, so take this with the appropriate grain of salt :-)

  • Are we looping over all processes on the system for every flow that gets logged?
  • Is packetbeat sampling the flows, or handling 100% of them?

These two questions have me a bit worried

@adriansr
Copy link
Contributor Author

adriansr commented Jul 6, 2018

Hi @webmat

Currently, for every logged event that has a local IP as source or destination, the TCP port is looked up in a process cache. Only if not found in this cache, then all processes are scanned for its open ports. It is an expensive operation, usually ranging from 10 ms under Linux and about 100 ms in Windows.

As processes monitoring is disabled by default, I think it makes sense to make it more precise when it's enabled, at the expense of some overhead. Previously it would only update the process list after a fixed timeout, causing some events to not be enriched with process information, especially the short-lived processes and sockets.

About the flows, yes, it's handling all of them.

Of course, there's room for improvement. Feel free to work on it :)

@webmat
Copy link
Contributor

webmat commented Jul 6, 2018

Got it, works for me if this is disabled by default. 👍

@@ -79,10 +79,18 @@
description: >
The name of the process that served the transaction.

- name: cmdline
Copy link
Member

Choose a reason for hiding this comment

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

So these are not new, correct? They were just missing from fields.yml before?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have something like the fields_check we have for metricbeat in packetbeat to detect these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, those were missing

Copy link
Member

@andrewkroh andrewkroh Jul 9, 2018

Choose a reason for hiding this comment

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

@ruflin The packetbeat system tests all appear to be checking that the fields are documented. But there are no tests with live data for the process enrichment feature (the feature is disabled when reading from pcaps since that isn't live).

self.all_fields_are_expected(jsons, self.expected_fields)

@andrewkroh andrewkroh merged commit 3e3c289 into elastic:master Jul 9, 2018
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.

4 participants