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

filebeat/input/udp: add initial UDP metrics support #33870

Merged
merged 2 commits into from
Dec 1, 2022

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented Nov 30, 2022

What does this PR do?

This adds metrics for UDP packet count and total bytes, and histograms for time required to process UDP packets prior to acking from a publication and time between UDP packet arrivals.

Why is it important?

This allows us to help users configure their systems to match the requirements that they have.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@efd6 efd6 added enhancement Filebeat Filebeat Team:Security-External Integrations backport-skip Skip notification from the automated backport with mergify 8.7-candidate labels Nov 30, 2022
@efd6 efd6 requested a review from andrewkroh November 30, 2022 00:45
@efd6 efd6 self-assigned this Nov 30, 2022
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Nov 30, 2022
@efd6 efd6 requested a review from a team November 30, 2022 00:46
}, nil
}

func configID(config *conf.C) (string, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is probably a good thing to factor out into inputmon.

}, nil
}

func configID(config *conf.C) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I didn't realize that this input is not converted to the v2.Input interface that provides an ID. Can you please scope what the effort would be to convert it to the new interface.

Copy link
Contributor Author

@efd6 efd6 Nov 30, 2022

Choose a reason for hiding this comment

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

It looks reasonably straight forward. The only inputs here that are v2 are filestream, journald, kafka, unix and winlog. The update would be better in another PR.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Nov 30, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-12-01T03:51:21.881+0000

  • Duration: 70 min 1 sec

Test stats 🧪

Test Results
Failed 0
Passed 7133
Skipped 738
Total 7871

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

This adds metrics for UDP packet count and total bytes, and histograms
for time required to process UDP packets prior to acking from a
publication and time between UDP packet arrivals.
@efd6 efd6 marked this pull request as ready for review November 30, 2022 03:36
@efd6 efd6 requested a review from a team as a code owner November 30, 2022 03:37
@efd6 efd6 requested review from belimawr and rdner and removed request for a team November 30, 2022 03:37
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

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.

This looks good. I have some naming suggestions. Can you please a table to the UDP input docs that describes the metrics (the aws-s3 input doc has an example).

if id == "" {
return nil
}
reg, unreg := inputmon.NewInputRegistry("udp", id+"::"+device, nil)
Copy link
Member

Choose a reason for hiding this comment

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

For the case of Fleet where an id should be present in the config, my desire would be to have same value represented in the metrics. Could we keep the ID as is in that case (without appending a device)

reg, unreg := inputmon.NewInputRegistry("udp", id+"::"+device, nil)
out := &inputMetrics{
unregister: unreg,
bufferLen: monitoring.NewUint(reg, "udp_read_buffer_length"),
Copy link
Member

Choose a reason for hiding this comment

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

Our monitoring package does not have the concept of a gauge so I have been suffixing new gauges with _gauge. This gives you a quick hint how this value should be interpreted. It also hints to the monitoring log reporter that it should not compute a delta between the previous sample when logging this value. So can you add a suffix to this one.

Register("histogram", metrics.NewHistogram(out.arrivalPeriod))
_ = adapter.NewGoMetrics(reg, "udp_processing_time", adapter.Accept).
Register("histogram", metrics.NewHistogram(out.processingTime))

Copy link
Member

@andrewkroh andrewkroh Dec 1, 2022

Choose a reason for hiding this comment

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

Let me propose some slightly more generic names. Before we ship this in the next release I plan to look across the inputs to see if there are opportunities for alignment on naming.

  • received_bytes_total
  • received_events_total - My thinking is that s/packet/events/ will be more generic and applicable across more inputs.
  • arrival_period
  • processing_time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • received_packets_total
  • received_events_total - My thinking is that s/packet/events/ will be more generic and applicable across more

Is the first of these intended to be received_bytes_total?

Copy link
Member

@andrewkroh andrewkroh Dec 1, 2022

Choose a reason for hiding this comment

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

Yep. That should have been received_bytes_total. (updated original comment)

@sonarcloud
Copy link

sonarcloud bot commented Dec 1, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@efd6 efd6 merged commit f2e20e9 into elastic:main Dec 1, 2022
}

func (m *inputMetrics) close() {
if m != nil {
Copy link
Contributor Author

@efd6 efd6 Dec 1, 2022

Choose a reason for hiding this comment

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

Ooops. Will send a fix. #33920

chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
This adds metrics for UDP packet count and total bytes, and histograms
for time required to process UDP packets prior to acking from a
publication and time between UDP packet arrivals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.7-candidate backport-skip Skip notification from the automated backport with mergify enhancement Filebeat Filebeat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants