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

fluent-plugin-loki: Restructuring and CI #2006

Merged

Conversation

Skeen
Copy link
Contributor

@Skeen Skeen commented Apr 28, 2020

What this PR does / why we need it:
This PR:

  1. Moves fluentd/fluent-plugin-grafana-loki to cmd/fluentd, as to follow the standard for the other integrations.
  2. Integrates it with the Makefile, such that the commands fluentd-plugin, fluentd-image, fluentd-push and fluentd-test are added, as they are for the fluent-bit plugin.
  3. Adds a drone-ci job to generate and keep the FluentD images up to date.

Which issue(s) this PR fixes:
Fixes #1724.

Special notes for your reviewer:
I have removed the dependency on systemd, as it seems to have only been needed for the specific configuration in systemd.conf, assuming a user needs this, they will need to create a derivative image with this as base image.

Checklist

  • Documentation added
  • Tests updated

@cyriltovena
Copy link
Contributor

Wow we really needed that !! I’ll take a look this week, thank you !

@adityacs
Copy link
Collaborator

adityacs commented Apr 29, 2020

@Skeen Thanks for this PR.

@cyriltovena I think we should also include publishing the fluentd gem to gem repository in this PR and also we can move both fluentbit and fluentd under plugins folder as discussed here #1989 WDYT?

@Skeen
Copy link
Contributor Author

Skeen commented Apr 29, 2020

@adityacs as for publishing the Flutentd gem, I'm alfraid that I won't be able to help with that. I don't have any experience with Ruby.

Also, do we want to move them right away, or would we rather do it using two PRs:

  1. This PR, which unifies the structure
  2. A new PR, which restructures and moves the plugins to a seperate folder.

I'd personally argue for two seperate PRs, mainly to keep changes simple and traceable.

@cyriltovena
Copy link
Contributor

It's ok for the gem, I can take over.

Yeah @adityacs this is a good idea, but let's send another PR for it.

@adityacs
Copy link
Collaborator

@cyriltovena Sure

.drone/drone.jsonnet Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
cmd/fluentd/Dockerfile Outdated Show resolved Hide resolved
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

I'm wondering if the default conf we are providing in the container is a good one.

Good job on the PR. I'm happy to merge it as is although I'd like to see what you think could be a better default config for fluentd.

Alternatively we can update the doc in https://github.com/grafana/loki/tree/master/docs/clients/fluentd#docker-image it's a bit out of date and could use a configuration example.

No idea why but on the second run of make fluentd-image I'm getting

bundle install --gemfile=cmd/fluentd/Gemfile --path=cmd/fluentd/vendor/bundle
You must use Bundler 2 or greater with this lockfile.
make: *** [Makefile:425: fluentd-plugin] Error 20
The command '/bin/sh -c make BUILD_IN_CONTAINER=false fluentd-plugin' returned a non-zero code: 2
make: *** [fluentd-image] Error 2

PS: would be nice to update the image in the doc too.

Skeen and others added 2 commits April 30, 2020 14:17
Co-authored-by: Cyril Tovena <cyril.tovena@gmail.com>
Co-authored-by: Cyril Tovena <cyril.tovena@gmail.com>
@Skeen
Copy link
Contributor Author

Skeen commented Apr 30, 2020

I'm wondering if the default conf we are providing in the container is a good one.

Providing default configuration files are a difficult task as usage patterns are so diverse.

... I'd like to see what you think could be a better default config for fluentd.

If it was purely up to me, i think I'd just go with the default configuration that ships with FluentD, appended with the @include loki.conf line.

The argument for this approach would be, that we do not in fact take a stand with regards to the default configuration, but rather outsource this decision to upstream, and as such, if people are displased with the default configuration, it is not our issue, but rather an issue for them to take with upstream.

The default configuration for upstream looks like this (as of fluent/fluentd:v1.9.2-debian-1.0):

<source>
  @type  forward
  @id    input1
  @label @mainstream
  port  24224
</source>

<filter **>
  @type stdout
</filter>

<label @mainstream>
  <match docker.**>
    @type file
    @id   output_docker1
    path         /fluentd/log/docker.*.log
    symlink_path /fluentd/log/docker.log
    append       true
    time_slice_format %Y%m%d
    time_slice_wait   1m
    time_format       %Y%m%dT%H%M%S%z
  </match>
  <match **>
    @type file
    @id   output1
    path         /fluentd/log/data.*.log
    symlink_path /fluentd/log/data.log
    append       true
    time_slice_format %Y%m%d
    time_slice_wait   10m
    time_format       %Y%m%dT%H%M%S%z
  </match>
</label>

Alternatively we can update the doc in https://github.com/grafana/loki/tree/master/docs/clients/fluentd#docker-image it's a bit out of date and could use a configuration example.

Assuming we switched to using upstreams default configuration file, we may also be able to refer people to upstreams documentation, and purely document the loki.confand the configuration variables defined within this file.

However changing the default configuration file in general (which is already done in this PR, by eliminating the systemd dependency), has the issue of breaking backwards compatability for users running with the default configuration file. I don't know if this is a big issue, but it could be.

An alternative solution to breaking backwards compatability, would be to deprecate the old docker registry, and create a new one with this change. - But I don't know how likely it is that users are actually using the default configuration in production environments.

@Skeen
Copy link
Contributor Author

Skeen commented Apr 30, 2020

No idea why but on the second run of make fluentd-image I'm getting

bundle install --gemfile=cmd/fluentd/Gemfile --path=cmd/fluentd/vendor/bundle
You must use Bundler 2 or greater with this lockfile.
make: *** [Makefile:425: fluentd-plugin] Error 20
The command '/bin/sh -c make BUILD_IN_CONTAINER=false fluentd-plugin' returned a non-zero code: 2
make: *** [fluentd-image] Error 2

I'm afraid I have little to no experience with Ruby or it's toolchains, but I imagine a very crude workaround would be to simply remove the lockfile if it exists before trying to bundle install ...

@cyriltovena
Copy link
Contributor

Could not find a lock file, I'll figure this out.

However changing the default configuration file in general (which is already done in this PR, by eliminating the systemd dependency), has the issue of breaking backwards compatability for users running with the default configuration file. I don't know if this is a big issue, but it could be.

Nobody is really using that image since it's wasn't pushed first, I'm not worried that you go with the suggestion you have, I like it.

@codecov-io
Copy link

codecov-io commented May 1, 2020

Codecov Report

Merging #2006 into master will decrease coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2006      +/-   ##
==========================================
- Coverage   63.83%   63.76%   -0.07%     
==========================================
  Files         132      132              
  Lines       10150    10150              
==========================================
- Hits         6479     6472       -7     
- Misses       3189     3193       +4     
- Partials      482      485       +3     
Impacted Files Coverage Δ
pkg/promtail/targets/tailer.go 73.86% <0.00%> (-4.55%) ⬇️
pkg/promtail/targets/filetarget.go 68.29% <0.00%> (-1.83%) ⬇️

@Skeen
Copy link
Contributor Author

Skeen commented May 1, 2020

@cyriltovena Am I right in assuming, that you do not expect me to make other changes before this is mergeable, or did I miss something?

.drone/drone.yml Outdated Show resolved Hide resolved
<match loki.**>
@type loki
url "#{ENV['LOKI_URL']}"
extra_labels {"env":"dev"}
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe job="fluentd" is a better default ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 244f196

@cyriltovena
Copy link
Contributor

@cyriltovena Am I right in assuming, that you do not expect me to make other changes before this is mergeable, or did I miss something?

No just have a look at the question I have.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@cyriltovena cyriltovena merged commit 33a8152 into grafana:master May 1, 2020
@cyriltovena
Copy link
Contributor

If you're up for a bit of documentation improvement that would greatly help again Thank you for this !

@Skeen Skeen deleted the feature/docker-image-fluentd-amd64 branch May 2, 2020 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI steps to push fluentd image with Loki output plugin
4 participants