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

Update log events and its handling #1405

Merged
merged 9 commits into from
Jan 10, 2017
Merged

Update log events and its handling #1405

merged 9 commits into from
Jan 10, 2017

Conversation

tagomoris
Copy link
Member

There are some issues and unexpected behavior about log events (fluent.** events).
This change is to fix these problems and add features.

Added features and changes:

  • logger emits log events into @FLUENT_LOG labels if exists
    • In that sections, mis-matched logs will be ignored without warnings (missed tags are warned at startup)
    • This behavior estimates log levels of standard loggers
  • Log events will NOT be emitted before completion of startup (including #configure and #start of each plugiins), and after entering shutdown sequence (#stop, #shutdown...)
    • --log-event-verbose (or log_event_verbose in system config) turns log events on even in startup and shutting down
  • Fix logger to prohibit changing tag prefix from "fluent"
    • There is no use-case to change that tag prefix

Fixes #485, #1038

…events only when engine is running)

* fix a bug not to enable log events only with "match fluent.**" sections
  * fixed code will enable log events only with "match fluent.info" sections
* route fluent.** events to @FLUENT_LOG label event router if exists
  * route these events to top-level fluent.** if @FLUENT_LOG missing
  * in @FLUENT_LOG section, events not matched will be ignored (assuming log-level-ish behavior)
  * both in @FLUENT_LOG and in top-level, non-matched log event tags will be warned at startup
* disable log events in default, and enable it after starting up Engine
  * it prevent to raise unexpected errors by emitting events to plugins already shut-down
@tagomoris tagomoris added enhancement Feature request or improve operations v0.14 labels Jan 6, 2017
@tagomoris
Copy link
Member Author

@repeatedly could you review this change?

record = map.dup
record.keys.each {|key|
record[key] = record[key].inspect unless record[key].respond_to?(:to_msgpack)
}
record['message'] = message.dup
@engine.push_log_event("#{@tag}.#{level}", time.to_i, record)
@engine.push_log_event("#{LOG_EVENT_TAG_PREFIX}.#{level}", time.to_i, record)
Copy link
Member

Choose a reason for hiding this comment

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

Should we use EventTime for time and passing it to push_log_event without to_i call?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right... I added a commit to emit events with Fluent::EventTime.from_time(time).

@@ -158,35 +159,5 @@ def emit_error_event(tag, time, record, error)

def handle_emits_error(tag, es, error)
end

class NoMatchMatch
Copy link
Member

Choose a reason for hiding this comment

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

fluent-plugin-reemit uses this class directly. Should keep with constant value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. Why do the such thing...

Copy link
Member Author

@tagomoris tagomoris Jan 10, 2017

Choose a reason for hiding this comment

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

I checked the code of out_reemit. It doesn't refer Fluent::NoMatchMatch.
(It just refer Fluent::EngineClass::NoMatchMatch in V10Engine).
https://github.com/sonots/fluent-plugin-reemit/blob/master/lib/fluent/plugin/out_reemit.rb

Isn't it?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see.
I missed the if condition for versions.

unmatched_tags = Fluent::Log.event_tags.select{|t| !@log_event_router.match?(t) }
unless unmatched_tags.empty?
$log.warn "match for some tags of log events are not defined (to be ignored)", tags: unmatched_tags
end
Copy link
Member

Choose a reason for hiding this comment

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

Check tag typo is better. Currently, there is no warning with following conf.

<label @FLUENT_LOG>
  <match fleunt.info>
    @type stdout
  </match>
</label>

Log example: There is no 'fluent' prefix <match> in <label @FLUENT_LOG>. Check typo.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the code to warn that <label @FLUENT_LOG> doesn't have any matches for fluent.* tags.

@tagomoris
Copy link
Member Author

I'll merge this after CI green.

@tagomoris tagomoris merged commit 26c4dc4 into master Jan 10, 2017
@tagomoris tagomoris deleted the fix-log-event-handling branch January 10, 2017 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improve operations v0.14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A counter-intuitive behavior for fluent.(error|warn|info|trace) logs
2 participants