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

Add application name field into output configuration #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/com/wizecore/graylog2/plugin/SyslogOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class SyslogOutput implements MessageOutput {
private SyslogIF syslog;
private String format;
private MessageSender sender;
private String appName;

public static MessageSender createSender(String fmt, Configuration conf) {
try {
Expand Down Expand Up @@ -91,6 +92,10 @@ public SyslogOutput(@Assisted Stream stream, @Assisted Configuration conf) {
if (format == null || format.equals("")) {
format = "plain";
}
appName = conf.getString("applicationName");
if (appName == null || appName.equals("")) {
appName = "server";
}

log.info("Creating syslog output " + protocol + "://" + host + ":" + port + ", format " + format);
SyslogConfigIF config = null;
Expand Down Expand Up @@ -142,6 +147,7 @@ public SyslogOutput(@Assisted Stream stream, @Assisted Configuration conf) {
}
config.setMaxMessageLength(maxlen);
config.setTruncateMessage(true);
config.setLocalName(appName);

String hash = protocol + "_" + host + "_" + port + "_" + format;
syslog = Syslog.exists(hash) ? Syslog.getInstance(hash) : Syslog.createInstance(hash, config);
Expand Down Expand Up @@ -314,6 +320,8 @@ public ConfigurationRequest getRequestedConfiguration() {
"Message format. For detailed explanation, see https://github.com/wizecore/graylog2-output-syslog",
ConfigurationField.Optional.NOT_OPTIONAL)
);

configurationRequest.addField(new TextField("applicationName", "Application name", "server", "Application identifier for syslog", ConfigurationField.Optional.OPTIONAL));
configurationRequest.addField(new BooleanField("transparentFormatRemoveHeader", "Remove header (only for transparent)", false, "Do not insert header when it forwards the message content."));

configurationRequest.addField(new TextField("maxlen", "Maximum message length", "", "Maximum message (body) length. Longer messages will be truncated. If not specified defaults to 16384 bytes.", ConfigurationField.Optional.OPTIONAL));
Expand Down