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

Collect version metadata for Fluentd #5057

Merged
merged 7 commits into from
Nov 25, 2019

Conversation

florimondmanca
Copy link
Contributor

@florimondmanca florimondmanca commented Nov 21, 2019

What does this PR do?

  • Collect version metadata for the Fluentd integration.

Motivation

  • Ongoing effort to collect version metadata for Inventories across all integrations.

Additional Notes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached

@codecov
Copy link

codecov bot commented Nov 21, 2019

Codecov Report

Merging #5057 into master will increase coverage by 9.12%.
The diff coverage is 96.49%.

Impacted Files Coverage Δ
fluentd/datadog_checks/fluentd/fluentd.py 92.64% <100%> (+3.28%) ⬆️
fluentd/tests/common.py 100% <100%> (ø) ⬆️
fluentd/tests/test_metadata.py 100% <100%> (ø)
fluentd/tests/mock/fluentd_version.py 100% <100%> (ø)
fluentd/tests/conftest.py 83.33% <33.33%> (-16.67%) ⬇️
fluentd/tests/test_unit.py 100% <0%> (ø) ⬆️
fluentd/tests/test_integration_and_e2e.py 85% <0%> (ø) ⬆️
fluentd/datadog_checks/fluentd/__init__.py 100% <0%> (ø) ⬆️
... and 845 more

@florimondmanca florimondmanca force-pushed the florimond/fluentd-version-metadata branch from eb66d12 to 92f7106 Compare November 22, 2019 13:41
@florimondmanca florimondmanca marked this pull request as ready for review November 22, 2019 13:42
@florimondmanca florimondmanca requested review from a team as code owners November 22, 2019 13:42
@florimondmanca florimondmanca force-pushed the florimond/fluentd-version-metadata branch from 92f7106 to 2d14166 Compare November 22, 2019 13:49
@florimondmanca florimondmanca changed the title [Fluentd] Collect version metadata Collect version metadata for Fluentd Nov 22, 2019
Copy link
Member

@AlexandreYang AlexandreYang left a comment

Choose a reason for hiding this comment

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

Looks good overall 👍 , few comments.

command = self._fluentd_command + ['--version']

try:
out, _, _ = get_subprocess_output(command, self.log, False)
Copy link
Member

Choose a reason for hiding this comment

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

It seems the the api doesn't provide currently the version, but can be added easily upstream here, example:

      def config_json(req)
        obj = {
          'pid' => Process.pid,
          'ppid' => Process.ppid
          'version' => Fluent::VERSION
        }.merge(@agent.fluentd_opts)
        opts = build_option(req)

        render_json(obj, pretty_json: opts[:pretty_json])
      end

https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/in_monitor_agent.rb#L65-L68

Even if we push this change upstream, it will be available only for new versions, so we will still need to retrieve versions via command line for old versions.

Copy link
Contributor Author

@florimondmanca florimondmanca Nov 22, 2019

Choose a reason for hiding this comment

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

Yup. I'll open an issue (or most likely a PR directly) on the fluentd repo to discuss adding the version to their monitoring REST API.

Agreed that this is not a blocker w.r.t. this PR, though? (i.e. we can add the API-based version lookup later.)

Copy link
Contributor Author

@florimondmanca florimondmanca Nov 25, 2019

Choose a reason for hiding this comment

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

@AlexandreYang I opened fluent/fluentd#2705 and fluent/fluentd#2706 on the Fluentd repo.

Will discuss there whether supporting accessing a remote Fluentd instance makes any sense at all from a monitoring perspective.

I'm now less sure that it can actually be a possible setup: most examples from the Fluentd monitoring docs show calls to localhost or similar.

So, if people always only install the integration on the host where Fluentd is installed, then the benefits we'd get from using the API are less clear IMO.

ofek
ofek previously approved these changes Nov 22, 2019
@l0k0ms
Copy link
Contributor

l0k0ms commented Nov 25, 2019

hello, is there a reason why we add this parameter in the init_config and in the instance section ? :)

@florimondmanca
Copy link
Contributor Author

florimondmanca commented Nov 25, 2019

Hi @l0k0ms, thanks for looking at this.

The fluentd parameter allows users to specify how the integration should call into Fluentd to retrieve its version. By default it should use the fluentd shell command, but users may have Fluentd locally available elsewhere, e.g. in a container or a path to a custom binary (as documented in the example config file).

On our side, we use it to test various cases — e.g. what happens if the Fluentd command does not exist, or if the command returns unexpected output?

This technique is currently in use in some other integrations, e.g. Gunicorn (see #4968 for discussion) and cassandra-nodetool.

@l0k0ms
Copy link
Contributor

l0k0ms commented Nov 25, 2019

@florimondmanca ohhhh i missed that.. many thanks for the clarification :) Doc wise this PR is g2g

AlexandreYang
AlexandreYang previously approved these changes Nov 25, 2019
@florimondmanca florimondmanca dismissed stale reviews from AlexandreYang and ofek via 3083b6a November 25, 2019 13:13
@florimondmanca florimondmanca merged commit db6e09b into master Nov 25, 2019
@florimondmanca florimondmanca deleted the florimond/fluentd-version-metadata branch November 25, 2019 15:45
@bai
Copy link

bai commented Mar 11, 2020

👋Given that "remote version" PR has been merged into fluentd upstream, is there any way to make datadog agent use it instead of shelling out to fluentd --version?

It seems like there's no way to disable this version check and at 15k+ hosts we seem to be having a lot of logging noise about those failures:

2020-03-11 03:46:53 UTC | CORE | WARN | (pkg/collector/python/datadog_agent.go:118 in LogMessage) | fluentd:edfda3e12aed702d | (fluentd.py:117) | fluentd version not found in stdout: ``

Running datadog-agent on kubernetes so naturally no fluentd binary available within datadog container.

@florimondmanca
Copy link
Contributor Author

florimondmanca commented Mar 11, 2020

Hi @bai, thanks for the heads up!

You're correct, upstream PR fluent/fluentd#2706 got merged and got released as part of Fluentd v1.8.0 in December (see changelog).

This means we can look at using the new REST endpoint in priority, and fallback to a shell command for older Fluentd installs.

We'd also need to update the integration to honor any enable_metadata_collection flag set in the Agent config. Unfortunately this is not checked in the code yet so I can't recommend a workaround for noisy logs yet.

We'll try to take a look at these items soon, and report back! Thanks.

@hithwen
Copy link
Contributor

hithwen commented Mar 16, 2020

Disabling collection done in #6061

@hithwen
Copy link
Contributor

hithwen commented Mar 16, 2020

REST call added in #6062

@hithwen
Copy link
Contributor

hithwen commented Mar 18, 2020

@bai Fluentd check with latest changes is being released. Version is 1.6.0. You can install it with the integration command

@bai
Copy link

bai commented Mar 18, 2020

Many thanks, this is really helpful 🙏

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.

6 participants