Skip to content

added simple filter on field functionality#8

Open
rrichardson wants to merge 4 commits into
packetzoom:masterfrom
rrichardson:basic_filter
Open

added simple filter on field functionality#8
rrichardson wants to merge 4 commits into
packetzoom:masterfrom
rrichardson:basic_filter

Conversation

@rrichardson
Copy link
Copy Markdown

This is a proposed enhancement to provide basic, low-cost routing and filtering capabilities to logzoom.

It doesn't do anything terribly special, it just adds a new config value to output plugins (currently es and s3) called if_has_field. If the config value is set, then it checks each inbound event for the presence of that Field before allowing it to proceed. It is very low cost, because it is only checking the field name, which is already unpacked into a hash-map. It doesn't need to construct any values from interface{}.

The use case for us is that we want to use logzoom to send business events, debug/error logs, and application profiler events through the same place and have them "routed" based on their type. In many cases a message can be destined for 1, or 2 of the 3 destinations, which is why checking for fields is pretty much the only simple way to accomplish this.

I am certainly open to ideas as to better ways to accomplish this architecturally, or alternate ways to implement this in code.

Thanks for making logzoom!

@rrichardson
Copy link
Copy Markdown
Author

Actually.. I was confused. This is the wrong approach.. I think I just need to add the Route fields filtering loop that S3 and Redis have to the ES, then I should be able to route using the presence of the field, methinks. I'll update and re-submit.

@rrichardson
Copy link
Copy Markdown
Author

I went ahead and cleaned up the route filtering logic to avoid runtime panics for all output types. It also now only does a single check of the fields map per iteration, so it is optimized a tiny bit.

indexType string
RateCounter *ratecounter.RateCounter
lastDisplayUpdate time.Time
fields map[string]string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if the value is not a string (e.g. float, integer, etc.)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What indeed. :)

I was just following the established convention that it routes only by strings. If there is a need to support routing for all JSON datatypes, it could be done with a type switch in each output plugin. IMO that's overkill unless someone has a compelling reason.

@asemt
Copy link
Copy Markdown

asemt commented Feb 3, 2017

I really like this functionality!
+1

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.

3 participants