@SupportsBatching @InputRequirement(value=INPUT_FORBIDDEN) @Tags(value={"syslog","listen","udp","tcp","logs"}) @CapabilityDescription(value="Listens for Syslog messages being sent to a given port over TCP or UDP. Incoming messages are checked against regular expressions for RFC5424 and RFC3164 formatted messages. The format of each message is: (<PRIORITY>)(VERSION )(TIMESTAMP) (HOSTNAME) (BODY) where version is optional. The timestamp can be an RFC5424 timestamp with a format of \"yyyy-MM-dd\'T\'HH:mm:ss.SZ\" or \"yyyy-MM-dd\'T\'HH:mm:ss.S+hh:mm\", or it can be an RFC3164 timestamp with a format of \"MMM d HH:mm:ss\". If an incoming messages matches one of these patterns, the message will be parsed and the individual pieces will be placed in FlowFile attributes, with the original message in the content of the FlowFile. If an incoming message does not match one of these patterns it will not be parsed and the syslog.valid attribute will be set to false with the original message in the content of the FlowFile. Valid messages will be transferred on the success relationship, and invalid messages will be transferred on the invalid relationship.") @WritesAttribute(attribute="syslog.priority",description="The priority of the Syslog message.") @WritesAttribute(attribute="syslog.severity",description="The severity of the Syslog message derived from the priority.") @WritesAttribute(attribute="syslog.facility",description="The facility of the Syslog message derived from the priority.") @WritesAttribute(attribute="syslog.version",description="The optional version from the Syslog message.") @WritesAttribute(attribute="syslog.timestamp",description="The timestamp of the Syslog message.") @WritesAttribute(attribute="syslog.hostname",description="The hostname or IP address of the Syslog message.") @WritesAttribute(attribute="syslog.sender",description="The hostname of the Syslog server that sent the message.") @WritesAttribute(attribute="syslog.body",description="The body of the Syslog message, everything after the hostname.") @WritesAttribute(attribute="syslog.valid",description="An indicator of whether this message matched the expected formats. If this value is false, the other attributes will be empty and only the original message will be available in the content.") @WritesAttribute(attribute="syslog.protocol",description="The protocol over which the Syslog message was received.") @WritesAttribute(attribute="syslog.port",description="The port over which the Syslog message was received.") @WritesAttribute(attribute="mime.type",description="The mime.type of the FlowFile which will be text/plain for Syslog messages.") @SeeAlso(value={PutSyslog.class,ParseSyslog.class}) public class ListenSyslog extends AbstractSyslogProcessor
| Modifier and Type | Field and Description |
|---|---|
static PropertyDescriptor |
CLIENT_AUTH |
private static String |
DEFAULT_MIME_TYPE |
private List<PropertyDescriptor> |
descriptors |
private EventServer |
eventServer |
static PropertyDescriptor |
MAX_BATCH_SIZE |
static PropertyDescriptor |
MAX_CONNECTIONS |
static PropertyDescriptor |
MAX_MESSAGE_QUEUE_SIZE |
static PropertyDescriptor |
MAX_SOCKET_BUFFER_SIZE |
static PropertyDescriptor |
MESSAGE_DELIMITER |
private byte[] |
messageDemarcatorBytes |
static PropertyDescriptor |
PARSE_MESSAGES |
private SyslogParser |
parser |
protected static String |
RECEIVED_COUNTER |
static PropertyDescriptor |
RECV_BUFFER_SIZE |
static Relationship |
REL_INVALID |
static Relationship |
REL_SUCCESS |
private Set<Relationship> |
relationships |
static PropertyDescriptor |
SOCKET_KEEP_ALIVE |
static PropertyDescriptor |
SSL_CONTEXT_SERVICE |
protected static String |
SUCCESS_COUNTER |
private BlockingQueue<ByteArrayMessage> |
syslogEvents |
| Constructor and Description |
|---|
ListenSyslog() |
| Modifier and Type | Method and Description |
|---|---|
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
private Map<String,String> |
getDefaultAttributes(ProcessContext context) |
private Map<String,String> |
getEventAttributes(SyslogEvent event) |
private InetAddress |
getListenAddress(String networkInterfaceName) |
int |
getListeningPort() |
private ByteArrayMessage |
getMessage(ProcessSession session) |
Set<Relationship> |
getRelationships() |
List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
private String |
getTransitUri(FlowFile flowFile) |
protected void |
init(ProcessorInitializationContext context) |
void |
onPropertyModified(PropertyDescriptor descriptor,
String oldValue,
String newValue) |
void |
onScheduled(ProcessContext context) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private SyslogEvent |
parseSyslogEvent(ByteArrayMessage rawSyslogEvent) |
void |
shutdownEventServer() |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, validatepublic static final PropertyDescriptor MAX_MESSAGE_QUEUE_SIZE
public static final PropertyDescriptor RECV_BUFFER_SIZE
public static final PropertyDescriptor MAX_SOCKET_BUFFER_SIZE
public static final PropertyDescriptor MAX_CONNECTIONS
public static final PropertyDescriptor MAX_BATCH_SIZE
public static final PropertyDescriptor MESSAGE_DELIMITER
public static final PropertyDescriptor PARSE_MESSAGES
public static final PropertyDescriptor SSL_CONTEXT_SERVICE
public static final PropertyDescriptor CLIENT_AUTH
public static final PropertyDescriptor SOCKET_KEEP_ALIVE
public static final Relationship REL_SUCCESS
public static final Relationship REL_INVALID
protected static final String RECEIVED_COUNTER
protected static final String SUCCESS_COUNTER
private static final String DEFAULT_MIME_TYPE
private Set<Relationship> relationships
private List<PropertyDescriptor> descriptors
private volatile EventServer eventServer
private volatile SyslogParser parser
private volatile BlockingQueue<ByteArrayMessage> syslogEvents
private volatile byte[] messageDemarcatorBytes
protected void init(ProcessorInitializationContext context)
init in class AbstractSessionFactoryProcessorpublic Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorpublic List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentpublic void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified in interface ConfigurableComponentonPropertyModified in class AbstractConfigurableComponentprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponent@OnScheduled public void onScheduled(ProcessContext context) throws IOException
IOExceptionpublic int getListeningPort()
@OnStopped public void shutdownEventServer()
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate InetAddress getListenAddress(String networkInterfaceName) throws SocketException
SocketExceptionprivate SyslogEvent parseSyslogEvent(ByteArrayMessage rawSyslogEvent)
private ByteArrayMessage getMessage(ProcessSession session)
private Map<String,String> getDefaultAttributes(ProcessContext context)
private Map<String,String> getEventAttributes(SyslogEvent event)
Copyright © 2023 Apache NiFi Project. All rights reserved.