Skip to content

Add mixer adapter for Fluentd #2423

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

Merged
merged 1 commit into from
Jan 5, 2018

Conversation

jeffmendoza
Copy link
Contributor

Supports logentry types and forwards on to a listening Fluentd daemon. Uses the forward input plugin on Fluentd. Uses the github.com/fluent/fluent-logger-golang/fluent client.

Screenshot of viewing logs in Kibana via Elasticsearch:
istio-kibana

@istio-testing
Copy link
Collaborator

Hi @jeffmendoza. Thanks for your PR.

I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@rshriram
Copy link
Member

rshriram commented Jan 4, 2018

This is cool!! Thanks for the contribution..

@dcberg
Copy link
Contributor

dcberg commented Jan 4, 2018

Very nice contribution....thanks!

@codecov
Copy link

codecov bot commented Jan 4, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@62dc933). Click here to learn what that means.
The diff coverage is 75.86%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2423   +/-   ##
=========================================
  Coverage          ?   76.35%           
=========================================
  Files             ?      218           
  Lines             ?    19453           
  Branches          ?        0           
=========================================
  Hits              ?    14853           
  Misses            ?     3786           
  Partials          ?      814
Flag Coverage Δ
#broker 75.36% <ø> (?)
#mixer 76.35% <75.86%> (?)
#pilot 78.55% <ø> (?)
#security 76.19% <ø> (?)
Impacted Files Coverage Δ
mixer/adapter/fluentd/fluentd.go 75.86% <75.86%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62dc933...4bb4cc7. Read the comment docs.

@jeffmendoza
Copy link
Contributor Author

/assign @douglas-reid

@istio-merge-robot
Copy link

@jeffmendoza PR needs rebase

@istio-merge-robot istio-merge-robot added the needs-rebase Indicates a PR needs to be rebased before being merged label Jan 4, 2018
Copy link
Contributor

@douglas-reid douglas-reid left a comment

Choose a reason for hiding this comment

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

Looks pretty good. Thanks for tackling. Left a few nits, mostly around comments.

option (gogoproto.equal_all) = false;
option (gogoproto.gostring_all) = false;

message Params {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Let's add some comments here on what the fluentd adapter is for and how one might use it. Currently, this is the source of generated website documentation (a la: https://istio.io/docs/reference/config/mixer/adapters/kubernetes.html). It'd be nice to have some verbose presentation of this adapter in the Reference section.

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

@@ -10,3 +10,4 @@ servicecontrol: "istio.io/istio/mixer/adapter/servicecontrol"
stackdriver: "istio.io/istio/mixer/adapter/stackdriver"
statsd: "istio.io/istio/mixer/adapter/statsd"
stdio: "istio.io/istio/mixer/adapter/stdio"
fluentd: "istio.io/istio/mixer/adapter/fluentd"
Copy link
Contributor

Choose a reason for hiding this comment

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

question: what do you think about maintaining alphabetical ordering of this inventory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it. Done


//go:generate $GOPATH/src/istio.io/istio/bin/mixer_codegen.sh -f mixer/adapter/fluentd/config/config.proto

package fluentd
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: similar to above, can you add a Package-level comment here explaining the role of the adapter, how it is used, and what templates it implements?

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

delete(i.Variables, "tag")
}

err := h.logger.PostWithTime(tag.(string), i.Timestamp, i.Variables)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: collapse the following line, via something like:

if err := h.logger.PostWithTime(...); err != nil {
  return err
}

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

},
NewBuilder: func() adapter.HandlerBuilder { return &builder{} },
DefaultConfig: &config.Params{
Address: "localhost:24224",
Copy link
Contributor

Choose a reason for hiding this comment

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

should we move this up into a const and make it more obvious as to the default value?

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


message Params {
// Address that fluentd is listening, ex: 1.2.3.4:24224
string address = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a comment about the default value assumed by code.

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

}

for i, c := range cases {
t.Run(strconv.Itoa(i), func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just name the tests for the Address being provided? then, upon failure, I know what the input was precisely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, let me figure this out.

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

}

for i, c := range cases {
t.Run(strconv.Itoa(i), func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

as above, let's give these things reasonable names. the cases are complex enough that a readable name for each case would help others debug a bit.

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

spec:
match: "true" # match for all requests
actions:
- handler: fdhandler.fluentd
Copy link
Contributor

Choose a reason for hiding this comment

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

at some point, we considered a convention of just 'handler.*' for handlers (in the case where there would only be one). not sure on the current state of that, but it may be worth considering.

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

name: fdhandler
namespace: istio-system
spec:
address: "localhost:24224"
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the default address, right?

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, I'd like to have is here in the test configs incase someone wants to copy it

Copy link
Contributor

@douglas-reid douglas-reid left a comment

Choose a reason for hiding this comment

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

This is awesome! Can't wait to try it out.

@douglas-reid
Copy link
Contributor

/lgtm

@istio-merge-robot
Copy link

/lgtm cancel //PR changed after LGTM, removing LGTM. @douglas-reid @jeffmendoza

@istio-merge-robot istio-merge-robot removed lgtm needs-rebase Indicates a PR needs to be rebased before being merged labels Jan 5, 2018
@jeffmendoza
Copy link
Contributor Author

/retest

@istio-testing
Copy link
Collaborator

@jeffmendoza: you can't request testing unless you are a istio member.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@douglas-reid
Copy link
Contributor

/lgtm

@istio-merge-robot
Copy link

/lgtm cancel //PR changed after LGTM, removing LGTM. @douglas-reid @jeffmendoza

@jeffmendoza
Copy link
Contributor Author

Rebased again, keep getting merge conflicts as HEAD gets Gopkg.lock changes.

Supports logentry types. Connects to a listening fluentd daemon. Only
config is the address of fluentd. Uses the "Name" of the logentry as
the fluentd "tag", unless the logentry has a variable "tag". Adds a
dependency on the "github.com/fluent/fluent-logger-golang/fluent"
library.
@douglas-reid
Copy link
Contributor

/lgtm

@istio-merge-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: douglas-reid

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@istio-merge-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@istio-merge-robot
Copy link

Automatic merge from submit-queue.

@istio-merge-robot istio-merge-robot merged commit 5959336 into istio:master Jan 5, 2018
@jeffmendoza jeffmendoza deleted the fluentd-adapter branch January 5, 2018 23:18
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.

7 participants