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

check variable buffer is a Buffer instance in MonitorAgentInput #1556

Merged
merged 2 commits into from
May 7, 2017

Conversation

kazegusuri
Copy link
Contributor

in_monitor_agent plugin collects metrics by checking internal variables by instance_exec. It implicitly asserts that @buffer is a buffer instance when get metrics of buffer_queue_length and buffer_total_queued_size. If a plugin uses the variable name for other purpose, NoMethodError happens.

Example configuration with fluent-plugin-concat which uses @buffer variable as a Hash. On this configuration, doing curl 'http://localhost:24220/api/plugins.json' causes

[error]: #0 NoMethodError in monitoring plugins key="buffer_queue_length" plugin=Fluent::Plugin::ConcatFilter error_class=NoMethodError error="undefined method `queue' for {}:Hash"
<source>
  @type monitor_agent
</source>

<filter **>
   @type concat
    key message
    multiline_start_regexp /foo.bar/
    flush_interval 
    stream_identity_key container_id
    timeout_label @OUT
</filter>

@mururu
Copy link
Member

mururu commented Apr 30, 2017

Good catch! Could you add tests for such case?

@kazegusuri
Copy link
Contributor Author

Thanks. Addeda test, PTAL.

@repeatedly repeatedly merged commit 182bebd into fluent:master May 7, 2017
@repeatedly
Copy link
Member

Thx!

@kazegusuri kazegusuri deleted the check-buffer-class branch July 1, 2017 15:13
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