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

Expose filestream metrics together with log input #35835

Merged
merged 2 commits into from
Jun 21, 2023

Conversation

belimawr
Copy link
Contributor

@belimawr belimawr commented Jun 20, 2023

What does this PR do?

The filestream input now also exposes the following metrics:

  • filebeat.harvester.closed
  • filebeat.harvester.open_file
  • filebeat.harvester.started
  • filebeat.harvester.running

Why is it important?

The filestream input did not expose those metrics, which is very confusing, especially for users migrating from the log input

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

  1. Start Filebeat and ensure the HTTP endpoint is enabled, here is a config example:
filebeat.inputs:
  - type: filestream
    id: my-filestream-id
    enabled: true
    close.reader.after_interval: 30s
    paths:
      - /tmp/filestream*.log

output.console:
  codec.json:
    pretty: true

logging:
  to_stderr: true

http:
  enabled: true
  host: localhost
  port: 5066
  1. Create files matching the glob /tmp/filestream*.log.
  2. Check the metrics with curl -sL http://localhost:5066/stats | jq '.[].harvester | select(.!=null)'
  3. Check the monitoring log metrics contains the correct values, look for entries like:
{"log.level":"info","@timestamp":"2023-06-20T18:36:14.044+0200","log.logger":"monitoring","log.origin":{"file.name":"log/log.go","file.line":187},"message":"Non-zero metrics in the last 30s","service.name":"filebeat","monitoring":{"metrics":{"beat":{"cgroup":{"cpu":{"id":"emacs.service"},"memory":{"id":"emacs.service","mem":{"usage":{"bytes":26226442240}}}},"cpu":{"system":{"ticks":20,"time":{"ms":20}},"total":{"ticks":30,"time":{"ms":30},"value":30},"user":{"ticks":10,"time":{"ms":10}}},"handles":{"limit":{"hard":524288,"soft":524288},"open":12},"info":{"ephemeral_id":"402cd7c0-145a-48fd-bda2-553f979af7a3","name":"filebeat","uptime":{"ms":30016},"version":"8.9.0"},"memstats":{"gc_next":11980576,"memory_alloc":7224144,"memory_sys":26326280,"memory_total":15859808,"rss":64663552},"runtime":{"goroutines":32}},"filebeat":{"events":{"active":0,"added":2,"done":2},"harvester":{"open_files":2,"running":2,"started":2}},"libbeat":{"config":{"module":{"running":0}},"output":{"events":{"acked":1,"active":0,"batches":1,"total":1},"type":"console","write":{"bytes":616}},"pipeline":{"clients":3,"events":{"active":0,"filtered":1,"published":1,"total":2},"queue":{"acked":1,"max_events":4096}}},"registrar":{"states":{"current":1,"update":1},"writes":{"success":1,"total":1}},"system":{"cpu":{"cores":16},"load":{"1":4.3,"15":3.85,"5":4.06,"norm":{"1":0.2688,"15":0.2406,"5":0.2537}}}},"ecs.version":"1.6.0"}}

Related issues

## Use cases
## Screenshots
## Logs

@belimawr belimawr requested a review from a team as a code owner June 20, 2023 16:37
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 20, 2023
@mergify
Copy link
Contributor

mergify bot commented Jun 20, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @belimawr? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

The filestream input now also exposes the following metrics:
- filebeat.harvester.closed
- filebeat.harvester.open_file
- filebeat.harvester.started
- filebeat.harvester.running
@belimawr belimawr force-pushed the expose-file-handles-count-filestream branch from 2a92e6f to 1c5582b Compare June 20, 2023 16:40
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 20, 2023

💚 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: 2023-06-21T14:14:01.148+0000

  • Duration: 70 min 7 sec

Test stats 🧪

Test Results
Failed 0
Passed 7987
Skipped 757
Total 8744

💚 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!)

@pierrehilbert pierrehilbert requested a review from rdner June 21, 2023 06:57
@pierrehilbert pierrehilbert added the Team:Elastic-Agent Label for the Agent team label Jun 21, 2023
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 21, 2023
@rdner
Copy link
Member

rdner commented Jun 21, 2023

@belimawr seems like some metric tests are failing now, can you have a look?

Copy link
Contributor

@michalpristas michalpristas left a comment

Choose a reason for hiding this comment

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

change looks ok,
tested also with closing files, works

@belimawr belimawr requested a review from michalpristas June 21, 2023 16:42
@belimawr
Copy link
Contributor Author

I removed the flaky test and will implement it on #35863.
I'm doing this to get it merged for the next release.

@belimawr belimawr enabled auto-merge (squash) June 21, 2023 16:45
Copy link
Collaborator

@pierrehilbert pierrehilbert left a comment

Choose a reason for hiding this comment

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

Was approved by @michalpristas before your remove the flaky test

@belimawr belimawr merged commit c7c18b3 into elastic:main Jun 21, 2023
belimawr added a commit that referenced this pull request Jun 27, 2023
…35835 (#35886)

This commit implements integration tests for filestream metrics.

It also moves the "integration test framework" from `x-pack/filebeat`
to `libbeat` and implements some improvements on it.
mergify bot pushed a commit that referenced this pull request Jul 7, 2023
…35835 (#35886)

This commit implements integration tests for filestream metrics.

It also moves the "integration test framework" from `x-pack/filebeat`
to `libbeat` and implements some improvements on it.

(cherry picked from commit e16de71)
cmacknz added a commit that referenced this pull request Jul 8, 2023
… with log input metrics #35835 (#36023)

* Tests for exposing filestream metrics together with log input metrics #35835 (#35886)

This commit implements integration tests for filestream metrics.

It also moves the "integration test framework" from `x-pack/filebeat`
to `libbeat` and implements some improvements on it.

(cherry picked from commit e16de71)

* Remove test for feature that was not backported.

---------

Co-authored-by: Tiago Queiroz <[email protected]>
Co-authored-by: Craig MacKenzie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose file handles count for log and filestream inputs
5 participants