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

Added plugin.name to fish tag log lines #11078

Closed

Conversation

andsel
Copy link
Contributor

@andsel andsel commented Aug 23, 2019

Added the plugin's name to log lines generated by the plugins


This PR adds plugin.id to log lines.

Tipical use case:

  • the user sees some log lines with plugin.id bring that id (running Java pipeline)
  • query the LS Node Info API to get source reference in config file for that id (curl -XGET "localhost:9600/_node/pipelines/main?graph=true")

How to test

  • run logstash with java pipeline, with debug log running the following pipeline.conf:
input {
  stdin {}
}

filter {
  json {
    source => "message"
  }
  sleep {
    id => "sleep_filter_123"
    time => 1
  }
}

output {
  stdout {
    codec => rubydebug
  }
}

bin/logstash -f "<config>" --java-execution=true --debug

  • in console or in logs/logstash-plain.log you should find a line like:
[DEBUG][logstash.filters.json    ][main][31543d02478e75487017793958c743af64669fe5f915ab05695717240d026f49] Running json filter {:event=>#<LogStash::Event:0x2220404c>}
  • bring that uuid and search in Node Into API with a rest call

Copy link
Member

@robbavey robbavey left a comment

Choose a reason for hiding this comment

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

Looks good so far - can we add an integration test to show the plugin name logging works?

@andsel
Copy link
Contributor Author

andsel commented Sep 4, 2019 via email

@andsel andsel force-pushed the feature/add_plugin_name_to_log_lines branch from 195b8b0 to baa5300 Compare September 5, 2019 13:24
@andsel
Copy link
Contributor Author

andsel commented Sep 6, 2019

@robbavey this is done and ready to review

@andsel andsel force-pushed the feature/add_plugin_name_to_log_lines branch from 46451b1 to bc11ab8 Compare September 20, 2019 07:49
@andsel andsel requested a review from robbavey September 20, 2019 08:28
Copy link
Member

@robbavey robbavey left a comment

Choose a reason for hiding this comment

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

I like the work done here in terms of how the extra information is added to log entries, but it might make sense to hold off on committing this PR until we have a more useful plugin.id and use that rather than include plugin.name.

My thoughts here are that plugin.name on its own may not be massively useful - the name does not unique identify plugins of the same type in a pipeline (or whether the plugin is an input, output, filter or codec), and often the log category already gives us sufficient context to do identify which plugin generated the log message (although this is less the case for more Java-centric plugins):

eg - this log entry created using a Logstash with this PR included:

[2019-09-20T10:42:05,574][INFO ][logstash.outputs.elasticsearch][main][elasticsearch] Retrying individual bulk actions that failed or were rejected by the previous bulk request. {:count=>2}

Thoughts @jsvd?

}
IO.write(@ls.application_settings_file, settings.to_yaml)
@ls.spawn_logstash("-w", "1" , "-e", config)
#@ls.wait_for_logstash
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please remove comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks @robbavey.
I've also create an issue #11154 and a PR #11155 to start discussing a useful plugin.id or plugin.name

@andsel andsel force-pushed the feature/add_plugin_name_to_log_lines branch from f4c638f to 3b83b21 Compare January 15, 2020 11:39
@andsel andsel requested a review from robbavey January 15, 2020 15:37
Copy link
Member

@robbavey robbavey left a comment

Choose a reason for hiding this comment

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

Couple of nitpicks, but other than that, looks good!

@@ -10,6 +10,7 @@
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.runtime.Block;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.ThreadContext;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: unused import

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

@@ -11,6 +11,7 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.logstash.RubyUtil;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Unused import

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

@andsel andsel requested a review from robbavey January 23, 2020 09:09
Copy link
Member

@robbavey robbavey left a comment

Choose a reason for hiding this comment

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

LGTM

@andsel andsel force-pushed the feature/add_plugin_name_to_log_lines branch from bddcb96 to 1d3c539 Compare January 23, 2020 14:43
@elasticsearch-bot
Copy link

Andrea Selva merged this into the following branches!

Branch Commits
master 6eb2517
7.x 7a22220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants