├── .circleci ├── config.yml └── settings.xml ├── LICENSE ├── README.md ├── loghub-apacheclient ├── pom.xml └── src │ ├── main │ └── java │ │ └── loghub │ │ └── httpclient │ │ ├── ApacheHttpClientService.java │ │ ├── HcHttpRequest.java │ │ └── HcHttpResponse.java │ └── test │ └── java │ └── loghub │ └── httpclient │ └── TestApacheHttpClient.java ├── loghub-cbor ├── pom.xml └── src │ ├── main │ ├── java │ │ └── loghub │ │ │ ├── cbor │ │ │ ├── AbstractBase64TagHandler.java │ │ │ ├── AbstractBigIntegerTagHandler.java │ │ │ ├── AbstractIpTagHandler.java │ │ │ ├── Base64TagHandler.java │ │ │ ├── Base64UrlTagHandler.java │ │ │ ├── CborParser.java │ │ │ ├── CborSerializer.java │ │ │ ├── CborTagHandler.java │ │ │ ├── CborTagHandlerService.java │ │ │ ├── DurationTagHandler.java │ │ │ ├── EpochTagHandler.java │ │ │ ├── Ipv4TagHandler.java │ │ │ ├── Ipv6TagHandler.java │ │ │ ├── LogHubEventTagHandler.java │ │ │ ├── NegativeBigIntegerTagHandler.java │ │ │ ├── PositiveBigIntegerTagHandler.java │ │ │ ├── URITagHandler.java │ │ │ ├── UUIDTagHandler.java │ │ │ └── ZonedDateTimeTagHandler.java │ │ │ ├── decoders │ │ │ └── Cbor.java │ │ │ └── encoders │ │ │ └── Cbor.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── loghub.cbor.CborTagHandler │ └── test │ └── java │ └── loghub │ ├── cbor │ └── TestDecode.java │ ├── decoders │ └── TestCbor.java │ └── encoders │ └── TestCbor.java ├── loghub-core ├── pom.xml └── src │ ├── main │ ├── antlr4 │ │ └── loghub │ │ │ └── Route.g4 │ ├── java │ │ └── loghub │ │ │ ├── AbstractBuilder.java │ │ │ ├── AbstractCompDecomp.java │ │ │ ├── AsyncProcessor.java │ │ │ ├── BuildableConnectionContext.java │ │ │ ├── BuilderClass.java │ │ │ ├── CanBatch.java │ │ │ ├── Compressor.java │ │ │ ├── ConnectionContext.java │ │ │ ├── Dashboard.java │ │ │ ├── Decompressor.java │ │ │ ├── DiscardedEventException.java │ │ │ ├── DurationUnit.java │ │ │ ├── EventsProcessor.java │ │ │ ├── EventsRepository.java │ │ │ ├── Expression.java │ │ │ ├── Filter.java │ │ │ ├── FilterException.java │ │ │ ├── Helpers.java │ │ │ ├── IgnoredEventException.java │ │ │ ├── IpConnectionContext.java │ │ │ ├── Lambda.java │ │ │ ├── NullOrMissingValue.java │ │ │ ├── PathTree.java │ │ │ ├── PausedEvent.java │ │ │ ├── Pipeline.java │ │ │ ├── PriorityBlockingQueue.java │ │ │ ├── ProcessingException.java │ │ │ ├── Processor.java │ │ │ ├── ProcessorException.java │ │ │ ├── ShutdownTask.java │ │ │ ├── Start.java │ │ │ ├── SubPipeline.java │ │ │ ├── SystemdHandler.java │ │ │ ├── ThreadBuilder.java │ │ │ ├── UncheckedProcessorException.java │ │ │ ├── VarFormatter.java │ │ │ ├── VariablePath.java │ │ │ ├── XmlHandler.java │ │ │ ├── cloners │ │ │ ├── CloneArray.java │ │ │ ├── CloneCollection.java │ │ │ ├── CloneOpaque.java │ │ │ ├── Cloner.java │ │ │ ├── DeepCloner.java │ │ │ ├── EnumMapCloner.java │ │ │ ├── Immutable.java │ │ │ ├── MapCloner.java │ │ │ ├── NotClonableException.java │ │ │ ├── ObjectFaster.java │ │ │ └── SSLSessionCloned.java │ │ │ ├── commands │ │ │ ├── BaseParameters.java │ │ │ ├── BaseParametersRunner.java │ │ │ ├── CommandJwt.java │ │ │ ├── CommandLineHandler.java │ │ │ ├── CommandPassword.java │ │ │ ├── CommandRunner.java │ │ │ ├── ExitCode.java │ │ │ ├── Launch.java │ │ │ ├── Parser.java │ │ │ ├── TestPipeline.java │ │ │ └── TimePattern.java │ │ │ ├── configuration │ │ │ ├── BeansManager.java │ │ │ ├── BeansPostProcess.java │ │ │ ├── CacheManager.java │ │ │ ├── CharSupport.java │ │ │ ├── ConfigErrorListener.java │ │ │ ├── ConfigException.java │ │ │ ├── ConfigListener.java │ │ │ ├── Configuration.java │ │ │ ├── ConfigurationProperties.java │ │ │ ├── ExpressionBuilder.java │ │ │ ├── GrammarParserFiltering.java │ │ │ ├── Properties.java │ │ │ ├── SecretsHandler.java │ │ │ └── TestEventProcessing.java │ │ │ ├── datetime │ │ │ ├── AppendOffset.java │ │ │ ├── DatetimeProcessor.java │ │ │ ├── DatetimeProcessorCustom.java │ │ │ ├── DatetimeProcessorIso8601.java │ │ │ ├── DatetimeProcessorRfc3164.java │ │ │ ├── DatetimeProcessorRfc822.java │ │ │ ├── DatetimeProcessorUnixMillis.java │ │ │ ├── DatetimeProcessorUnixNano.java │ │ │ ├── DatetimeProcessorUnixSeconds.java │ │ │ ├── DatetimeProcessorUtil.java │ │ │ ├── JacksonModule.java │ │ │ ├── NamedPatterns.java │ │ │ ├── NumericDateTimeProcessor.java │ │ │ ├── ParseTimeZone.java │ │ │ ├── ParsingContext.java │ │ │ └── PatternResolver.java │ │ │ ├── decoders │ │ │ ├── AbstractJacksonDecoder.java │ │ │ ├── AbstractStringJackson.java │ │ │ ├── AbstractXmlDecoder.java │ │ │ ├── DecodeException.java │ │ │ ├── Decoder.java │ │ │ ├── JournaldExport.java │ │ │ ├── Json.java │ │ │ ├── Msgpack.java │ │ │ ├── Properties.java │ │ │ ├── Raw.java │ │ │ ├── SerializedObject.java │ │ │ ├── StringCodec.java │ │ │ ├── TextDecoder.java │ │ │ ├── XmlDom.java │ │ │ └── XmlXslt.java │ │ │ ├── encoders │ │ │ ├── AbstractJacksonEncoder.java │ │ │ ├── EncodeException.java │ │ │ ├── Encoder.java │ │ │ ├── EvalExpression.java │ │ │ ├── Gelf.java │ │ │ ├── Msgpack.java │ │ │ ├── Syslog.java │ │ │ ├── ToJson.java │ │ │ └── Xml.java │ │ │ ├── events │ │ │ ├── Event.java │ │ │ ├── EventBuilder.java │ │ │ ├── EventFinalizer.java │ │ │ ├── EventInstance.java │ │ │ ├── EventWrapper.java │ │ │ ├── EventsFactory.java │ │ │ ├── ExecutionStackElement.java │ │ │ ├── LockedConnectionContext.java │ │ │ ├── PostSubPipline.java │ │ │ └── PreSubPipline.java │ │ │ ├── groovy │ │ │ ├── BooleanMetaClass.java │ │ │ ├── CharacterMetaClass.java │ │ │ ├── CollectionMetaClass.java │ │ │ ├── GroovyMethods.java │ │ │ ├── LoghubMetaClass.java │ │ │ ├── NumberMetaClass.java │ │ │ ├── ObjectMetaClass.java │ │ │ ├── StringMetaClass.java │ │ │ └── TemporalMetaClass.java │ │ │ ├── httpclient │ │ │ ├── AbstractHttpClientService.java │ │ │ ├── ContentType.java │ │ │ ├── ContentWriter.java │ │ │ ├── HttpRequest.java │ │ │ ├── HttpResponse.java │ │ │ ├── JHttpRequest.java │ │ │ ├── JHttpResponse.java │ │ │ └── JavaHttpClientService.java │ │ │ ├── jackson │ │ │ ├── EventSerializer.java │ │ │ ├── JacksonBuilder.java │ │ │ ├── MsgpackTimeDeserializer.java │ │ │ ├── MsgpackTimeSerializer.java │ │ │ └── package-info.java │ │ │ ├── metrics │ │ │ ├── CustomStats.java │ │ │ ├── Description.java │ │ │ ├── DocumentedMBean.java │ │ │ ├── EventExceptionDescription.java │ │ │ ├── ExceptionsMBean.java │ │ │ ├── FullStackExceptionDescription.java │ │ │ ├── JmxService.java │ │ │ ├── MetricType.java │ │ │ ├── PipelineMBean.java │ │ │ ├── ReceivedExceptionDescription.java │ │ │ ├── ReceiverMBean.java │ │ │ ├── SenderMBean.java │ │ │ ├── Stats.java │ │ │ ├── StatsMBean.java │ │ │ └── Units.java │ │ │ ├── netty │ │ │ ├── AbstractHttpReceiver.java │ │ │ ├── BaseChannelConsumer.java │ │ │ ├── ChannelConsumer.java │ │ │ ├── CloseOnError.java │ │ │ ├── ConsumerProvider.java │ │ │ ├── ContextExtractor.java │ │ │ ├── DashboardService.java │ │ │ ├── HttpChannelConsumer.java │ │ │ ├── NettyReceiver.java │ │ │ ├── http │ │ │ │ ├── AccessControl.java │ │ │ │ ├── ContentType.java │ │ │ │ ├── FatalErrorHandler.java │ │ │ │ ├── GetMetric.java │ │ │ │ ├── GraphMetric.java │ │ │ │ ├── HstsData.java │ │ │ │ ├── HttpFilter.java │ │ │ │ ├── HttpHandler.java │ │ │ │ ├── HttpRequestFailure.java │ │ │ │ ├── HttpRequestProcessing.java │ │ │ │ ├── JmxProxy.java │ │ │ │ ├── JwtToken.java │ │ │ │ ├── NoCache.java │ │ │ │ ├── NotFound.java │ │ │ │ ├── NotSharable.java │ │ │ │ ├── RequestAccept.java │ │ │ │ ├── ResourceFiles.java │ │ │ │ ├── RootRedirect.java │ │ │ │ └── TokenFilter.java │ │ │ ├── servers │ │ │ │ └── Authenticated.java │ │ │ └── transport │ │ │ │ ├── AbstractIpTransport.java │ │ │ │ ├── AbstractUnixDomainTransport.java │ │ │ │ ├── DomainConnectionContext.java │ │ │ │ ├── EpollPollerServiceProvider.java │ │ │ │ ├── IoUringPollerServiceProvider.java │ │ │ │ ├── KQueuePollerServiceProvider.java │ │ │ │ ├── LocalPollerServiceProvider.java │ │ │ │ ├── LocalTransport.java │ │ │ │ ├── NettyTransport.java │ │ │ │ ├── NioPollerServiceProvider.java │ │ │ │ ├── OioPollerServiceProvider.java │ │ │ │ ├── POLLER.java │ │ │ │ ├── PollerServiceProvider.java │ │ │ │ ├── SctpTransport.java │ │ │ │ ├── TRANSPORT.java │ │ │ │ ├── TcpTransport.java │ │ │ │ ├── TransportEnum.java │ │ │ │ ├── UdpTransport.java │ │ │ │ ├── UnixDgramTransport.java │ │ │ │ └── UnixStreamTransport.java │ │ │ ├── processors │ │ │ ├── AnonymousSubPipeline.java │ │ │ ├── AnsiClean.java │ │ │ ├── AsyncFieldsProcessor.java │ │ │ ├── Cidr.java │ │ │ ├── Convert.java │ │ │ ├── Crlf.java │ │ │ ├── DateParser.java │ │ │ ├── DecodeUrl.java │ │ │ ├── Dissect.java │ │ │ ├── Drop.java │ │ │ ├── DurationConvert.java │ │ │ ├── Encoder.java │ │ │ ├── Etl.java │ │ │ ├── FieldsProcessor.java │ │ │ ├── Filter.java │ │ │ ├── FireEvent.java │ │ │ ├── ForEach.java │ │ │ ├── Forker.java │ │ │ ├── Forwarder.java │ │ │ ├── FutureProcessor.java │ │ │ ├── Grok.java │ │ │ ├── Hierarchical.java │ │ │ ├── Identity.java │ │ │ ├── Log.java │ │ │ ├── Log4JExtract.java │ │ │ ├── Map.java │ │ │ ├── Mapper.java │ │ │ ├── Merge.java │ │ │ ├── NamedSubPipeline.java │ │ │ ├── NettyNameResolver.java │ │ │ ├── ObjectExtractor.java │ │ │ ├── ParseCef.java │ │ │ ├── ParseJson.java │ │ │ ├── ParseXml.java │ │ │ ├── ScanBinary.java │ │ │ ├── Slicer.java │ │ │ ├── Split.java │ │ │ ├── SyslogPriority.java │ │ │ ├── Test.java │ │ │ ├── TreeWalkProcessor.java │ │ │ ├── UnstackException.java │ │ │ ├── UnwrapEvent.java │ │ │ ├── UrlParser.java │ │ │ ├── VarExtractor.java │ │ │ ├── WrapEvent.java │ │ │ ├── X509Parser.java │ │ │ └── XPathExtractor.java │ │ │ ├── receivers │ │ │ ├── AbstractNettyStream.java │ │ │ ├── Beats.java │ │ │ ├── Blocking.java │ │ │ ├── Http.java │ │ │ ├── Jfr.java │ │ │ ├── Journald.java │ │ │ ├── MultiLinesStream.java │ │ │ ├── Receiver.java │ │ │ ├── SelfDecoder.java │ │ │ ├── TcpLinesStream.java │ │ │ ├── TimeSerie.java │ │ │ ├── Udp.java │ │ │ └── ZMQ.java │ │ │ ├── security │ │ │ ├── AuthenticationHandler.java │ │ │ ├── JWTHandler.java │ │ │ └── ssl │ │ │ │ ├── ClientAuthentication.java │ │ │ │ ├── MultiKeyStoreProvider.java │ │ │ │ ├── MultiKeyStoreSpi.java │ │ │ │ ├── PKCS8Codec.java │ │ │ │ ├── SimpleBerCodec.java │ │ │ │ ├── SmartKeyManager.java │ │ │ │ └── SslContextBuilder.java │ │ │ ├── senders │ │ │ ├── AbstractHttpSender.java │ │ │ ├── AsyncSender.java │ │ │ ├── ElasticSearch.java │ │ │ ├── File.java │ │ │ ├── Null.java │ │ │ ├── SelfEncoder.java │ │ │ ├── SendException.java │ │ │ ├── Sender.java │ │ │ ├── Stdout.java │ │ │ ├── Tcp.java │ │ │ ├── Udp.java │ │ │ └── ZMQ.java │ │ │ ├── sources │ │ │ ├── FileMap.java │ │ │ └── Source.java │ │ │ ├── types │ │ │ ├── Dn.java │ │ │ ├── MacAddress.java │ │ │ └── MimeType.java │ │ │ └── zmq │ │ │ ├── MsgHeaders.java │ │ │ ├── ZMQCheckedException.java │ │ │ ├── ZMQHandler.java │ │ │ ├── ZMQHelper.java │ │ │ ├── ZMQSocketFactory.java │ │ │ ├── ZapDomainHandler.java │ │ │ ├── ZapReply.java │ │ │ ├── ZapRequest.java │ │ │ ├── ZapService.java │ │ │ └── ZmqConnectionContext.java │ └── resources │ │ ├── META-INF │ │ ├── mime.types │ │ └── services │ │ │ ├── loghub.commands.CommandLineHandler │ │ │ └── loghub.netty.transport.PollerServiceProvider │ │ ├── estemplate.2.json │ │ ├── estemplate.5.json │ │ ├── estemplate.6.json │ │ ├── estemplate.7.json │ │ ├── estemplate.7.notype.json │ │ ├── log4j2.xml │ │ ├── patterns │ │ ├── apache │ │ ├── aws │ │ ├── bacula │ │ ├── bro │ │ ├── exim │ │ ├── firewalls │ │ ├── haproxy │ │ ├── java │ │ ├── junos │ │ ├── mcollective │ │ ├── mcollective-patterns │ │ ├── mongodb │ │ ├── nagios │ │ ├── nodename │ │ ├── patterns │ │ ├── postgresql │ │ ├── rails │ │ ├── redis │ │ ├── ruby │ │ ├── squid │ │ ├── syslog │ │ └── time │ │ ├── propertiestype.properties │ │ ├── static │ │ ├── Lato:400,700.css │ │ ├── charts.js │ │ ├── d3.v2.min.js │ │ └── index.html │ │ └── xml2json.xsl │ └── test │ ├── java │ └── loghub │ │ ├── AbstractDashboard.java │ │ ├── BeanChecks.java │ │ ├── HttpTestServer.java │ │ ├── LogUtils.java │ │ ├── MockHttpClient.java │ │ ├── PathTreeTest.java │ │ ├── TestAbstractCompDecomp.java │ │ ├── TestConvertGlobToRegex.java │ │ ├── TestDashboard.java │ │ ├── TestDashboardHttps.java │ │ ├── TestEvent.java │ │ ├── TestIntegrated.java │ │ ├── TestMime.java │ │ ├── TestPriorityBlockingQueue.java │ │ ├── TestProcessor.java │ │ ├── TestShutdownTask.java │ │ ├── TestStringsToUrl.java │ │ ├── TestVarFormatter.java │ │ ├── TestVariablePath.java │ │ ├── TestsParseUri.java │ │ ├── Tools.java │ │ ├── ZMQFactory.java │ │ ├── ZMQFlow.java │ │ ├── ZMQSink.java │ │ ├── cloners │ │ └── TestDeepCloner.java │ │ ├── commands │ │ ├── TestCommandSecret.java │ │ ├── TestCriticalFailure.java │ │ ├── TestTester.java │ │ └── TestTimePattern.java │ │ ├── configuration │ │ ├── ConfigurationTools.java │ │ ├── TestBeanManager.java │ │ ├── TestClassLoader.java │ │ ├── TestConfigurations.java │ │ ├── TestExpressionParsing.java │ │ ├── TestLog4J.java │ │ ├── TestParser.java │ │ ├── TestSslContextConfiguration.java │ │ ├── TestWithZMQ.java │ │ └── TestWrapping.java │ │ ├── datetime │ │ ├── TestJacksonModule.java │ │ └── TestPattern.java │ │ ├── decoders │ │ ├── TestJournaldDecoder.java │ │ ├── TestJson.java │ │ ├── TestMsgpack.java │ │ ├── TestProperties.java │ │ ├── TestXmlDom.java │ │ └── TestXmlXslt.java │ │ ├── encoders │ │ ├── TestEvalExpression.java │ │ ├── TestMsgpack.java │ │ ├── TestSyslog.java │ │ ├── TestToJson.java │ │ └── TestXml.java │ │ ├── events │ │ ├── Mocker.java │ │ └── TestEventApply.java │ │ ├── httpclient │ │ └── TestJavaHttpClient.java │ │ ├── jackson │ │ └── TestEventSerializer.java │ │ ├── metrics │ │ ├── TestExceptionsDescriptions.java │ │ ├── TestJmxConnection.java │ │ └── TestJmxStats.java │ │ ├── netty │ │ ├── TestSimpleReceiver.java │ │ ├── http │ │ │ ├── TestHttp.java │ │ │ └── TestHttpSsl.java │ │ └── transport │ │ │ ├── TestPoller.java │ │ │ └── TestTransports.java │ │ ├── processors │ │ ├── TestAnsiClean.java │ │ ├── TestCidr.java │ │ ├── TestConditions.java │ │ ├── TestConvert.java │ │ ├── TestCrlf.java │ │ ├── TestDateParser.java │ │ ├── TestDissect.java │ │ ├── TestDurationConvert.java │ │ ├── TestEncoder.java │ │ ├── TestEtl.java │ │ ├── TestFailure.java │ │ ├── TestFieldsAsynchronous.java │ │ ├── TestFieldsProcessor.java │ │ ├── TestFilter.java │ │ ├── TestFire.java │ │ ├── TestForEach.java │ │ ├── TestFork.java │ │ ├── TestGrok.java │ │ ├── TestHierarchical.java │ │ ├── TestLog.java │ │ ├── TestMap.java │ │ ├── TestMapper.java │ │ ├── TestMerge.java │ │ ├── TestNettyNameResolver.java │ │ ├── TestParseCef.java │ │ ├── TestParseJson.java │ │ ├── TestPausingEvent.java │ │ ├── TestScanBinary.java │ │ ├── TestSlicer.java │ │ ├── TestSplit.java │ │ ├── TestSyslogPriority.java │ │ ├── TestTest.java │ │ ├── TestTreeWalk.java │ │ ├── TestUrlDecoders.java │ │ ├── TestUrlParser.java │ │ ├── TestVarExtractor.java │ │ ├── TestX509Parser.java │ │ └── TestXml.java │ │ ├── receivers │ │ ├── ReceiverTools.java │ │ ├── TestBeats.java │ │ ├── TestHttp.java │ │ ├── TestJfr.java │ │ ├── TestJournald.java │ │ ├── TestMultiLinesStream.java │ │ ├── TestTcpLinesStream.java │ │ ├── TestUdp.java │ │ └── TestZMQReceiver.java │ │ ├── security │ │ ├── TestHttpJwt.java │ │ ├── TestJwt.java │ │ └── ssl │ │ │ ├── TestMultiKeyStore.java │ │ │ ├── TestPKCS8Codec.java │ │ │ ├── TestSSL.java │ │ │ └── TestSmartKeyManager.java │ │ ├── senders │ │ ├── BlockingConnectionContext.java │ │ ├── InMemorySender.java │ │ ├── SenderTools.java │ │ ├── TestElasticSearch.java │ │ ├── TestFile.java │ │ ├── TestNull.java │ │ ├── TestTcp.java │ │ ├── TestUdp.java │ │ └── TestZMQSender.java │ │ ├── sources │ │ ├── TestFailed.java │ │ └── TestFileMap.java │ │ ├── types │ │ ├── TestDn.java │ │ ├── TestMacAddress.java │ │ └── TestMimeType.java │ │ └── zmq │ │ ├── TestContext.java │ │ ├── TestCurve.java │ │ ├── TestFactory.java │ │ ├── TestFailure.java │ │ ├── TestHandler.java │ │ └── TestHeader.java │ └── resources │ ├── TestProcessor.noclass │ ├── array.conf │ ├── binaryjournald │ ├── conditions.conf │ ├── crypto │ ├── domain.policy │ ├── isrg-root-x2.pem │ ├── isrgrootx1.pem │ ├── openssh.pem │ ├── package1.pem │ ├── package2.pem │ ├── package3.pem │ ├── package4.pem │ └── sampleca.pem │ ├── etl.conf │ ├── filesbuffer.conf │ ├── fire.conf │ ├── forkforward.conf │ ├── includes │ ├── .hidden.conf │ ├── a.conf │ ├── b.conf │ ├── recurse.conf │ └── sub.conf │ ├── loghub.p12 │ ├── map.conf │ ├── mapping.csv │ ├── mapping.json │ ├── pkcs8 │ ├── DSA_2048.pk8 │ ├── DSA_4096.pk8 │ ├── ED25519.pk8 │ ├── RSA_2048.pk8 │ ├── RSA_4096.pk8 │ ├── prime192v1.pk8 │ ├── prime256v1.pk8 │ ├── secp224r1.pk8 │ ├── secp384r1.pk8 │ └── secp521r1.pk8 │ ├── resolv.conf │ ├── scanbinary.conf │ ├── script.js │ ├── script.py │ ├── simple.conf │ ├── simpleinput.conf │ ├── sources.conf │ ├── sub.conf │ ├── subpipeline.conf │ ├── test.conf │ ├── testclause.conf │ ├── testlog4j.xml │ ├── twopipe.conf │ ├── types.conf │ └── wrap.conf ├── loghub-csv ├── pom.xml └── src │ ├── main │ └── java │ │ └── loghub │ │ ├── decoders │ │ └── Csv.java │ │ ├── encoders │ │ └── Csv.java │ │ ├── jackson │ │ └── CsvHelpers.java │ │ └── processors │ │ └── ParseCsv.java │ └── test │ └── java │ └── loghub │ ├── decoders │ └── TestCsv.java │ ├── encoders │ └── TestCsv.java │ └── processors │ └── TestParseCsv.java ├── loghub-espipeline ├── pom.xml └── src │ ├── main │ ├── java │ │ └── loghub │ │ │ └── commands │ │ │ └── EsPipelineConvert.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── loghub.commands.CommandLineHandler │ └── test │ └── java │ └── loghub │ └── commands │ └── TestEsPipelineConvert.java ├── loghub-executable ├── pom.xml └── src │ └── main │ ├── resources.linux │ └── META-INF │ │ └── services │ │ └── loghub.netty.transport.PollerServiceProvider │ └── resources.osx │ └── META-INF │ └── services │ └── loghub.netty.transport.PollerServiceProvider ├── loghub-geoip ├── pom.xml └── src │ ├── main │ └── java │ │ └── loghub │ │ └── processors │ │ └── Geoip2.java │ └── test │ ├── java │ └── loghub │ │ └── processors │ │ └── TestGeoip2.java │ └── resources │ ├── GeoLite2-City.mmdb │ └── GeoLite2-Country.mmdb ├── loghub-jolokia ├── pom.xml └── src │ ├── main │ ├── java │ │ └── loghub │ │ │ ├── jolokia │ │ │ ├── JolokiaDashboardService.java │ │ │ └── JolokiaEndpoint.java │ │ │ └── netty │ │ │ └── http │ │ │ └── JolokiaService.java │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── loghub.netty.DashboardService │ │ ├── jolokia-access.xml │ │ └── propertiestype.properties │ └── test │ └── java │ └── loghub │ └── TestDashboard.java ├── loghub-kafka ├── pom.xml └── src │ ├── main │ └── java │ │ └── loghub │ │ ├── kafka │ │ ├── HeadersTypes.java │ │ ├── KafkaProperties.java │ │ └── range │ │ │ ├── LongRange.java │ │ │ └── RangeCollection.java │ │ ├── receivers │ │ └── Kafka.java │ │ └── senders │ │ └── Kafka.java │ └── test │ └── java │ └── loghub │ ├── kafka │ └── range │ │ ├── TestLongRange.java │ │ └── TestRangeCollection.java │ ├── loghub │ └── kafka │ │ └── TestHeadersType.java │ ├── receivers │ └── TestKafka.java │ └── senders │ └── TestKafka.java ├── loghub-kaitai ├── pom.xml └── src │ └── test │ └── java │ ├── kaitai │ ├── EthernetFrame.java │ ├── Ipv4Packet.java │ ├── Ipv6Packet.java │ ├── PacketPpi.java │ ├── Pcap.java │ ├── ProtocolBody.java │ ├── TcpSegment.java │ └── UdpDatagram.java │ └── loghub │ └── CaptureStream.java ├── loghub-netflow ├── pom.xml └── src │ ├── main │ ├── java │ │ └── loghub │ │ │ ├── decoders │ │ │ └── Netflow.java │ │ │ └── netflow │ │ │ ├── IpfixInformationElements.java │ │ │ ├── IpfixPacket.java │ │ │ ├── Netflow5Packet.java │ │ │ ├── Netflow9Packet.java │ │ │ ├── NetflowPacket.java │ │ │ ├── NetflowRegistry.java │ │ │ ├── Template.java │ │ │ └── TemplateBasedPacket.java │ └── resources │ │ └── ipfix-information-elements.csv │ └── test │ ├── java │ └── loghub │ │ ├── decoders │ │ └── TestNetflow.java │ │ └── netflow │ │ └── IpfixInformationElementsTest.java │ └── resources │ └── packets │ ├── ipfix.dat │ ├── ipfix_test_barracuda_data256.dat │ ├── ipfix_test_barracuda_tpl.dat │ ├── ipfix_test_mikrotik_data258.dat │ ├── ipfix_test_mikrotik_data259.dat │ ├── ipfix_test_mikrotik_tpl.dat │ ├── ipfix_test_netscaler_data.dat │ ├── ipfix_test_netscaler_tpl.dat │ ├── ipfix_test_openbsd_pflow_data.dat │ ├── ipfix_test_openbsd_pflow_tpl.dat │ ├── ipfix_test_vmware_vds_data264.dat │ ├── ipfix_test_vmware_vds_data266.dat │ ├── ipfix_test_vmware_vds_data266_267.dat │ ├── ipfix_test_vmware_vds_tpl.dat │ ├── netflow5.dat │ ├── netflow5_test_invalid01.dat │ ├── netflow5_test_invalid02.dat │ ├── netflow5_test_juniper_mx80.dat │ ├── netflow5_test_microtik.dat │ ├── netflow9_cisco_asr1001x_tpl259.dat │ ├── netflow9_test_0length_fields_tpl_data.dat │ ├── netflow9_test_cisco_1941K9.dat │ ├── netflow9_test_cisco_asa_1_data.dat │ ├── netflow9_test_cisco_asa_1_tpl.dat │ ├── netflow9_test_cisco_asa_2_data.dat │ ├── netflow9_test_cisco_asa_2_tpl_26x.dat │ ├── netflow9_test_cisco_asa_2_tpl_27x.dat │ ├── netflow9_test_cisco_asr9k_data256.dat │ ├── netflow9_test_cisco_asr9k_data260.dat │ ├── netflow9_test_cisco_asr9k_opttpl256.dat │ ├── netflow9_test_cisco_asr9k_opttpl257.dat │ ├── netflow9_test_cisco_asr9k_opttpl334.dat │ ├── netflow9_test_cisco_asr9k_tpl260.dat │ ├── netflow9_test_cisco_asr9k_tpl266.dat │ ├── netflow9_test_cisco_nbar_data262.dat │ ├── netflow9_test_cisco_nbar_opttpl260.dat │ ├── netflow9_test_cisco_nbar_tpl262.dat │ ├── netflow9_test_cisco_wlc_8510_tpl_262.dat │ ├── netflow9_test_cisco_wlc_data261.dat │ ├── netflow9_test_cisco_wlc_tpl.dat │ ├── netflow9_test_fortigate_fortios_521_data256.dat │ ├── netflow9_test_fortigate_fortios_521_data257.dat │ ├── netflow9_test_fortigate_fortios_521_tpl.dat │ ├── netflow9_test_invalid01.dat │ ├── netflow9_test_juniper_srx_tplopt.dat │ ├── netflow9_test_macaddr_data.dat │ ├── netflow9_test_macaddr_tpl.dat │ ├── netflow9_test_nprobe_data.dat │ ├── netflow9_test_nprobe_dpi.dat │ ├── netflow9_test_nprobe_tpl.dat │ ├── netflow9_test_softflowd_tpl_data.dat │ ├── netflow9_test_streamcore_tpl_data256.dat │ ├── netflow9_test_streamcore_tpl_data260.dat │ ├── netflow9_test_ubnt_edgerouter_data1024.dat │ ├── netflow9_test_ubnt_edgerouter_data1025.dat │ ├── netflow9_test_ubnt_edgerouter_tpl.dat │ └── netflow9_test_valid01.dat ├── loghub-nsca ├── pom.xml └── src │ ├── main │ └── java │ │ └── loghub │ │ └── senders │ │ └── Nsca.java │ └── test │ └── java │ └── loghub │ └── senders │ └── TestNsca.java ├── loghub-onigurumaregex ├── pom.xml └── src │ ├── main │ └── java │ │ └── loghub │ │ └── processors │ │ └── OnigurumaRegex.java │ └── test │ └── java │ └── loghub │ └── processors │ └── TestOnigurumaRegex.java ├── loghub-prometheus ├── pom.xml └── src │ ├── main │ ├── java │ │ └── loghub │ │ │ └── prometheus │ │ │ ├── NettyPrometheusHttpExchange.java │ │ │ ├── PrometheusDashboardService.java │ │ │ └── PrometheusExporter.java │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── loghub.netty.DashboardService │ │ └── propertiestype.properties │ └── test │ └── java │ └── loghub │ └── prometheus │ └── TestDashboard.java ├── loghub-protobuf ├── pom.xml └── src │ ├── main │ ├── java │ │ └── loghub │ │ │ ├── decoders │ │ │ └── ProtoBuf.java │ │ │ ├── protobuf │ │ │ ├── BinaryCodec.java │ │ │ ├── OpentelemetryDecoder.java │ │ │ └── PrometheusDecoder.java │ │ │ └── receivers │ │ │ ├── OpenTelemetry.java │ │ │ └── Prometheus.java │ ├── protobuf │ │ ├── gogoproto │ │ │ └── gogo.proto │ │ └── prometheus │ │ │ ├── remote.proto │ │ │ └── types.proto │ └── resources │ │ └── prometheus.binpb │ └── test │ └── java │ ├── com │ └── google │ │ └── protobuf │ │ └── GoGoProtos.java │ ├── loghub │ ├── ProtobufTestUtils.java │ └── receivers │ │ └── TestPrometheus.java │ └── prometheus │ ├── Remote.java │ └── Types.java ├── loghub-ratelimiter ├── pom.xml └── src │ ├── main │ └── java │ │ └── loghub │ │ └── processors │ │ └── RateLimiter.java │ └── test │ └── java │ └── loghub │ └── processors │ └── TestRateLimiter.java ├── loghub-sflow ├── pom.xml └── src │ ├── main │ ├── antlr4 │ │ └── loghub │ │ │ └── xdr │ │ │ └── Xdr.g4 │ ├── java │ │ └── loghub │ │ │ ├── decoders │ │ │ └── Sflow.java │ │ │ ├── sflow │ │ │ ├── DataFormat.java │ │ │ ├── DataSource.java │ │ │ ├── HeaderProtocol.java │ │ │ ├── IANAifType.java │ │ │ ├── IfDirection.java │ │ │ ├── SFlowDatagram.java │ │ │ ├── SflowParser.java │ │ │ ├── StructureClass.java │ │ │ └── structs │ │ │ │ ├── CounterSample.java │ │ │ │ ├── DynamicStruct.java │ │ │ │ ├── ExtendedRouter.java │ │ │ │ ├── ExtendedUser.java │ │ │ │ ├── FlowSample.java │ │ │ │ ├── LagPortStats.java │ │ │ │ ├── OpaqueStruct.java │ │ │ │ ├── SampledHeader.java │ │ │ │ └── Struct.java │ │ │ └── xdr │ │ │ ├── EnumTypeSpecifier.java │ │ │ ├── FixedOpaqueTypeSpecifier.java │ │ │ ├── FixedStringTypeSpecifier.java │ │ │ ├── IndirectTypeSpecifier.java │ │ │ ├── InvalidTypeSpecifier.java │ │ │ ├── NativeType.java │ │ │ ├── NativeTypeSpecifier.java │ │ │ ├── ReadType.java │ │ │ ├── StructSpecifier.java │ │ │ ├── TypeSpecifier.java │ │ │ ├── UnionTypeSpecifier.java │ │ │ └── XdrWalker.java │ └── resources │ │ ├── structs.tsv │ │ └── xdr │ │ ├── bv-sflow.xdr │ │ ├── host.xdr │ │ ├── sflow.xdr │ │ ├── sflow_80211.xdr │ │ ├── sflow_application.xdr │ │ ├── sflow_broadcom_tables.xdr │ │ ├── sflow_datagram.xdr │ │ ├── sflow_drops.xdr │ │ ├── sflow_host_ip.xdr │ │ ├── sflow_http.xdr │ │ ├── sflow_jvm.xdr │ │ ├── sflow_lag.xdr │ │ ├── sflow_memcached.xdr │ │ ├── sflow_nvml.xdr │ │ ├── sflow_openflow.xdr │ │ ├── sflow_optics.xdr │ │ ├── sflow_transit.xdr │ │ └── sflow_tunnels.xdr │ └── test │ ├── java │ └── loghub │ │ └── decoders │ │ └── TestSflow.java │ └── resources │ └── sflow.pcap ├── loghub-snmp ├── pom.xml └── src │ ├── main │ ├── java │ │ └── loghub │ │ │ └── receivers │ │ │ └── SnmpTrap.java │ └── resources │ │ └── propertiestype.properties │ └── test │ └── java │ └── loghub │ └── receivers │ └── TestTrap.java ├── loghub-uap ├── pom.xml └── src │ ├── main │ ├── java │ │ └── loghub │ │ │ ├── CachingParser.java │ │ │ └── processors │ │ │ └── UserAgent.java │ └── resources │ │ └── ua_parser │ │ └── regexes.yaml │ └── test │ ├── java │ └── loghub │ │ └── processors │ │ └── TestUserAgent.java │ └── resources │ └── regexes.yaml ├── loghub-zabbix ├── pom.xml └── src │ ├── main │ └── java │ │ └── loghub │ │ └── senders │ │ └── ZabbixSender.java │ └── test │ └── java │ └── loghub │ └── senders │ └── ZabbixSenderTest.java ├── lombok.config └── pom.xml /.circleci/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | central 5 | ${env.MAVENCENTRAL_USERNAME} 6 | ${env.MAVENCENTRAL_PASSWORD} 7 | 8 | 9 | 10 | 11 | sonar 12 | 13 | https://sonarcloud.io 14 | ${env.SONARCLOUD_ORG} 15 | ${env.SONARCLOUD_LOGIN} 16 | 17 | 18 | 19 | skip 20 | 21 | true 22 | true 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014-2016 Fabrice Bacchella. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/AbstractBase64TagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.io.IOException; 4 | import java.util.Base64; 5 | 6 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator; 7 | 8 | public abstract class AbstractBase64TagHandler extends CborTagHandler { 9 | 10 | AbstractBase64TagHandler(int tag) { 11 | super(tag); 12 | } 13 | 14 | @Override 15 | public byte[] parse(CborParser p) throws IOException { 16 | Base64.Decoder decoder = getTag() == 33 ? Base64.getUrlDecoder() : Base64.getDecoder(); 17 | return decoder.decode(p.readText()); 18 | } 19 | 20 | @Override 21 | public void write(byte[] data, CBORGenerator p) throws IOException { 22 | Base64.Encoder encoder = getTag() == 33 ? Base64.getUrlEncoder() : Base64.getEncoder(); 23 | p.writeString(encoder.encodeToString(data)); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/AbstractBigIntegerTagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.io.IOException; 4 | import java.math.BigInteger; 5 | 6 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator; 7 | 8 | public abstract class AbstractBigIntegerTagHandler extends CborTagHandler { 9 | 10 | AbstractBigIntegerTagHandler(int tag) { 11 | super(tag); 12 | } 13 | 14 | @Override 15 | public void write(BigInteger data, CBORGenerator p) throws IOException { 16 | byte[] buffer = data.abs().toByteArray(); 17 | p.writeBinary(buffer); 18 | } 19 | 20 | @Override 21 | public BigInteger parse(CborParser p) throws IOException { 22 | byte[] data = p.readBytes(); 23 | BigInteger value = new BigInteger(data); 24 | return getTag() == 2 ? value : value.negate(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/Base64TagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | public class Base64TagHandler extends AbstractBase64TagHandler { 4 | 5 | public Base64TagHandler() { 6 | super(34); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/Base64UrlTagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | public class Base64UrlTagHandler extends AbstractBase64TagHandler { 4 | 5 | public Base64UrlTagHandler() { 6 | super(33); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/CborSerializer.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.io.IOException; 4 | 5 | import com.fasterxml.jackson.core.JsonGenerator; 6 | import com.fasterxml.jackson.databind.JsonSerializer; 7 | import com.fasterxml.jackson.databind.SerializerProvider; 8 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator; 9 | 10 | public class CborSerializer extends JsonSerializer { 11 | 12 | private final CborTagHandler tag; 13 | private final Class handledClass; 14 | 15 | public CborSerializer(CborTagHandler tag, Class handledClass) { 16 | this.tag = tag; 17 | this.handledClass = handledClass; 18 | } 19 | 20 | @Override 21 | public Class handledType() { 22 | return handledClass; 23 | } 24 | 25 | @Override 26 | @SuppressWarnings("unchecked") 27 | public void serialize(C value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 28 | ((CBORGenerator)gen).writeTag(tag.getTag()); 29 | tag.doWrite((T) value, (CBORGenerator) gen); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/CborTagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.io.IOException; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.stream.Collectors; 7 | 8 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator; 9 | 10 | import loghub.cbor.CborTagHandlerService.CustomParser; 11 | import loghub.cbor.CborTagHandlerService.CustomWriter; 12 | import lombok.Getter; 13 | import lombok.Setter; 14 | 15 | @Getter @Setter 16 | public abstract class CborTagHandler { 17 | private final int tag; 18 | private final List> targetTypes; 19 | private CustomWriter customWriter; 20 | private CustomParser customParser; 21 | 22 | CborTagHandler(int tag, Class... targetType) { 23 | this.tag = tag; 24 | this.targetTypes = List.copyOf(Arrays.stream(targetType).collect(Collectors.toList())); 25 | } 26 | 27 | T doParse(CborParser p) throws IOException { 28 | if (customParser != null && customParser.usable(p)) { 29 | return customParser.parse(p); 30 | } else { 31 | return parse(p); 32 | } 33 | } 34 | 35 | void doWrite(T data, CBORGenerator p) throws IOException { 36 | if (customWriter != null && customWriter.usable(data, p)) { 37 | customWriter.write(data, p); 38 | } else { 39 | write(data, p); 40 | } 41 | } 42 | 43 | public abstract T parse(CborParser p) throws IOException; 44 | 45 | public abstract void write(T data, CBORGenerator p) throws IOException; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/DurationTagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.io.IOException; 4 | import java.time.Duration; 5 | 6 | import com.fasterxml.jackson.core.JsonToken; 7 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator; 8 | 9 | public class DurationTagHandler extends CborTagHandler { 10 | 11 | public DurationTagHandler() { 12 | super(1002, Duration.class); 13 | } 14 | 15 | @Override 16 | public Duration parse(CborParser p) throws IOException { 17 | long seconds; 18 | long nanos; 19 | if (p.currentToken() == JsonToken.VALUE_NUMBER_INT) { 20 | seconds = p.readLong(); 21 | nanos = 0; 22 | } else if (p.currentToken() == JsonToken.VALUE_NUMBER_FLOAT) { 23 | double epochSeconds = p.readDouble(); 24 | seconds = (long) epochSeconds; 25 | nanos = (long) ((epochSeconds - seconds) * 1_000_000_000); 26 | } else { 27 | throw new IOException("Invalid token " + p.currentToken()); 28 | } 29 | return Duration.ofSeconds(seconds, nanos); 30 | } 31 | 32 | @Override 33 | public void write(Duration data, CBORGenerator p) throws IOException { 34 | double seconds = data.getSeconds(); 35 | double nanos = data.getNano(); 36 | p.writeNumber(seconds + nanos / 1_000_000_000); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/Ipv4TagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.net.Inet4Address; 4 | 5 | public class Ipv4TagHandler extends AbstractIpTagHandler { 6 | 7 | public Ipv4TagHandler() { 8 | super(52, Inet4Address.class); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/Ipv6TagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.net.Inet6Address; 4 | 5 | public class Ipv6TagHandler extends AbstractIpTagHandler { 6 | 7 | public Ipv6TagHandler() { 8 | super(54, Inet6Address.class); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/NegativeBigIntegerTagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | public class NegativeBigIntegerTagHandler extends AbstractBigIntegerTagHandler{ 4 | 5 | public NegativeBigIntegerTagHandler() { 6 | super(3); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/PositiveBigIntegerTagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | public class PositiveBigIntegerTagHandler extends AbstractBigIntegerTagHandler { 4 | 5 | public PositiveBigIntegerTagHandler() { 6 | super(2); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/URITagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.io.IOException; 4 | import java.net.URI; 5 | 6 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator; 7 | 8 | public class URITagHandler extends CborTagHandler { 9 | 10 | public URITagHandler() { 11 | super(32, URI.class); 12 | } 13 | 14 | @Override 15 | public URI parse(CborParser p) throws IOException { 16 | return java.net.URI.create(p.readText()); 17 | } 18 | 19 | @Override 20 | public void write(URI data, CBORGenerator p) throws IOException { 21 | p.writeString(data.toString()); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/UUIDTagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.io.IOException; 4 | import java.nio.ByteBuffer; 5 | import java.util.UUID; 6 | 7 | import com.fasterxml.jackson.core.JsonToken; 8 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator; 9 | 10 | public class UUIDTagHandler extends CborTagHandler { 11 | 12 | public UUIDTagHandler() { 13 | super(37, UUID.class); 14 | } 15 | 16 | @Override 17 | public UUID parse(CborParser p) throws IOException { 18 | if (p.currentToken() != JsonToken.VALUE_EMBEDDED_OBJECT) { 19 | throw new IllegalStateException("Expected embedded binary object for UUID"); 20 | } 21 | byte[] data = p.readBytes(); 22 | if (data.length != 16) { 23 | throw new IOException("UUID binary representation must be exactly 16 bytes"); 24 | } 25 | 26 | ByteBuffer buffer = ByteBuffer.wrap(data); 27 | long mostSigBits = buffer.getLong(); 28 | long leastSigBits = buffer.getLong(); 29 | return new UUID(mostSigBits, leastSigBits); 30 | } 31 | 32 | @Override 33 | public void write(UUID uuid, CBORGenerator p) throws IOException { 34 | ByteBuffer buffer = ByteBuffer.allocate(16); 35 | buffer.putLong(uuid.getMostSignificantBits()); 36 | buffer.putLong(uuid.getLeastSignificantBits()); 37 | p.writeBinary(buffer.array()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/java/loghub/cbor/ZonedDateTimeTagHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.cbor; 2 | 3 | import java.io.IOException; 4 | import java.time.ZonedDateTime; 5 | 6 | import com.fasterxml.jackson.dataformat.cbor.CBORGenerator; 7 | 8 | import loghub.datetime.DatetimeProcessor; 9 | import loghub.datetime.NamedPatterns; 10 | 11 | public class ZonedDateTimeTagHandler extends CborTagHandler { 12 | 13 | private static final DatetimeProcessor parser = DatetimeProcessor.of(NamedPatterns.ISO_NANOS); 14 | 15 | public ZonedDateTimeTagHandler() { 16 | super(0, ZonedDateTime.class); 17 | } 18 | 19 | @Override 20 | public ZonedDateTime parse(CborParser p) throws IOException { 21 | return parser.parse(p.readText()); 22 | } 23 | 24 | @Override 25 | public void write(ZonedDateTime data, CBORGenerator p) throws IOException { 26 | p.writeString(parser.print(data)); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /loghub-cbor/src/main/resources/META-INF/services/loghub.cbor.CborTagHandler: -------------------------------------------------------------------------------- 1 | loghub.cbor.UUIDTagHandler 2 | loghub.cbor.ZonedDateTimeTagHandler 3 | loghub.cbor.EpochTagHandler 4 | loghub.cbor.URITagHandler 5 | loghub.cbor.PositiveBigIntegerTagHandler 6 | loghub.cbor.NegativeBigIntegerTagHandler 7 | loghub.cbor.DurationTagHandler 8 | loghub.cbor.Base64TagHandler 9 | loghub.cbor.Base64UrlTagHandler 10 | loghub.cbor.Ipv6TagHandler 11 | loghub.cbor.Ipv4TagHandler 12 | 13 | -------------------------------------------------------------------------------- /loghub-cbor/src/test/java/loghub/decoders/TestCbor.java: -------------------------------------------------------------------------------- 1 | package loghub.decoders; 2 | 3 | import java.beans.IntrospectionException; 4 | import java.io.IOException; 5 | import java.io.StringReader; 6 | 7 | import org.apache.logging.log4j.Level; 8 | import org.apache.logging.log4j.LogManager; 9 | import org.apache.logging.log4j.Logger; 10 | import org.junit.BeforeClass; 11 | import org.junit.Test; 12 | 13 | import loghub.BeanChecks; 14 | import loghub.LogUtils; 15 | import loghub.Tools; 16 | import loghub.configuration.Configuration; 17 | import loghub.configuration.Properties; 18 | import loghub.events.EventsFactory; 19 | 20 | public class TestCbor { 21 | 22 | private static Logger logger; 23 | 24 | @BeforeClass 25 | public static void configure() { 26 | Tools.configure(); 27 | logger = LogManager.getLogger(); 28 | LogUtils.setLevel(logger, Level.TRACE, "loghub.decoders.Cbor"); 29 | } 30 | 31 | @Test 32 | public void testReadConfig() throws IOException { 33 | String configFile = "input {loghub.receivers.Udp{decoder: loghub.decoders.Cbor }} | $main pipeline[main] {}"; 34 | Properties p = Configuration.parse(new StringReader(configFile)); 35 | p.receivers.stream().findAny().get(); 36 | } 37 | 38 | @Test 39 | public void testBeans() throws IntrospectionException, ReflectiveOperationException { 40 | BeanChecks.beansCheck(logger, "loghub.decoders.Cbor" 41 | , BeanChecks.BeanInfo.build("eventsFactory", EventsFactory.class) 42 | ); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/AbstractBuilder.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | 5 | public abstract class AbstractBuilder { 6 | 7 | public abstract B build(); 8 | 9 | public static AbstractBuilder resolve(Class objectClass) throws InvocationTargetException { 10 | BuilderClass bca = objectClass.getAnnotation(BuilderClass.class); 11 | if (bca != null) { 12 | try { 13 | @SuppressWarnings("unchecked") 14 | Class> bc = (Class>) bca.value(); 15 | return bc.getConstructor().newInstance(); 16 | } catch (InstantiationException | IllegalAccessException 17 | | IllegalArgumentException | NoSuchMethodException 18 | | SecurityException | InvocationTargetException e) { 19 | throw new InvocationTargetException(e, "The builder is unusable: " + Helpers.resolveThrowableException(e)); 20 | } 21 | } else { 22 | return null; 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/AsyncProcessor.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import java.util.Optional; 4 | import java.util.concurrent.Semaphore; 5 | import java.util.function.BiConsumer; 6 | 7 | import io.netty.util.concurrent.Future; 8 | import loghub.events.Event; 9 | import lombok.Getter; 10 | 11 | public interface AsyncProcessor> { 12 | 13 | @Getter 14 | class PausedEventException extends RuntimeException { 15 | 16 | private final Future future; 17 | 18 | public PausedEventException(Future future) { 19 | super("Paused event", null, false, false); 20 | this.future = future; 21 | } 22 | 23 | public PausedEventException() { 24 | super("Paused event", null, false, false); 25 | this.future = null; 26 | } 27 | 28 | } 29 | 30 | boolean processCallback(Event event, FI content) throws ProcessorException; 31 | boolean manageException(Event event, Exception e) throws ProcessorException; 32 | /** 33 | * Will be called if the event processing timeout. If can be null, but then the processor 34 | * must handle by his own the timeout, without any external help 35 | * @return a timeout handler, or null 36 | */ 37 | BiConsumer getTimeoutHandler(); 38 | int getTimeout(); 39 | default Optional getLimiter() { 40 | return Optional.empty(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/BuilderClass.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | 7 | import static java.lang.annotation.ElementType.TYPE; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | @Documented 11 | @Retention(RUNTIME) 12 | @Target(TYPE) 13 | public @interface BuilderClass { 14 | Class> value(); 15 | } 16 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/CanBatch.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.Target; 7 | 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | @Documented 12 | @Retention(RUNTIME) 13 | @Target(TYPE) 14 | @Inherited 15 | public @interface CanBatch { 16 | boolean only() default false; 17 | } 18 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/Compressor.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import java.io.InputStream; 4 | import java.io.OutputStream; 5 | 6 | import org.apache.commons.compress.compressors.CompressorException; 7 | 8 | import lombok.EqualsAndHashCode; 9 | import lombok.Getter; 10 | import lombok.Setter; 11 | import lombok.ToString; 12 | 13 | @Getter 14 | public class Compressor extends AbstractCompDecomp { 15 | 16 | @Setter 17 | @EqualsAndHashCode(callSuper = true) @ToString 18 | public static class Builder extends AbstractCompDecomp.Builder { 19 | protected String format; 20 | public Compressor build() { 21 | return new Compressor(this); 22 | } 23 | } 24 | 25 | public static Builder getBuilder() { 26 | return new Builder(); 27 | } 28 | 29 | protected final String format; 30 | 31 | public Compressor(Builder builder) { 32 | super(builder); 33 | this.format = builder.format; 34 | } 35 | 36 | protected InputStream source(InputStream wrappedInput) { 37 | return wrappedInput; 38 | } 39 | 40 | protected OutputStream destination(OutputStream wrappedOutput) throws CompressorException { 41 | return csf.createCompressorOutputStream(format, wrappedOutput); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/ConnectionContext.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import java.security.Principal; 4 | import java.util.Optional; 5 | 6 | import loghub.decoders.Decoder; 7 | 8 | public interface ConnectionContext { 9 | 10 | ConnectionContext EMPTY = BuildableConnectionContext.EMPTY; 11 | 12 | void acknowledge(); 13 | 14 | Optional getDecoder(); 15 | 16 | A getLocalAddress(); 17 | 18 | A getRemoteAddress(); 19 | 20 | Principal getPrincipal(); 21 | 22 | Runnable getOnAcknowledge(); 23 | 24 | Optional getProperty(String property); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/Decompressor.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import java.io.InputStream; 4 | import java.io.OutputStream; 5 | 6 | import org.apache.commons.compress.compressors.CompressorException; 7 | import org.apache.commons.compress.compressors.CompressorStreamFactory; 8 | 9 | public class Decompressor extends AbstractCompDecomp { 10 | 11 | public static class Builder extends AbstractCompDecomp.Builder { 12 | public Decompressor build() { 13 | return new Decompressor(this); 14 | } 15 | } 16 | 17 | public static Builder getBuilder() { 18 | return new Builder(); 19 | } 20 | 21 | public Decompressor(Builder builder) { 22 | super(builder); 23 | } 24 | 25 | protected InputStream source(InputStream wrappedInput) throws CompressorException { 26 | return csf.createCompressorInputStream(CompressorStreamFactory.detect(wrappedInput), wrappedInput); 27 | } 28 | 29 | protected OutputStream destination(OutputStream wrappedOutput) { 30 | return wrappedOutput; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/DiscardedEventException.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | public class DiscardedEventException extends RuntimeException { 4 | public static final RuntimeException INSTANCE = new DiscardedEventException(); 5 | private DiscardedEventException() { 6 | super("Ignored Event", null, true, false); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/Filter.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | 5 | public interface Filter { 6 | byte[] filter(byte[] input, int offset, int length) throws FilterException; 7 | default byte[] filter(byte[] input) throws FilterException { 8 | return filter(input, 0, input.length); 9 | } 10 | ByteBuf filter(ByteBuf input) throws FilterException; 11 | } 12 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/FilterException.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | public class FilterException extends Exception { 4 | 5 | public FilterException(String message, Throwable cause) { 6 | super(message, cause); 7 | } 8 | 9 | public FilterException(String message) { 10 | super(message); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/IgnoredEventException.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | public class IgnoredEventException extends RuntimeException { 4 | 5 | public static final RuntimeException INSTANCE = new IgnoredEventException(); 6 | 7 | private IgnoredEventException() { 8 | super("Ignored Event", null, true, false); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/Lambda.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import lombok.Data; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | @Data 8 | public class Lambda { 9 | private final Expression expression; 10 | } 11 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/ProcessingException.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import loghub.events.Event; 4 | 5 | public interface ProcessingException { 6 | 7 | Event getEvent(); 8 | 9 | Throwable getCause(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/ProcessorException.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import loghub.events.Event; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public class ProcessorException extends Exception implements ProcessingException { 8 | 9 | private final Event event; 10 | 11 | public ProcessorException(Event event, String message, Exception root) { 12 | super(message, root); 13 | this.event = event; 14 | } 15 | 16 | public ProcessorException(Event event, String message) { 17 | super(message); 18 | this.event = event; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/SubPipeline.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | public interface SubPipeline { 4 | Pipeline getPipeline(); 5 | } 6 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/UncheckedProcessorException.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import loghub.events.Event; 4 | 5 | public class UncheckedProcessorException extends RuntimeException implements ProcessingException { 6 | 7 | public UncheckedProcessorException(ProcessorException root) { 8 | super(root.getMessage(), root); 9 | } 10 | 11 | /** 12 | * @return the event 13 | */ 14 | public Event getEvent() { 15 | return getProcessorException().getEvent(); 16 | } 17 | 18 | public ProcessorException getProcessorException() { 19 | return (ProcessorException) getCause(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/cloners/Cloner.java: -------------------------------------------------------------------------------- 1 | package loghub.cloners; 2 | 3 | @FunctionalInterface 4 | public interface Cloner { 5 | T clone(T object) throws NotClonableException; 6 | } 7 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/cloners/EnumMapCloner.java: -------------------------------------------------------------------------------- 1 | package loghub.cloners; 2 | 3 | import java.util.EnumMap; 4 | import java.util.Map; 5 | 6 | public class EnumMapCloner { 7 | 8 | @SuppressWarnings({"unchecked", "java:S1452", "java:S1319"}) 9 | public static > EnumMap clone(EnumMap map) throws NotClonableException { 10 | if (map.isEmpty()) { 11 | return new EnumMap<>(map); 12 | } else { 13 | Class enumClass = (Class) map.entrySet().iterator().next().getKey().getClass(); 14 | EnumMap newMap = new EnumMap<>(enumClass); 15 | for (Map.Entry e: map.entrySet()) { 16 | newMap.put(e.getKey(), DeepCloner.clone(e.getValue())); 17 | } 18 | return newMap; 19 | } 20 | } 21 | 22 | private EnumMapCloner() { 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/cloners/Immutable.java: -------------------------------------------------------------------------------- 1 | package loghub.cloners; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface Immutable { 11 | } 12 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/cloners/NotClonableException.java: -------------------------------------------------------------------------------- 1 | package loghub.cloners; 2 | 3 | public class NotClonableException extends Exception { 4 | 5 | NotClonableException(Class clazz, Throwable cause) { 6 | super(resolveName(clazz), cause); 7 | } 8 | 9 | private static String resolveName(Class clazz) { 10 | String name = clazz.getCanonicalName(); 11 | return name != null ? name : clazz.getName(); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/cloners/ObjectFaster.java: -------------------------------------------------------------------------------- 1 | package loghub.cloners; 2 | 3 | import java.io.Externalizable; 4 | 5 | public abstract class ObjectFaster implements Externalizable { 6 | protected T value; 7 | 8 | protected ObjectFaster(T o) { 9 | value = o; 10 | } 11 | 12 | protected ObjectFaster() { 13 | // No value 14 | } 15 | 16 | public T get() { 17 | return value; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/commands/BaseParameters.java: -------------------------------------------------------------------------------- 1 | package loghub.commands; 2 | 3 | import com.beust.jcommander.Parameter; 4 | 5 | import lombok.Getter; 6 | 7 | @Getter 8 | public class BaseParameters { 9 | 10 | @Parameter(names = {"--help", "-h"}, help = true) 11 | private boolean help = false; 12 | 13 | void reset() { 14 | help = false; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/commands/BaseParametersRunner.java: -------------------------------------------------------------------------------- 1 | package loghub.commands; 2 | 3 | import java.io.PrintWriter; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | public interface BaseParametersRunner extends CommandLineHandler { 8 | 9 | @Deprecated 10 | default int run(List mainParameters) { 11 | return run(mainParameters, new PrintWriter(System.out), new PrintWriter(System.err)); 12 | } 13 | 14 | default int run(List mainParameters, PrintWriter out, PrintWriter err) { 15 | return run(mainParameters); 16 | } 17 | 18 | default Optional getField(String name) { 19 | return Optional.empty(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/commands/CommandLineHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.commands; 2 | 3 | public interface CommandLineHandler { 4 | default void reset() { 5 | // Should be implemented, it's used by tests 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/commands/CommandRunner.java: -------------------------------------------------------------------------------- 1 | package loghub.commands; 2 | 3 | import java.io.PrintWriter; 4 | import java.util.List; 5 | 6 | import com.beust.jcommander.Parameters; 7 | 8 | public interface CommandRunner extends CommandLineHandler { 9 | 10 | @Deprecated 11 | default int run() { 12 | return run(List.of(), new PrintWriter(System.out), new PrintWriter(System.err)); 13 | } 14 | 15 | default int run(PrintWriter out, PrintWriter err) { 16 | return run(List.of(), out, err); 17 | } 18 | 19 | default int run(List mainArguments, PrintWriter out, PrintWriter err) { 20 | return run(out, err); 21 | } 22 | 23 | default String[] getVerbs() { 24 | return getClass().getAnnotation(Parameters.class).commandNames(); 25 | } 26 | default void extractFields(BaseParametersRunner cmd) { 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/commands/ExitCode.java: -------------------------------------------------------------------------------- 1 | package loghub.commands; 2 | 3 | /** 4 | * Used to define custom exit code, start at 10 because I don't know what exit code are reserved by the JVM. 5 | * For example, ExitOnOutOfMemoryError return 3. 6 | * 7 | * @author Fabrice Bacchella 8 | */ 9 | public class ExitCode { 10 | 11 | public static final int DONTEXIT = -2; 12 | public static final int IGNORE = -1; 13 | public static final int OK = 0; 14 | public static final int INVALIDCONFIGURATION = 10; 15 | public static final int FAILEDSTART = 11; 16 | public static final int FAILEDSTARTCRITICAL = 12; 17 | public static final int OPERATIONFAILED = 13; 18 | public static final int INVALIDARGUMENTS = 14; 19 | public static final int CRITICALFAILURE = 99; 20 | private ExitCode() { 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/configuration/BeansPostProcess.java: -------------------------------------------------------------------------------- 1 | package loghub.configuration; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | import java.lang.reflect.Method; 7 | import java.util.Map; 8 | 9 | import static java.lang.annotation.ElementType.TYPE; 10 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 11 | 12 | @Documented 13 | @Retention(RUNTIME) 14 | @Target(TYPE) 15 | public @interface BeansPostProcess { 16 | abstract class Processor { 17 | public abstract void process(Map beans); 18 | } 19 | Class value(); 20 | } 21 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/configuration/ConfigErrorListener.java: -------------------------------------------------------------------------------- 1 | package loghub.configuration; 2 | 3 | import org.antlr.v4.runtime.BaseErrorListener; 4 | import org.antlr.v4.runtime.FailedPredicateException; 5 | import org.antlr.v4.runtime.RecognitionException; 6 | import org.antlr.v4.runtime.Recognizer; 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | 10 | public class ConfigErrorListener extends BaseErrorListener { 11 | 12 | private static final Logger logger = LogManager.getLogger(); 13 | 14 | @Override 15 | public void syntaxError(Recognizer recognizer, 16 | Object offendingSymbol, int line, int charPositionInLine, 17 | String msg, RecognitionException e) { 18 | // Generated when parsing lambda as the predicate is in the middle of the clause 19 | if (e instanceof FailedPredicateException) { 20 | msg = "Invalid lambda definition"; 21 | } 22 | String sourceFileName; 23 | if (e != null) { 24 | sourceFileName = e.getInputStream().getSourceName(); 25 | } else if (recognizer != null) { 26 | sourceFileName = recognizer.getInputStream().getSourceName(); 27 | } else { 28 | sourceFileName = "UNKNOWN FILE"; 29 | } 30 | logger.error("File {}, line {}@{}: {}", sourceFileName, line, charPositionInLine, msg); 31 | throw new ConfigException(msg, sourceFileName, line, charPositionInLine); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/configuration/ConfigurationProperties.java: -------------------------------------------------------------------------------- 1 | package loghub.configuration; 2 | 3 | import java.util.Map; 4 | import java.util.function.BiConsumer; 5 | 6 | public class ConfigurationProperties { 7 | 8 | private final Map properties; 9 | 10 | public ConfigurationProperties(Map properties) { 11 | this.properties = Map.copyOf(properties); 12 | } 13 | 14 | public ConfigurationProperties() { 15 | this.properties = Map.of(); 16 | } 17 | 18 | public int size() { 19 | return properties.size(); 20 | } 21 | 22 | public void forEach(BiConsumer action) { 23 | properties.forEach(action); 24 | } 25 | 26 | public boolean containsKey(String key) { 27 | return properties.containsKey(key); 28 | } 29 | 30 | public Object get(String key) { 31 | return properties.get(key); 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/datetime/AppendOffset.java: -------------------------------------------------------------------------------- 1 | package loghub.datetime; 2 | 3 | import java.time.ZonedDateTime; 4 | import java.time.format.DateTimeFormatter; 5 | import java.util.Locale; 6 | 7 | interface AppendOffset { 8 | class PatternAppendOffset implements AppendOffset { 9 | private final DateTimeFormatter dtf; 10 | 11 | PatternAppendOffset(String pattern) { 12 | dtf = DateTimeFormatter.ofPattern(pattern); 13 | } 14 | private PatternAppendOffset(DateTimeFormatter dtf) { 15 | this.dtf = dtf; 16 | } 17 | @Override 18 | public StringBuilder append(StringBuilder sb, ZonedDateTime dateTime) { 19 | return sb.append(dtf.format(dateTime)); 20 | } 21 | @Override 22 | public AppendOffset withLocale(Locale locale) { 23 | return new PatternAppendOffset(dtf.withLocale(locale)); 24 | } 25 | } 26 | 27 | StringBuilder append(StringBuilder sb, ZonedDateTime dateTime); 28 | default AppendOffset withLocale(Locale locale) { 29 | return this; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/datetime/DatetimeProcessor.java: -------------------------------------------------------------------------------- 1 | package loghub.datetime; 2 | 3 | import java.time.Instant; 4 | import java.time.ZoneId; 5 | import java.time.ZonedDateTime; 6 | import java.util.Locale; 7 | 8 | public interface DatetimeProcessor { 9 | 10 | Instant parseInstant(String datetime); 11 | 12 | ZonedDateTime parse(String datetime); 13 | 14 | String print(Instant instant); 15 | 16 | String print(ZonedDateTime zonedDateTime); 17 | 18 | DatetimeProcessor withLocale(Locale locale); 19 | 20 | DatetimeProcessor withDefaultZone(ZoneId zoneId); 21 | 22 | static DatetimeProcessor of(String pattern) { 23 | return PatternResolver.createNewFormatter(pattern); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/datetime/NamedPatterns.java: -------------------------------------------------------------------------------- 1 | package loghub.datetime; 2 | 3 | public final class NamedPatterns { 4 | public static final String ISO = "iso"; 5 | public static final String ISO_NANOS = "iso_nanos"; 6 | public static final String ISO_SECONDS = "iso_seconds"; 7 | public static final String NANOSECONDS = "nanoseconds"; 8 | public static final String MILLISECONDS = "milliseconds"; 9 | public static final String SECONDS = "seconds"; 10 | public static final String RFC822 = "rfc822"; 11 | public static final String RFC3164 = "rfc3164"; 12 | 13 | private NamedPatterns() {} 14 | } 15 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/datetime/NumericDateTimeProcessor.java: -------------------------------------------------------------------------------- 1 | package loghub.datetime; 2 | 3 | public interface NumericDateTimeProcessor extends DatetimeProcessor { 4 | } 5 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/datetime/ParseTimeZone.java: -------------------------------------------------------------------------------- 1 | package loghub.datetime; 2 | 3 | import java.time.ZoneId; 4 | 5 | @FunctionalInterface 6 | public interface ParseTimeZone { 7 | ZoneId parse(ParsingContext context, AppendOffset offsetType, ZoneId defaultZone); 8 | } 9 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/decoders/DecodeException.java: -------------------------------------------------------------------------------- 1 | package loghub.decoders; 2 | 3 | import loghub.FilterException; 4 | 5 | public class DecodeException extends Exception { 6 | 7 | public static class RuntimeDecodeException extends RuntimeException { 8 | public RuntimeDecodeException(DecodeException cause) { 9 | super(cause.getMessage(), cause); 10 | } 11 | public RuntimeDecodeException(String message, DecodeException cause) { 12 | super(message, cause); 13 | } 14 | public DecodeException getDecodeException() { 15 | return (DecodeException) getCause(); 16 | } 17 | } 18 | 19 | public DecodeException(String message, Throwable cause) { 20 | super(message, cause); 21 | } 22 | public DecodeException(FilterException cause) { 23 | super("Filter exception", cause); 24 | } 25 | public DecodeException(String message) { 26 | super(message); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/decoders/Json.java: -------------------------------------------------------------------------------- 1 | package loghub.decoders; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | 5 | import com.fasterxml.jackson.databind.json.JsonMapper; 6 | 7 | import loghub.BuilderClass; 8 | import loghub.jackson.JacksonBuilder; 9 | 10 | @BuilderClass(Json.Builder.class) 11 | public class Json extends AbstractStringJackson { 12 | 13 | public static class Builder extends AbstractStringJackson.Builder { 14 | @Override 15 | public Json build() { 16 | this.charset = StandardCharsets.UTF_8.name(); 17 | return new Json(this); 18 | } 19 | } 20 | public static Builder getBuilder() { 21 | return new Builder(); 22 | } 23 | 24 | protected Json(Builder builder) { 25 | super(builder); 26 | } 27 | 28 | @Override 29 | protected JacksonBuilder getReaderBuilder(Builder builder) { 30 | return JacksonBuilder.get(JsonMapper.class); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/decoders/Raw.java: -------------------------------------------------------------------------------- 1 | package loghub.decoders; 2 | 3 | import java.util.Arrays; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import loghub.BuilderClass; 7 | import loghub.ConnectionContext; 8 | 9 | @BuilderClass(Raw.Builder.class) 10 | public class Raw extends Decoder { 11 | 12 | public static class Builder extends Decoder.Builder { 13 | @Override 14 | public Raw build() { 15 | return new Raw(this); 16 | } 17 | } 18 | public static Raw.Builder getBuilder() { 19 | return new Raw.Builder(); 20 | } 21 | 22 | private Raw(Raw.Builder builder) { 23 | super(builder); 24 | } 25 | 26 | @Override 27 | protected Object decodeObject(ConnectionContext ctx, ByteBuf bbuf) { 28 | byte[] content = new byte[bbuf.readableBytes()]; 29 | bbuf.readBytes(content); 30 | return content; 31 | } 32 | 33 | @Override 34 | protected Object decodeObject(ConnectionContext ctx, byte[] msg, int offset, int length) { 35 | return Arrays.copyOfRange(msg, offset, offset + length); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/decoders/StringCodec.java: -------------------------------------------------------------------------------- 1 | package loghub.decoders; 2 | 3 | import java.nio.charset.Charset; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import loghub.BuilderClass; 7 | import loghub.ConnectionContext; 8 | import lombok.Setter; 9 | 10 | @BuilderClass(StringCodec.Builder.class) 11 | public class StringCodec extends Decoder { 12 | 13 | @Setter 14 | public static class Builder extends Decoder.Builder { 15 | private String charset = Charset.defaultCharset().name(); 16 | @Override 17 | public StringCodec build() { 18 | return new StringCodec(this); 19 | } 20 | } 21 | 22 | public static Builder getBuilder() { 23 | return new Builder(); 24 | } 25 | 26 | private final Charset charset; 27 | 28 | private StringCodec(Builder builder) { 29 | super(builder); 30 | charset = Charset.forName(builder.charset); 31 | } 32 | 33 | @Override 34 | protected Object decodeObject(ConnectionContext connectionContext, 35 | byte[] msg, int offset, int length) { 36 | return new String(msg, offset, length, charset); 37 | } 38 | 39 | @Override 40 | protected Object decodeObject(ConnectionContext ctx, ByteBuf bbuf) { 41 | return bbuf.toString(charset); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/decoders/TextDecoder.java: -------------------------------------------------------------------------------- 1 | package loghub.decoders; 2 | 3 | import java.util.Map; 4 | import java.util.stream.Stream; 5 | 6 | import loghub.ConnectionContext; 7 | 8 | public interface TextDecoder { 9 | 10 | String getCharset(); 11 | Object decodeObject(ConnectionContext ctx, String message) throws DecodeException; 12 | Stream> decode(ConnectionContext ctx, String message) throws DecodeException; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/decoders/XmlDom.java: -------------------------------------------------------------------------------- 1 | package loghub.decoders; 2 | 3 | import org.w3c.dom.Document; 4 | 5 | import loghub.BuilderClass; 6 | 7 | @BuilderClass(XmlDom.Builder.class) 8 | public class XmlDom extends AbstractXmlDecoder { 9 | 10 | public static class Builder extends AbstractXmlDecoder.Builder { 11 | @Override 12 | public XmlDom build() { 13 | return new XmlDom(this); 14 | } 15 | } 16 | 17 | public static XmlDom.Builder getBuilder() { 18 | return new XmlDom.Builder(); 19 | } 20 | 21 | protected XmlDom(XmlDom.Builder builder) { 22 | super(builder); 23 | } 24 | 25 | @Override 26 | protected Object domTransform(Document d) { 27 | return d; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/encoders/EncodeException.java: -------------------------------------------------------------------------------- 1 | package loghub.encoders; 2 | 3 | import loghub.FilterException; 4 | 5 | public class EncodeException extends Exception { 6 | 7 | public static class RuntimeDecodeException extends RuntimeException { 8 | public RuntimeDecodeException(EncodeException cause) { 9 | super(cause.getMessage(), cause); 10 | } 11 | public RuntimeDecodeException(String message, EncodeException cause) { 12 | super(message, cause); 13 | } 14 | public EncodeException getDecodeException() { 15 | return (EncodeException) getCause(); 16 | } 17 | } 18 | 19 | public EncodeException(FilterException cause) { 20 | super("Filter exception", cause); 21 | } 22 | public EncodeException(String message, Throwable cause) { 23 | super(message, cause); 24 | } 25 | public EncodeException(String message) { 26 | super(message); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/events/EventBuilder.java: -------------------------------------------------------------------------------- 1 | package loghub.events; 2 | 3 | import java.time.Instant; 4 | import java.util.Map; 5 | 6 | import loghub.ConnectionContext; 7 | import lombok.Setter; 8 | import lombok.experimental.Accessors; 9 | 10 | @Setter 11 | @Accessors(chain = true) 12 | public class EventBuilder { 13 | private Instant timestamp = Instant.now(); 14 | private Map metas = Map.of(); 15 | private Map data = Map.of(); 16 | private ConnectionContext context = ConnectionContext.EMPTY; 17 | private boolean test = false; 18 | private EventsFactory factory; 19 | 20 | public Event getInstance() { 21 | Event ev = factory.newEvent(context, test); 22 | ev.setTimestamp(timestamp); 23 | ev.getMetas().putAll(metas); 24 | ev.putAll(data); 25 | return ev; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/events/EventFinalizer.java: -------------------------------------------------------------------------------- 1 | package loghub.events; 2 | 3 | import java.lang.ref.PhantomReference; 4 | import java.lang.ref.ReferenceQueue; 5 | 6 | import com.codahale.metrics.Timer; 7 | 8 | import loghub.metrics.Stats; 9 | 10 | public class EventFinalizer extends PhantomReference { 11 | 12 | private final Runnable clean; 13 | private volatile boolean ended = false; 14 | 15 | public EventFinalizer(Event referent, ReferenceQueue referenceQueue, Timer.Context timer) { 16 | super(referent, referenceQueue); 17 | this.clean = () -> EventsFactory.finishEvent(true, timer); 18 | } 19 | 20 | @Override 21 | public void clear() { 22 | super.clear(); 23 | if (ended) { 24 | Stats.duplicateEnd(); 25 | // To detect duplication during tests 26 | assert false : "Duplicate end of event"; 27 | } 28 | ended = true; 29 | } 30 | 31 | public void finalizeResources() { 32 | // free resources 33 | clean.run(); 34 | Stats.eventLeaked(); 35 | // To detect leaks during tests. 36 | assert false : "Leaked event"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/events/PostSubPipline.java: -------------------------------------------------------------------------------- 1 | package loghub.events; 2 | 3 | import java.util.NoSuchElementException; 4 | import java.util.Optional; 5 | 6 | import loghub.Processor; 7 | import loghub.ProcessorException; 8 | import loghub.configuration.Properties; 9 | 10 | public class PostSubPipline extends Processor { 11 | 12 | public static final PostSubPipline INSTANCE = new PostSubPipline(); 13 | private PostSubPipline() { 14 | // Empty 15 | } 16 | 17 | @Override 18 | public boolean configure(Properties properties) { 19 | return true; 20 | } 21 | 22 | @Override 23 | public boolean process(Event event) throws ProcessorException { 24 | ExecutionStackElement.logger.trace("<-- {}({})", () -> event.getRealEvent().executionStack, () -> event); 25 | try { 26 | event.getRealEvent().executionStack.remove().close(); 27 | } catch (NoSuchElementException ex) { 28 | throw new ProcessorException(event.getRealEvent(), "Empty timer stack, bad state"); 29 | } 30 | Optional.ofNullable(event.getRealEvent().executionStack.peek()) 31 | .ifPresent(ExecutionStackElement::restart); 32 | event.getRealEvent().refreshLogger(); 33 | return true; 34 | } 35 | 36 | @Override 37 | public String getName() { 38 | return "postSubpipline"; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "postSubpipline"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/events/PreSubPipline.java: -------------------------------------------------------------------------------- 1 | package loghub.events; 2 | 3 | import java.util.Optional; 4 | 5 | import loghub.Pipeline; 6 | import loghub.Processor; 7 | import loghub.configuration.Properties; 8 | import lombok.Getter; 9 | 10 | @Getter 11 | public class PreSubPipline extends Processor { 12 | 13 | private final Pipeline pipe; 14 | 15 | public PreSubPipline(Pipeline pipe) { 16 | this.pipe = pipe; 17 | } 18 | 19 | @Override 20 | public boolean configure(Properties properties) { 21 | return true; 22 | } 23 | 24 | @Override 25 | public boolean process(Event event) { 26 | Optional.ofNullable(event.getRealEvent().executionStack.peek()).ifPresent(ExecutionStackElement::pause); 27 | ExecutionStackElement ctxt = new ExecutionStackElement(pipe); 28 | event.getRealEvent().executionStack.add(ctxt); 29 | ExecutionStackElement.logger.trace("--> {}({})", () -> event.getRealEvent().executionStack, () -> event); 30 | event.getRealEvent().refreshLogger(); 31 | return true; 32 | } 33 | 34 | @Override 35 | public String getName() { 36 | return "preSubpipline(" + pipe.getName() + ")"; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "preSubpipline(" + pipe.getName() + ")"; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/groovy/BooleanMetaClass.java: -------------------------------------------------------------------------------- 1 | package loghub.groovy; 2 | 3 | import groovy.lang.MetaClass; 4 | 5 | public class BooleanMetaClass extends LoghubMetaClass { 6 | 7 | public BooleanMetaClass(MetaClass theClass) { 8 | super(theClass); 9 | } 10 | 11 | @Override 12 | protected Object callMethod(Boolean arg1, GroovyMethods method, Object argument) { 13 | boolean arg2 = convertArgument(argument); 14 | boolean value; 15 | switch (method) { 16 | case PLUS: 17 | case OR: 18 | value = arg1 || arg2; 19 | break; 20 | case AND: 21 | case MULTIPLY: 22 | value = arg1 && arg2; 23 | break; 24 | case XOR: 25 | value = arg1 ^ arg2; 26 | break; 27 | default: 28 | return invokeMethod(arg1, method, argument); 29 | } 30 | return value; 31 | } 32 | 33 | @Override 34 | protected Boolean convertArgument(Object object) { 35 | if (object instanceof CharSequence) { 36 | return Boolean.parseBoolean(toString()); 37 | } else { 38 | return Boolean.TRUE.equals(object); 39 | } 40 | } 41 | 42 | @Override 43 | protected boolean isHandledClass(Object o) { 44 | return o instanceof Boolean; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/groovy/CharacterMetaClass.java: -------------------------------------------------------------------------------- 1 | package loghub.groovy; 2 | 3 | import groovy.lang.MetaClass; 4 | 5 | public class CharacterMetaClass extends LoghubMetaClass { 6 | 7 | public CharacterMetaClass(MetaClass delegate) { 8 | super(delegate); 9 | } 10 | 11 | @Override 12 | public Object callMethod(Character object, GroovyMethods method, Object argument) { 13 | if (GroovyMethods.PLUS == method) { 14 | return object.toString() + argument.toString(); 15 | } else { 16 | return invokeMethod(object, method, argument); 17 | } 18 | } 19 | 20 | @Override 21 | public boolean isHandledClass(Object o) { 22 | return o instanceof Character; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/groovy/ObjectMetaClass.java: -------------------------------------------------------------------------------- 1 | package loghub.groovy; 2 | 3 | import groovy.lang.MetaClass; 4 | import loghub.Expression; 5 | 6 | /** 7 | * This wrapper object can be called when doing comparison of a collection 8 | */ 9 | public class ObjectMetaClass extends LoghubMetaClass { 10 | 11 | public ObjectMetaClass(MetaClass delegate) { 12 | super(delegate); 13 | } 14 | 15 | @Override 16 | protected Object callMethod(Object object, GroovyMethods method, Object argument) { 17 | if (GroovyMethods.EQUALS == method) { 18 | return Expression.compare("==", object, argument); 19 | } else if (GroovyMethods.COMPARE_TO == method) { 20 | return Expression.compare("<=>", object, argument); 21 | } else { 22 | return superInvokeMethod(object, method.groovyMethod, new Object[]{argument}); 23 | } 24 | } 25 | 26 | @Override 27 | protected boolean isHandledClass(Object o) { 28 | return true; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/groovy/StringMetaClass.java: -------------------------------------------------------------------------------- 1 | package loghub.groovy; 2 | 3 | import groovy.lang.MetaClass; 4 | 5 | public class StringMetaClass extends LoghubMetaClass { 6 | 7 | public StringMetaClass(MetaClass theClass) { 8 | super(theClass); 9 | } 10 | 11 | @Override 12 | protected Object callMethod(CharSequence object, GroovyMethods method, Object argument) { 13 | if (method == GroovyMethods.PLUS) { 14 | return object.toString() + argument.toString(); 15 | } else { 16 | return invokeMethod(object, method, argument); 17 | } 18 | } 19 | 20 | @Override 21 | protected boolean isHandledClass(Object o) { 22 | return o instanceof CharSequence; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/httpclient/ContentType.java: -------------------------------------------------------------------------------- 1 | package loghub.httpclient; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum ContentType { 7 | 8 | TEXT_HTML(true, AbstractHttpClientService.TEXT_HTML), 9 | TEXT_PLAIN(true, AbstractHttpClientService.TEXT_PLAIN), 10 | APPLICATION_OCTET_STREAM(false, AbstractHttpClientService.APPLICATION_OCTET_STREAM), 11 | APPLICATION_JSON(true, AbstractHttpClientService.APPLICATION_JSON), 12 | APPLICATION_XML(true, AbstractHttpClientService.APPLICATION_XML); 13 | 14 | ContentType(boolean textBody, String mimeType) { 15 | this.textBody = textBody; 16 | this.mimeType = mimeType; 17 | } 18 | private final boolean textBody; 19 | private final String mimeType; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/httpclient/ContentWriter.java: -------------------------------------------------------------------------------- 1 | package loghub.httpclient; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | public interface ContentWriter { 7 | void writeTo(OutputStream outStream) throws IOException; 8 | } 9 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/httpclient/HttpResponse.java: -------------------------------------------------------------------------------- 1 | package loghub.httpclient; 2 | 3 | import java.io.Closeable; 4 | import java.io.IOException; 5 | import java.security.GeneralSecurityException; 6 | 7 | public abstract class HttpResponse implements Closeable { 8 | 9 | public abstract ContentType getMimeType(); 10 | 11 | public abstract String getHost(); 12 | 13 | public abstract int getStatus(); 14 | 15 | public abstract String getStatusMessage(); 16 | 17 | public abstract boolean isConnexionFailed(); 18 | 19 | public abstract IOException getSocketException(); 20 | 21 | public abstract GeneralSecurityException getSslException(); 22 | 23 | public abstract T getParsedResponse(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/jackson/EventSerializer.java: -------------------------------------------------------------------------------- 1 | package loghub.jackson; 2 | 3 | import java.io.IOException; 4 | import java.util.Collections; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.fasterxml.jackson.core.JsonGenerator; 9 | import com.fasterxml.jackson.databind.JsonSerializer; 10 | import com.fasterxml.jackson.databind.SerializerProvider; 11 | 12 | import loghub.events.Event; 13 | 14 | public class EventSerializer extends JsonSerializer { 15 | @Override 16 | public void serialize(Event value, JsonGenerator gen, 17 | SerializerProvider serializers) 18 | throws IOException { 19 | Map eventContent = new HashMap<>(); 20 | Map eventMetas = new HashMap<>(); 21 | Map eventFields = new HashMap<>(value); 22 | value.getMetaAsStream().forEach(i-> eventMetas.put(i.getKey(), i.getValue())); 23 | eventContent.put("@fields", eventFields); 24 | eventContent.put(Event.TIMESTAMPKEY, value.getTimestamp()); 25 | eventContent.put("@METAS", eventMetas); 26 | Map eventMap = Collections.singletonMap(Event.EVENT_ENTRY, eventContent); 27 | gen.writeObject(eventMap); 28 | } 29 | @Override 30 | public Class handledType() { 31 | return Event.class; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/jackson/MsgpackTimeDeserializer.java: -------------------------------------------------------------------------------- 1 | package loghub.jackson; 2 | 3 | import java.io.IOException; 4 | import java.nio.ByteBuffer; 5 | import java.time.DateTimeException; 6 | import java.time.Instant; 7 | 8 | import org.msgpack.jackson.dataformat.ExtensionTypeCustomDeserializers; 9 | 10 | public class MsgpackTimeDeserializer implements ExtensionTypeCustomDeserializers.Deser { 11 | 12 | @Override 13 | public Object deserialize(byte[] data) throws IOException { 14 | ByteBuffer content = ByteBuffer.wrap(data); 15 | long seconds; 16 | int nanoseconds; 17 | switch (data.length) { 18 | case 4: 19 | seconds = content.getInt(); 20 | nanoseconds = 0; 21 | break; 22 | case 8: 23 | long lcontent = content.getLong(); 24 | seconds = lcontent & 0x00000003ffffffffL; 25 | // Masked needed to drop sign extended by right shift 26 | nanoseconds = (int) ((lcontent >> 34) & (0x3FFFFFFFL)); 27 | break; 28 | case 12: 29 | nanoseconds = content.getInt(); 30 | seconds = content.getLong(); 31 | break; 32 | default: 33 | throw new IOException("Invalid time object length"); 34 | } 35 | try { 36 | return Instant.ofEpochSecond(seconds, nanoseconds); 37 | } catch (DateTimeException e) { 38 | return data; 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/jackson/package-info.java: -------------------------------------------------------------------------------- 1 | package loghub.jackson; 2 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/metrics/CustomStats.java: -------------------------------------------------------------------------------- 1 | package loghub.metrics; 2 | 3 | public interface CustomStats { 4 | void registerCustomStats(); 5 | } 6 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/metrics/Description.java: -------------------------------------------------------------------------------- 1 | package loghub.metrics; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target({ElementType.METHOD}) 10 | @interface Description { 11 | String value(); 12 | } 13 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/metrics/DocumentedMBean.java: -------------------------------------------------------------------------------- 1 | package loghub.metrics; 2 | 3 | import java.lang.reflect.Method; 4 | import java.util.Optional; 5 | 6 | import javax.management.MBeanAttributeInfo; 7 | import javax.management.NotCompliantMBeanException; 8 | import javax.management.StandardMBean; 9 | 10 | public class DocumentedMBean extends StandardMBean { 11 | 12 | protected DocumentedMBean(Class mbeanInterface) throws NotCompliantMBeanException { 13 | super(mbeanInterface); 14 | } 15 | 16 | @Override 17 | protected String getDescription(MBeanAttributeInfo info) { 18 | String description = null; 19 | try { 20 | Method method = getMBeanInterface().getMethod("get" + info.getName()); 21 | if (method.isAnnotationPresent(Description.class)) { 22 | description = method.getAnnotation(Description.class).value(); 23 | } 24 | } catch (NoSuchMethodException e) { 25 | // Ignore exception 26 | } 27 | return Optional.ofNullable(description).orElse(super.getDescription(info)); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/metrics/MetricType.java: -------------------------------------------------------------------------------- 1 | package loghub.metrics; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.management.DescriptorKey; 10 | 11 | @Documented 12 | @Target(ElementType.METHOD) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface MetricType { 15 | String COUNTER = "counter"; 16 | String GAUGE = "gauge"; 17 | @DescriptorKey("metricType") 18 | String value(); 19 | } 20 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/metrics/Units.java: -------------------------------------------------------------------------------- 1 | package loghub.metrics; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.management.DescriptorKey; 10 | 11 | @Documented 12 | @Target(ElementType.METHOD) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface Units { 15 | String EVENTS = "events"; 16 | String MILLISECONDS = "ms"; 17 | String BYTES = "bytes"; 18 | String BATCHES = "batches"; 19 | String EXCEPTIONS = "exceptions"; 20 | 21 | @DescriptorKey("units") 22 | String value(); 23 | } 24 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/ChannelConsumer.java: -------------------------------------------------------------------------------- 1 | package loghub.netty; 2 | 3 | import io.netty.bootstrap.Bootstrap; 4 | import io.netty.bootstrap.ServerBootstrap; 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.channel.ChannelPipeline; 7 | 8 | public interface ChannelConsumer { 9 | void addHandlers(ChannelPipeline pipe); 10 | default void addOptions(ServerBootstrap bootstrap) { } 11 | default void addOptions(Bootstrap bootstrap) { } 12 | void exception(ChannelHandlerContext ctx, Throwable cause); 13 | void logFatalException(Throwable ex); 14 | } 15 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/CloseOnError.java: -------------------------------------------------------------------------------- 1 | package loghub.netty; 2 | 3 | import java.lang.annotation.Inherited; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | 7 | import static java.lang.annotation.ElementType.TYPE; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | @Retention(RUNTIME) 11 | @Target(TYPE) 12 | @Inherited 13 | public @interface CloseOnError { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/ConsumerProvider.java: -------------------------------------------------------------------------------- 1 | package loghub.netty; 2 | 3 | public interface ConsumerProvider { 4 | ChannelConsumer getConsumer(); 5 | } 6 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/ContextExtractor.java: -------------------------------------------------------------------------------- 1 | package loghub.netty; 2 | 3 | import java.util.List; 4 | 5 | import io.netty.channel.ChannelHandler.Sharable; 6 | import io.netty.channel.ChannelHandlerContext; 7 | import io.netty.handler.codec.MessageToMessageDecoder; 8 | import io.netty.util.ReferenceCounted; 9 | 10 | @Sharable 11 | public class ContextExtractor, SM, B extends NettyReceiver.Builder> extends MessageToMessageDecoder { 12 | 13 | public static final String NAME = "SourceResolver"; 14 | 15 | private final NettyReceiver r; 16 | 17 | public ContextExtractor(Class messageClass, NettyReceiver r) { 18 | super(messageClass); 19 | this.r = r; 20 | } 21 | 22 | public ContextExtractor(NettyReceiver r) { 23 | this.r = r; 24 | } 25 | 26 | @Override 27 | protected void decode(ChannelHandlerContext ctx, SM msg, List out) { 28 | // In datagram-oriented flow, the remote adress is in the packet, not the channel 29 | // So forward the message too for check. 30 | r.makeConnectionContext(ctx, msg); 31 | //The message is not transformed in this step, so don't decrease reference count 32 | if (msg instanceof ReferenceCounted) { 33 | ((ReferenceCounted) msg).retain(); 34 | } 35 | out.add(msg); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/DashboardService.java: -------------------------------------------------------------------------------- 1 | package loghub.netty; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import io.netty.channel.SimpleChannelInboundHandler; 7 | import io.netty.handler.codec.http.FullHttpRequest; 8 | 9 | public interface DashboardService { 10 | String getName(); 11 | List> getHandlers(Map properties); 12 | default List getStarters() { 13 | return List.of(); 14 | } 15 | default List getStoppers() { 16 | return List.of(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/ContentType.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.Target; 7 | 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | @Documented 12 | @Retention(RUNTIME) 13 | @Target(TYPE) 14 | @Inherited 15 | public @interface ContentType { 16 | String value(); 17 | } 18 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/FatalErrorHandler.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import io.netty.channel.ChannelHandler; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.http.FullHttpRequest; 6 | import io.netty.handler.codec.http.HttpRequest; 7 | import io.netty.handler.codec.http.HttpResponse; 8 | import io.netty.handler.codec.http.HttpResponseStatus; 9 | 10 | @ChannelHandler.Sharable 11 | public class FatalErrorHandler extends HttpRequestProcessing { 12 | @Override 13 | public boolean acceptRequest(HttpRequest request) { 14 | return true; 15 | } 16 | @Override 17 | protected void processRequest(FullHttpRequest request, ChannelHandlerContext ctx) throws HttpRequestFailure { 18 | throw new HttpRequestFailure(HttpResponseStatus.SERVICE_UNAVAILABLE, "Unable to process request because of invalid configuration"); 19 | } 20 | @Override 21 | protected String getContentType(HttpRequest request, HttpResponse response) { 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/HttpFilter.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.util.Date; 4 | import java.util.function.Predicate; 5 | 6 | import io.netty.channel.ChannelHandlerContext; 7 | import io.netty.handler.codec.http.FullHttpRequest; 8 | import io.netty.handler.codec.http.HttpRequest; 9 | import io.netty.handler.codec.http.HttpResponse; 10 | 11 | public abstract class HttpFilter extends HttpHandler { 12 | 13 | protected HttpFilter() { 14 | super(false); 15 | } 16 | 17 | protected HttpFilter(Predicate urlFilter) { 18 | super(false, urlFilter); 19 | } 20 | 21 | protected HttpFilter(Predicate urlFilter, String... method) { 22 | super(false, urlFilter, method); 23 | } 24 | 25 | @Override 26 | protected final void subProcessing(FullHttpRequest request, ChannelHandlerContext ctx) throws HttpRequestFailure { 27 | filter(request, ctx); 28 | ctx.fireChannelRead(request); 29 | } 30 | 31 | protected abstract void filter(FullHttpRequest request, ChannelHandlerContext ctx) throws HttpRequestFailure; 32 | 33 | @Override 34 | protected String getContentType(HttpRequest request, HttpResponse response) { 35 | return null; 36 | } 37 | 38 | @Override 39 | protected Date getContentDate(HttpRequest request, HttpResponse response) { 40 | return null; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/HttpRequestFailure.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.util.Collections; 4 | import java.util.Map; 5 | 6 | import io.netty.handler.codec.http.HttpResponseStatus; 7 | import io.netty.util.AsciiString; 8 | 9 | public class HttpRequestFailure extends Exception { 10 | public final HttpResponseStatus status; 11 | public final String message; 12 | public final Map additionHeaders; 13 | public HttpRequestFailure(HttpResponseStatus status, String message, Map additionHeaders) { 14 | this.status = status; 15 | this.message = message; 16 | this.additionHeaders = additionHeaders; 17 | } 18 | public HttpRequestFailure(HttpResponseStatus status, String message) { 19 | this.status = status; 20 | this.message = message; 21 | this.additionHeaders = Collections.emptyMap(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/HttpRequestProcessing.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.util.function.Predicate; 4 | 5 | import com.codahale.metrics.Meter; 6 | 7 | import io.netty.buffer.Unpooled; 8 | import io.netty.channel.ChannelHandlerContext; 9 | import io.netty.handler.codec.http.FullHttpRequest; 10 | import loghub.metrics.Stats; 11 | import loghub.netty.HttpChannelConsumer; 12 | 13 | import static io.netty.handler.codec.http.HttpResponseStatus.OK; 14 | 15 | public abstract class HttpRequestProcessing extends HttpHandler { 16 | 17 | protected HttpRequestProcessing() { 18 | super(true); 19 | } 20 | 21 | protected HttpRequestProcessing(Predicate urlFilter) { 22 | super(true, urlFilter); 23 | } 24 | 25 | protected HttpRequestProcessing(Predicate urlFilter, String... method) { 26 | super(true, urlFilter, method); 27 | } 28 | 29 | @Override 30 | public void channelReadComplete(ChannelHandlerContext ctx) { 31 | ctx.flush(); 32 | } 33 | 34 | @Override 35 | protected void subProcessing(FullHttpRequest request, ChannelHandlerContext ctx) throws HttpRequestFailure { 36 | processRequest(request, ctx); 37 | ctx.writeAndFlush(Unpooled.EMPTY_BUFFER); 38 | } 39 | 40 | protected abstract void processRequest(FullHttpRequest request, ChannelHandlerContext ctx) throws HttpRequestFailure; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/JwtToken.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.security.Principal; 4 | import java.util.Collections; 5 | 6 | import com.auth0.jwt.exceptions.JWTCreationException; 7 | 8 | import io.netty.buffer.ByteBuf; 9 | import io.netty.buffer.Unpooled; 10 | import io.netty.channel.ChannelHandlerContext; 11 | import io.netty.handler.codec.http.FullHttpRequest; 12 | import io.netty.handler.codec.http.HttpResponseStatus; 13 | import io.netty.util.CharsetUtil; 14 | import loghub.security.JWTHandler; 15 | 16 | import static loghub.netty.transport.NettyTransport.PRINCIPALATTRIBUTE; 17 | 18 | @NoCache 19 | @ContentType("text/plain") 20 | @RequestAccept(path = "/token", methods = {"GET"}) 21 | public class JwtToken extends HttpRequestProcessing { 22 | 23 | private final JWTHandler alg; 24 | 25 | public JwtToken(JWTHandler alg) { 26 | this.alg = alg; 27 | } 28 | 29 | @Override 30 | protected void processRequest(FullHttpRequest request, ChannelHandlerContext ctx) throws HttpRequestFailure { 31 | Principal p = ctx.channel().attr(PRINCIPALATTRIBUTE).get(); 32 | try { 33 | String token = alg.getToken(p); 34 | ByteBuf content = Unpooled.copiedBuffer(token + "\r\n", CharsetUtil.UTF_8); 35 | writeResponse(ctx, request, content, content.readableBytes()); 36 | } catch (JWTCreationException exception) { 37 | throw new HttpRequestFailure(HttpResponseStatus.SERVICE_UNAVAILABLE, "JWT creation failed", Collections.emptyMap()); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/NoCache.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.Target; 7 | 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | @Documented 12 | @Retention(RUNTIME) 13 | @Target(TYPE) 14 | @Inherited 15 | public @interface NoCache { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/NotFound.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.channel.ChannelInboundHandler; 5 | import io.netty.handler.codec.http.FullHttpRequest; 6 | import io.netty.handler.codec.http.HttpRequest; 7 | import io.netty.handler.codec.http.HttpResponseStatus; 8 | 9 | public class NotFound extends HttpRequestProcessing implements ChannelInboundHandler { 10 | 11 | @Override 12 | protected void processRequest(FullHttpRequest request, ChannelHandlerContext ctx) throws HttpRequestFailure { 13 | throw new HttpRequestFailure(HttpResponseStatus.NOT_FOUND, request.uri() + " not found"); 14 | } 15 | 16 | @Override 17 | public boolean acceptRequest(HttpRequest request) { 18 | return true; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/NotSharable.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @Inherited 11 | @Documented 12 | @Target(ElementType.TYPE) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface NotSharable { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/RequestAccept.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.Target; 7 | 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | @Documented 12 | @Retention(RUNTIME) 13 | @Target(TYPE) 14 | @Inherited 15 | public @interface RequestAccept { 16 | String path() default ""; 17 | String filter() default ""; 18 | String[] methods() default {"GET"}; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/RootRedirect.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.util.Date; 4 | 5 | import io.netty.buffer.Unpooled; 6 | import io.netty.channel.ChannelHandlerContext; 7 | import io.netty.channel.ChannelInboundHandler; 8 | import io.netty.handler.codec.http.FullHttpRequest; 9 | import io.netty.handler.codec.http.HttpHeaderNames; 10 | import io.netty.handler.codec.http.HttpRequest; 11 | import io.netty.handler.codec.http.HttpResponse; 12 | import io.netty.handler.codec.http.HttpResponseStatus; 13 | 14 | @RequestAccept(path = "/") 15 | public class RootRedirect extends HttpRequestProcessing implements ChannelInboundHandler { 16 | 17 | @Override 18 | protected void processRequest(FullHttpRequest request, ChannelHandlerContext ctx) { 19 | writeResponse(ctx, request, HttpResponseStatus.MOVED_PERMANENTLY, Unpooled.EMPTY_BUFFER, 0); 20 | } 21 | 22 | @Override 23 | protected void addCustomHeaders(HttpRequest request, 24 | HttpResponse response) { 25 | response.headers().set(HttpHeaderNames.LOCATION, "/static/index.html"); 26 | } 27 | 28 | @Override 29 | protected String getContentType(HttpRequest request, HttpResponse response) { 30 | return null; 31 | } 32 | 33 | @Override 34 | protected Date getContentDate(HttpRequest request, HttpResponse response) { 35 | return null; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/http/TokenFilter.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import loghub.security.AuthenticationHandler; 4 | 5 | @RequestAccept(path = "/token", methods = {"GET"}) 6 | public class TokenFilter extends AccessControl { 7 | 8 | public TokenFilter(AuthenticationHandler authhandler) { 9 | super(authhandler); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/servers/Authenticated.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.servers; 2 | 3 | import loghub.security.AuthenticationHandler; 4 | 5 | public interface Authenticated { 6 | AuthenticationHandler getAuthHandler(); 7 | } 8 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/transport/AbstractUnixDomainTransport.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.transport; 2 | 3 | import io.netty.channel.unix.DomainSocketAddress; 4 | 5 | public abstract class AbstractUnixDomainTransport, B extends AbstractUnixDomainTransport.Builder> extends NettyTransport { 6 | 7 | protected AbstractUnixDomainTransport(B builder) { 8 | super(builder); 9 | } 10 | 11 | public abstract static class Builder, B extends AbstractUnixDomainTransport.Builder> extends NettyTransport.Builder { 12 | } 13 | 14 | protected DomainSocketAddress resolveAddress() { 15 | return new DomainSocketAddress(endpoint); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/transport/DomainConnectionContext.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.transport; 2 | 3 | import io.netty.channel.unix.DomainSocketAddress; 4 | import loghub.BuildableConnectionContext; 5 | import loghub.cloners.Immutable; 6 | 7 | @Immutable 8 | public class DomainConnectionContext extends BuildableConnectionContext { 9 | 10 | private final DomainSocketAddress remoteaddr; 11 | private final DomainSocketAddress localaddr; 12 | 13 | public DomainConnectionContext(DomainSocketAddress localaddr, DomainSocketAddress remoteaddr) { 14 | this.localaddr = localaddr; 15 | this.remoteaddr = remoteaddr; 16 | } 17 | 18 | @Override 19 | public DomainSocketAddress getLocalAddress() { 20 | return localaddr; 21 | } 22 | 23 | @Override 24 | public DomainSocketAddress getRemoteAddress() { 25 | return remoteaddr; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/transport/OioPollerServiceProvider.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.transport; 2 | 3 | import java.util.function.Supplier; 4 | 5 | import io.netty.channel.Channel; 6 | import io.netty.channel.IoHandlerFactory; 7 | import io.netty.channel.ServerChannel; 8 | 9 | public class OioPollerServiceProvider implements PollerServiceProvider { 10 | 11 | @Override 12 | public ServerChannel serverChannelProvider(TRANSPORT transport) { 13 | throw new UnsupportedOperationException("Deprecated OIO"); 14 | } 15 | 16 | @Override 17 | public Channel clientChannelProvider(TRANSPORT transport) { 18 | throw new UnsupportedOperationException("Deprecated OIO"); 19 | } 20 | 21 | @Override 22 | public Supplier getFactorySupplier() { 23 | throw new UnsupportedOperationException("Deprecated OIO"); 24 | } 25 | 26 | @Override 27 | public POLLER getPoller() { 28 | return POLLER.OIO; 29 | } 30 | 31 | @Override 32 | public boolean isValid() { 33 | return true; 34 | } 35 | 36 | @Override 37 | public boolean isUnixSocket() { 38 | return false; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/transport/PollerServiceProvider.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.transport; 2 | 3 | import java.util.function.Supplier; 4 | 5 | import io.netty.bootstrap.Bootstrap; 6 | import io.netty.bootstrap.ServerBootstrap; 7 | import io.netty.channel.Channel; 8 | import io.netty.channel.ChannelConfig; 9 | import io.netty.channel.IoHandlerFactory; 10 | import io.netty.channel.ServerChannel; 11 | 12 | public interface PollerServiceProvider { 13 | 14 | POLLER getPoller(); 15 | boolean isValid(); 16 | boolean isUnixSocket(); 17 | ServerChannel serverChannelProvider(TRANSPORT transport); 18 | Channel clientChannelProvider(TRANSPORT transport); 19 | Supplier getFactorySupplier(); 20 | default void setKeepAlive(ServerBootstrap bootstrap, int cnt, int idle, int intvl) { 21 | // default does nothing 22 | } 23 | default void setKeepAlive(Bootstrap bootstrap, int cnt, int idle, int intvl) { 24 | // default does nothing 25 | } 26 | default void setKeepAlive(ChannelConfig config, int cnt, int idle, int intvl) { 27 | // default does nothing 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/transport/SctpTransport.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.transport; 2 | 3 | import java.net.InetSocketAddress; 4 | 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.channel.sctp.SctpMessage; 7 | import loghub.ConnectionContext; 8 | 9 | @TransportEnum(TRANSPORT.SCTP) 10 | public class SctpTransport 11 | extends AbstractIpTransport { 12 | 13 | public static class Builder extends AbstractIpTransport.Builder { 14 | @Override 15 | public SctpTransport build() { 16 | return new SctpTransport(this); 17 | } 18 | } 19 | public static SctpTransport.Builder getBuilder() { 20 | return new SctpTransport.Builder(); 21 | } 22 | 23 | protected SctpTransport(Builder builder) { 24 | super(builder); 25 | } 26 | 27 | @Override 28 | public ConnectionContext getNewConnectionContext(ChannelHandlerContext ctx, 29 | SctpMessage message) { 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/transport/TransportEnum.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.transport; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | @Retention(RUNTIME) 10 | @Target(TYPE) 11 | @interface TransportEnum { 12 | TRANSPORT value(); 13 | } 14 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/netty/transport/UnixDgramTransport.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.transport; 2 | 3 | import io.netty.channel.ChannelHandlerContext; 4 | import io.netty.channel.unix.DomainDatagramPacket; 5 | import io.netty.channel.unix.DomainSocketAddress; 6 | import loghub.ConnectionContext; 7 | 8 | @TransportEnum(TRANSPORT.UNIX_DGRAM) 9 | public class UnixDgramTransport extends 10 | AbstractUnixDomainTransport { 11 | 12 | public static class Builder extends AbstractUnixDomainTransport.Builder { 13 | @Override 14 | public UnixDgramTransport build() { 15 | return new UnixDgramTransport(this); 16 | } 17 | } 18 | public static UnixDgramTransport.Builder getBuilder() { 19 | return new UnixDgramTransport.Builder(); 20 | } 21 | 22 | private UnixDgramTransport(UnixDgramTransport.Builder builder) { 23 | super(builder); 24 | } 25 | 26 | @Override 27 | public ConnectionContext getNewConnectionContext(ChannelHandlerContext ctx, DomainDatagramPacket message) { 28 | DomainSocketAddress remoteaddr = message.sender(); 29 | DomainSocketAddress localaddr = message.recipient(); 30 | return new DomainConnectionContext(localaddr, remoteaddr); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/AnonymousSubPipeline.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.Pipeline; 4 | import loghub.Processor; 5 | import loghub.SubPipeline; 6 | import loghub.configuration.Properties; 7 | import loghub.events.Event; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | @Setter 12 | @Getter 13 | public class AnonymousSubPipeline extends Processor implements SubPipeline { 14 | 15 | private Pipeline pipeline; 16 | 17 | @Override 18 | public boolean process(Event event) { 19 | assert false; 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean configure(Properties properties) { 25 | return pipeline.processors.stream().allMatch(i -> i.configure(properties)) && 26 | super.configure(properties); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/Drop.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.Processor; 4 | import loghub.events.Event; 5 | 6 | public class Drop extends Processor { 7 | 8 | @Override 9 | public boolean process(Event event) { 10 | throw new UnsupportedOperationException("can't process wrapped event"); 11 | } 12 | 13 | @Override 14 | public String getName() { 15 | return "Drop"; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/Encoder.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.Processor; 4 | import loghub.ProcessorException; 5 | import loghub.VariablePath; 6 | import loghub.configuration.Properties; 7 | import loghub.encoders.EncodeException; 8 | import loghub.events.Event; 9 | import lombok.Getter; 10 | import lombok.Setter; 11 | 12 | @Setter 13 | @Getter 14 | public class Encoder extends Processor { 15 | 16 | loghub.encoders.Encoder encoder; 17 | private VariablePath field = VariablePath.of("message"); 18 | 19 | @Override 20 | public boolean configure(Properties properties) { 21 | return encoder.configure(properties) && super.configure(properties); 22 | } 23 | 24 | @Override 25 | public boolean process(Event event) throws ProcessorException { 26 | try { 27 | byte[] encoded = encoder.encode(event); 28 | event.putAtPath(field, encoded); 29 | return true; 30 | } catch (EncodeException ex) { 31 | throw event.buildException("Can't encode event", ex); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/Forwarder.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.Pipeline; 4 | import loghub.Processor; 5 | import loghub.configuration.Properties; 6 | import loghub.events.Event; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | /** 11 | * An empty processor, it's just a place holder. It should never be used directly 12 | * 13 | * @author Fabrice Bacchella 14 | * 15 | */ 16 | public class Forwarder extends Processor { 17 | 18 | @Setter 19 | @Getter 20 | private String destination; 21 | private Pipeline pipeDestination; 22 | 23 | @Override 24 | public boolean process(Event event) { 25 | throw new UnsupportedOperationException("can't process wrapped event"); 26 | } 27 | 28 | public void forward(Event event) { 29 | event.finishPipeline(); 30 | event.refill(pipeDestination); 31 | } 32 | 33 | @Override 34 | public boolean configure(Properties properties) { 35 | if (! properties.namedPipeLine.containsKey(destination)) { 36 | logger.error("invalid destination for forked event: {}", destination); 37 | return false; 38 | } 39 | pipeDestination = properties.namedPipeLine.get(destination); 40 | return super.configure(properties); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/Identity.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.Processor; 4 | import loghub.events.Event; 5 | 6 | public class Identity extends Processor { 7 | 8 | @Override 9 | public String getName() { 10 | return "identity"; 11 | } 12 | 13 | @Override 14 | public boolean process(Event event) { 15 | return true; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/Log.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import org.apache.logging.log4j.Level; 4 | 5 | import loghub.BuilderClass; 6 | import loghub.Expression; 7 | import loghub.Processor; 8 | import loghub.ProcessorException; 9 | import loghub.events.Event; 10 | import lombok.Setter; 11 | 12 | @BuilderClass(Log.Builder.class) 13 | public class Log extends Processor { 14 | 15 | private final Expression message; 16 | private final Level level; 17 | 18 | @Setter 19 | public static class Builder extends Processor.Builder { 20 | String level; 21 | Expression message; 22 | public Log build() { 23 | return new Log(this); 24 | } 25 | } 26 | public static Builder getBuilder() { 27 | return new Builder(); 28 | } 29 | 30 | public Log(Builder builder) { 31 | super(builder); 32 | this.level = Level.toLevel(builder.level); 33 | this.message = builder.message; 34 | } 35 | 36 | @Override 37 | public boolean process(Event event) throws ProcessorException { 38 | event.getPipelineLogger().log(level, message.eval(event)); 39 | return true; 40 | } 41 | 42 | @Override 43 | public String getName() { 44 | return "log"; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/Map.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.BuilderClass; 4 | import loghub.Expression; 5 | import loghub.Lambda; 6 | import loghub.ProcessorException; 7 | import loghub.events.Event; 8 | import lombok.Setter; 9 | 10 | @BuilderClass(Map.Builder.class) 11 | public class Map extends TreeWalkProcessor { 12 | 13 | @Setter 14 | public static class Builder extends TreeWalkProcessor.Builder { 15 | private Lambda lambda; 16 | public Map build() { 17 | return new Map(this); 18 | } 19 | } 20 | 21 | public static Builder getBuilder() { 22 | return new Builder(); 23 | } 24 | 25 | private final Expression filter; 26 | 27 | private Map(Builder builder) { 28 | super(builder); 29 | filter = builder.lambda.getExpression(); 30 | } 31 | 32 | @Override 33 | protected Object processLeaf(Event event, Object value) throws ProcessorException { 34 | return filter.eval(event, value); 35 | } 36 | 37 | @Override 38 | protected Object processNode(Event event, java.util.Map value) { 39 | return RUNSTATUS.NOSTORE; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/NamedSubPipeline.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.Pipeline; 4 | import loghub.Processor; 5 | import loghub.SubPipeline; 6 | import loghub.configuration.Properties; 7 | import loghub.events.Event; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | public class NamedSubPipeline extends Processor implements SubPipeline { 12 | 13 | @Setter 14 | @Getter 15 | private String pipeRef; 16 | private Pipeline pipe; 17 | 18 | @Override 19 | public boolean process(Event event) { 20 | assert false; 21 | return true; 22 | } 23 | 24 | @Override 25 | public String getName() { 26 | return "piperef"; 27 | } 28 | 29 | @Override 30 | public boolean configure(Properties properties) { 31 | pipe = properties.namedPipeLine.get(pipeRef); 32 | if (pipe == null) { 33 | logger.error("pipeline '{}' not found", pipeRef); 34 | return false; 35 | } 36 | return super.configure(properties); 37 | } 38 | 39 | @Override 40 | public Pipeline getPipeline() { 41 | return pipe; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/ObjectExtractor.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.Processor; 4 | import loghub.ProcessorException; 5 | import loghub.events.Event; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | public abstract class ObjectExtractor extends Processor { 10 | 11 | public abstract void extract(Event event, T object); 12 | 13 | @Setter 14 | @Getter 15 | private String source; 16 | private final Class clazz; 17 | 18 | protected ObjectExtractor() { 19 | super(); 20 | this.clazz = getClassType(); 21 | } 22 | 23 | @Override 24 | public boolean process(Event event) throws ProcessorException { 25 | Object o = event.remove(source); 26 | if (clazz.isAssignableFrom(o.getClass())) { 27 | @SuppressWarnings("unchecked") 28 | T type = (T) o; 29 | extract(event, type); 30 | return true; 31 | } else { 32 | throw event.buildException("can't extract " + getClassType().getCanonicalName() + " from " + o.getClass().getCanonicalName()); 33 | } 34 | } 35 | 36 | protected abstract Class getClassType(); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/TreeWalkProcessor.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import java.util.Map; 4 | 5 | import loghub.ProcessorException; 6 | import loghub.events.Event; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | @Getter 11 | public abstract class TreeWalkProcessor extends FieldsProcessor { 12 | 13 | @Setter 14 | public abstract static class Builder extends FieldsProcessor.Builder { 15 | private TRAVERSAL_ORDER traversal = TRAVERSAL_ORDER.BREADTH; 16 | } 17 | 18 | private final TRAVERSAL_ORDER traversal; 19 | 20 | TreeWalkProcessor(Builder builder) { 21 | super(builder); 22 | this.traversal = builder.traversal; 23 | } 24 | 25 | @Override 26 | public Object fieldFunction(Event event, Object value) throws ProcessorException { 27 | if (value instanceof Map) { 28 | return processNode(event, (Map) value); 29 | } else { 30 | return processLeaf(event, value); 31 | } 32 | } 33 | 34 | protected abstract Object processLeaf(Event event, Object value) throws ProcessorException; 35 | 36 | protected abstract Object processNode(Event event, Map value) throws ProcessorException; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/UnstackException.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.Processor; 4 | import loghub.events.Event; 5 | 6 | public class UnstackException extends Processor { 7 | 8 | @Override 9 | public boolean process(Event event) { 10 | event.popException(); 11 | return true; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/UnwrapEvent.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | public class UnwrapEvent extends Identity { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/processors/WrapEvent.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import loghub.VariablePath; 4 | 5 | public class WrapEvent extends Identity { 6 | 7 | public WrapEvent(VariablePath collectionPath) { 8 | this.setPathArray(collectionPath); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/receivers/Blocking.java: -------------------------------------------------------------------------------- 1 | package loghub.receivers; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.Target; 7 | 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | /** 12 | * An annotation that's used to indicate that the receiver should block if 13 | * the destination queue is full, instead of dropping the event. It's too be used for 14 | * receiver that read from an already buffered source like Kafka or a followed file. 15 | * 16 | *

When just given, it defaults to block. But it can also be given a value that will reverse it's comportement

17 | * 18 | * @author Fabrice Bacchella 19 | * 20 | */ 21 | @Documented 22 | @Retention(RUNTIME) 23 | @Target(TYPE) 24 | @Inherited 25 | public @interface Blocking { 26 | boolean value() default true; 27 | } 28 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/receivers/SelfDecoder.java: -------------------------------------------------------------------------------- 1 | package loghub.receivers; 2 | 3 | import java.lang.annotation.Inherited; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | 7 | import static java.lang.annotation.ElementType.TYPE; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | @Retention(RUNTIME) 11 | @Target(TYPE) 12 | @Inherited 13 | public @interface SelfDecoder { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/receivers/TcpLinesStream.java: -------------------------------------------------------------------------------- 1 | package loghub.receivers; 2 | 3 | import loghub.BuilderClass; 4 | import loghub.Helpers; 5 | import loghub.decoders.StringCodec; 6 | 7 | @BuilderClass(TcpLinesStream.Builder.class) 8 | public class TcpLinesStream extends AbstractNettyStream { 9 | 10 | public static class Builder extends AbstractNettyStream.Builder { 11 | public Builder() { 12 | super(); 13 | // A ready to use TcpLinesStream: single line text message. 14 | StringCodec.Builder sbuilder = new StringCodec.Builder(); 15 | setDecoder(sbuilder.build()); 16 | } 17 | @Override 18 | public TcpLinesStream build() { 19 | return new TcpLinesStream(this); 20 | } 21 | } 22 | public static Builder getBuilder() { 23 | return new Builder(); 24 | } 25 | 26 | private TcpLinesStream(Builder builder) { 27 | super(builder); 28 | } 29 | 30 | @Override 31 | protected String getThreadPrefix(Builder builder) { 32 | return "LineReceiver"; 33 | } 34 | 35 | @Override 36 | public String getReceiverName() { 37 | return "LineReceiver/" + Helpers.ListenString(getListen()) + "/" + getPort(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/security/ssl/ClientAuthentication.java: -------------------------------------------------------------------------------- 1 | package loghub.security.ssl; 2 | 3 | import javax.net.ssl.SSLEngine; 4 | 5 | public enum ClientAuthentication { 6 | REQUIRED { 7 | @Override 8 | public void configureEngine(SSLEngine engine) { 9 | engine.setNeedClientAuth(true); 10 | } 11 | }, 12 | WANTED { 13 | @Override 14 | public void configureEngine(SSLEngine engine) { 15 | engine.setWantClientAuth(true); 16 | } 17 | }, 18 | NOTNEEDED { 19 | @Override 20 | public void configureEngine(SSLEngine engine) { 21 | engine.setNeedClientAuth(false); 22 | engine.setWantClientAuth(false); 23 | } 24 | }, 25 | NONE { 26 | @Override 27 | public void configureEngine(SSLEngine engine) { 28 | // No TLS configured 29 | } 30 | }; 31 | public abstract void configureEngine(SSLEngine engine); 32 | } 33 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/senders/AsyncSender.java: -------------------------------------------------------------------------------- 1 | package loghub.senders; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Inherited; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.Target; 7 | 8 | import static java.lang.annotation.ElementType.TYPE; 9 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 10 | 11 | @Documented 12 | @Retention(RUNTIME) 13 | @Target(TYPE) 14 | @Inherited 15 | public @interface AsyncSender { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/senders/SelfEncoder.java: -------------------------------------------------------------------------------- 1 | package loghub.senders; 2 | 3 | import java.lang.annotation.Inherited; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.Target; 6 | 7 | import static java.lang.annotation.ElementType.TYPE; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | @Retention(RUNTIME) 11 | @Target(TYPE) 12 | @Inherited 13 | public @interface SelfEncoder { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/senders/SendException.java: -------------------------------------------------------------------------------- 1 | package loghub.senders; 2 | 3 | public class SendException extends Exception { 4 | 5 | public SendException(Throwable cause) { 6 | super(cause); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/sources/Source.java: -------------------------------------------------------------------------------- 1 | package loghub.sources; 2 | 3 | import java.util.Map; 4 | 5 | import loghub.configuration.Properties; 6 | 7 | public interface Source extends Map { 8 | boolean configure(Properties properties); 9 | } 10 | -------------------------------------------------------------------------------- /loghub-core/src/main/java/loghub/types/Dn.java: -------------------------------------------------------------------------------- 1 | package loghub.types; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | import java.util.stream.Collectors; 7 | 8 | import javax.naming.InvalidNameException; 9 | import javax.naming.ldap.LdapName; 10 | import javax.naming.ldap.Rdn; 11 | 12 | import com.fasterxml.jackson.annotation.JsonValue; 13 | 14 | import loghub.cloners.Immutable; 15 | import loghub.Helpers; 16 | import lombok.Data; 17 | import lombok.Getter; 18 | 19 | @Getter 20 | @Data 21 | @Immutable 22 | public class Dn { 23 | 24 | private final LdapName name; 25 | 26 | public Dn(String name) { 27 | try { 28 | this.name = new LdapName(name); 29 | } catch (InvalidNameException ex) { 30 | throw new IllegalArgumentException(Helpers.resolveThrowableException(ex), ex); 31 | } 32 | } 33 | 34 | @Override 35 | @JsonValue 36 | public String toString() { 37 | List parts = new ArrayList<>(name.getRdns()); 38 | Collections.reverse(parts); 39 | return parts.stream().map(Rdn::toString).collect(Collectors.joining(", ")); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/META-INF/mime.types: -------------------------------------------------------------------------------- 1 | text/css css 2 | text/javascript js 3 | application/xml xml xsl 4 | application/json json 5 | application/yaml yaml 6 | text/csv csv 7 | 8 | # See http://pki-tutorial.readthedocs.io/en/latest/mime.html#file-types for explanations 9 | application/pkcs8 p8 key 10 | application/pkcs10 p10 csr 11 | application/pkix-cert cer crt der 12 | application/pkix-crl crl 13 | application/pkcs7-mime p7c 14 | # Netscape version of application/pkix-cert 15 | # application/x-x509-ca-cert crt der 16 | # application/x-x509-user-cert crt 17 | application/x-pkcs7-crl crl 18 | application/x-pem-file pem 19 | application/x-pkcs12 p12 pfx 20 | application/x-pkcs7-certificates p7b spc 21 | application/x-pkcs7-certreqresp p7r 22 | application/x-java-keystore jks 23 | application/x-java-jce-keystore jceks 24 | application/x-java-bc-keystore bks 25 | application/x-java-bc-uber-keystore ubr 26 | font/ttf ttf 27 | font/woff woff 28 | font/woff2 woff2 29 | 30 | image/svg+xml svg 31 | image/x-ico ico 32 | 33 | application/python py 34 | application/x-groovy groovy 35 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/META-INF/services/loghub.commands.CommandLineHandler: -------------------------------------------------------------------------------- 1 | loghub.commands.TimePattern 2 | loghub.commands.CommandJwt 3 | loghub.commands.CommandPassword 4 | loghub.commands.TestPipeline 5 | loghub.commands.Launch 6 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/META-INF/services/loghub.netty.transport.PollerServiceProvider: -------------------------------------------------------------------------------- 1 | loghub.netty.transport.NioPollerServiceProvider 2 | loghub.netty.transport.OioPollerServiceProvider 3 | loghub.netty.transport.EpollPollerServiceProvider 4 | loghub.netty.transport.IoUringPollerServiceProvider 5 | loghub.netty.transport.KQueuePollerServiceProvider 6 | loghub.netty.transport.LocalPollerServiceProvider 7 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/apache: -------------------------------------------------------------------------------- 1 | HTTPDERROR_DATE %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{YEAR} 2 | HTTPDATE %{MONTHDAY}/%{MONTH}/%{YEAR}:%{TIME} %{INT} 3 | 4 | # Shortcuts 5 | QS %{QUOTEDSTRING} 6 | 7 | COMMONAPACHELOG %{IPORHOST:clientip} %{HTTPDUSER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-) 8 | COMBINEDAPACHELOG %{COMMONAPACHELOG} %{QS:referrer} %{QS:agent} 9 | HTTPD20_ERRORLOG \[%{HTTPDERROR_DATE:timestamp}\] \[%{LOGLEVEL:loglevel}\] (?:\[client %{IPORHOST:clientip}\] ){0,1}%{GREEDYDATA:errormsg} 10 | HTTPD24_ERRORLOG \[%{HTTPDERROR_DATE:timestamp}\] \[%{WORD:module}:%{LOGLEVEL:loglevel}\] \[pid %{POSINT:pid}:tid %{NUMBER:tid}\]( \(%{POSINT:proxy_errorcode}\)%{DATA:proxy_errormessage}:)?( \[client %{IPORHOST:client}:%{POSINT:clientport}\])? %{DATA:errorcode}: %{GREEDYDATA:message} 11 | HTTPD_ERRORLOG %{HTTPD20_ERRORLOG}|%{HTTPD24_ERRORLOG} 12 | 13 | HTTPDUSER %{EMAILADDRESS}|%{USER} 14 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/aws: -------------------------------------------------------------------------------- 1 | S3_REQUEST_LINE (?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest}) 2 | 3 | S3_ACCESS_LOG %{WORD:owner} %{NOTSPACE:bucket} \[%{HTTPDATE:timestamp}\] %{IP:clientip} %{NOTSPACE:requester} %{NOTSPACE:request_id} %{NOTSPACE:operation} %{NOTSPACE:key} (?:"%{S3_REQUEST_LINE}"|-) (?:%{INT:response:int}|-) (?:-|%{NOTSPACE:error_code}) (?:%{INT:bytes:int}|-) (?:%{INT:object_size:int}|-) (?:%{INT:request_time_ms:int}|-) (?:%{INT:turnaround_time_ms:int}|-) (?:%{QS:referrer}|-) (?:"?%{QS:agent}"?|-) (?:-|%{NOTSPACE:version_id}) 4 | 5 | ELB_URIPATHPARAM %{URIPATH:path}(?:%{URIPARAM:params})? 6 | 7 | ELB_URI %{URIPROTO:proto}://(?:%{USER}(?::[^@]*)?@)?(?:%{URIHOST:urihost})?(?:%{ELB_URIPATHPARAM})? 8 | 9 | ELB_REQUEST_LINE (?:%{WORD:verb} %{ELB_URI:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest}) 10 | 11 | ELB_ACCESS_LOG %{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE:elb} %{IP:clientip}:%{INT:clientport:int} (?:(%{IP:backendip}:?:%{INT:backendport:int})|-) %{NUMBER:request_processing_time:float} %{NUMBER:backend_processing_time:float} %{NUMBER:response_processing_time:float} %{INT:response:int} %{INT:backend_response:int} %{INT:received_bytes:int} %{INT:bytes:int} "%{ELB_REQUEST_LINE}" 12 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/exim: -------------------------------------------------------------------------------- 1 | EXIM_MSGID [0-9A-Za-z]{6}-[0-9A-Za-z]{6}-[0-9A-Za-z]{2} 2 | EXIM_FLAGS (<=|[-=>*]>|[*]{2}|==) 3 | EXIM_DATE %{YEAR:exim_year}-%{MONTHNUM:exim_month}-%{MONTHDAY:exim_day} %{TIME:exim_time} 4 | EXIM_PID \[%{POSINT}\] 5 | EXIM_QT ((\d+y)?(\d+w)?(\d+d)?(\d+h)?(\d+m)?(\d+s)?) 6 | EXIM_EXCLUDE_TERMS (Message is frozen|(Start|End) queue run| Warning: | retry time not reached | no (IP address|host name) found for (IP address|host) | unexpected disconnection while reading SMTP command | no immediate delivery: |another process is handling this message) 7 | EXIM_REMOTE_HOST (H=(%{NOTSPACE:remote_hostname} )?(\(%{NOTSPACE:remote_heloname}\) )?\[%{IP:remote_host}\]) 8 | EXIM_INTERFACE (I=\[%{IP:exim_interface}\](:%{NUMBER:exim_interface_port})) 9 | EXIM_PROTOCOL (P=%{NOTSPACE:protocol}) 10 | EXIM_MSG_SIZE (S=%{NUMBER:exim_msg_size}) 11 | EXIM_HEADER_ID (id=%{NOTSPACE:exim_header_id}) 12 | EXIM_SUBJECT (T=%{QS:exim_subject}) 13 | 14 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/java: -------------------------------------------------------------------------------- 1 | JAVACLASS (?:[a-zA-Z$_][a-zA-Z$_0-9]*\.)*[a-zA-Z$_][a-zA-Z$_0-9]* 2 | #Space is an allowed character to match special cases like 'Native Method' or 'Unknown Source' 3 | JAVAFILE (?:[A-Za-z0-9_. -]+) 4 | #Allow special method 5 | JAVAMETHOD (?:()|[a-zA-Z$_][a-zA-Z$_0-9]*) 6 | #Line number is optional in special cases 'Native method' or 'Unknown source' 7 | JAVASTACKTRACEPART %{SPACE}at %{JAVACLASS:class}\.%{JAVAMETHOD:method}\(%{JAVAFILE:file}(?::%{NUMBER:line})?\) 8 | # Java Logs 9 | JAVATHREAD (?:[A-Z]{2}-Processor[\d]+) 10 | JAVALOGMESSAGE (.*) 11 | # MMM dd, yyyy HH:mm:ss eg: Jan 9, 2014 7:13:13 AM 12 | CATALINA_DATESTAMP %{MONTH} %{MONTHDAY}, 20%{YEAR} %{HOUR}:?%{MINUTE}(?::?%{SECOND}) (?:AM|PM) 13 | # yyyy-MM-dd HH:mm:ss,SSS ZZZ eg: 2014-01-09 17:32:25,527 -0800 14 | TOMCAT_DATESTAMP 20%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{HOUR}:?%{MINUTE}(?::?%{SECOND}) %{ISO8601_TIMEZONE} 15 | CATALINALOG %{CATALINA_DATESTAMP:timestamp} %{JAVACLASS:class} %{JAVALOGMESSAGE:logmessage} 16 | # 2014-01-09 20:03:28,269 -0800 | ERROR | com.example.service.ExampleService - something compeletely unexpected happened... 17 | TOMCATLOG %{TOMCAT_DATESTAMP:timestamp} \| %{LOGLEVEL:level} \| %{JAVACLASS:class} - %{JAVALOGMESSAGE:logmessage} 18 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/junos: -------------------------------------------------------------------------------- 1 | # JUNOS 11.4 RT_FLOW patterns 2 | RT_FLOW_EVENT (RT_FLOW_SESSION_CREATE|RT_FLOW_SESSION_CLOSE|RT_FLOW_SESSION_DENY) 3 | 4 | RT_FLOW1 %{RT_FLOW_EVENT:event}: %{GREEDYDATA:close-reason}: %{IP:src-ip}/%{INT:src-port}->%{IP:dst-ip}/%{INT:dst-port} %{DATA:service} %{IP:nat-src-ip}/%{INT:nat-src-port}->%{IP:nat-dst-ip}/%{INT:nat-dst-port} %{DATA:src-nat-rule-name} %{DATA:dst-nat-rule-name} %{INT:protocol-id} %{DATA:policy-name} %{DATA:from-zone} %{DATA:to-zone} %{INT:session-id} \d+\(%{DATA:sent}\) \d+\(%{DATA:received}\) %{INT:elapsed-time} .* 5 | 6 | RT_FLOW2 %{RT_FLOW_EVENT:event}: session created %{IP:src-ip}/%{INT:src-port}->%{IP:dst-ip}/%{INT:dst-port} %{DATA:service} %{IP:nat-src-ip}/%{INT:nat-src-port}->%{IP:nat-dst-ip}/%{INT:nat-dst-port} %{DATA:src-nat-rule-name} %{DATA:dst-nat-rule-name} %{INT:protocol-id} %{DATA:policy-name} %{DATA:from-zone} %{DATA:to-zone} %{INT:session-id} .* 7 | 8 | RT_FLOW3 %{RT_FLOW_EVENT:event}: session denied %{IP:src-ip}/%{INT:src-port}->%{IP:dst-ip}/%{INT:dst-port} %{DATA:service} %{INT:protocol-id}\(\d\) %{DATA:policy-name} %{DATA:from-zone} %{DATA:to-zone} .* 9 | 10 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/mcollective: -------------------------------------------------------------------------------- 1 | MCOLLECTIVEAUDIT %{TIMESTAMP_ISO8601:timestamp}: 2 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/mcollective-patterns: -------------------------------------------------------------------------------- 1 | # Remember, these can be multi-line events. 2 | MCOLLECTIVE ., \[%{TIMESTAMP_ISO8601:timestamp} #%{POSINT:pid}\]%{SPACE}%{LOGLEVEL:event_level} 3 | 4 | MCOLLECTIVEAUDIT %{TIMESTAMP_ISO8601:timestamp}: 5 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/mongodb: -------------------------------------------------------------------------------- 1 | MONGO_LOG %{SYSLOGTIMESTAMP:timestamp} \[%{WORD:component}\] %{GREEDYDATA:message} 2 | MONGO_QUERY \{ (?<={ ).*(?= } ntoreturn:) \} 3 | MONGO_SLOWQUERY %{WORD} %{MONGO_WORDDASH:database}\.%{MONGO_WORDDASH:collection} %{WORD}: %{MONGO_QUERY:query} %{WORD}:%{NONNEGINT:ntoreturn} %{WORD}:%{NONNEGINT:ntoskip} %{WORD}:%{NONNEGINT:nscanned}.*nreturned:%{NONNEGINT:nreturned}..+ (?[0-9]+)ms 4 | MONGO_WORDDASH \b[\w-]+\b 5 | MONGO3_SEVERITY \w 6 | MONGO3_COMPONENT %{WORD}|- 7 | MONGO3_LOG %{TIMESTAMP_ISO8601:timestamp} %{MONGO3_SEVERITY:severity} %{MONGO3_COMPONENT:component}%{SPACE}(?:\[%{DATA:context}\])? %{GREEDYDATA:message} 8 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/nodename: -------------------------------------------------------------------------------- 1 | NODENAME [a-zA-Z0-9_-]+ 2 | LOCALDOMAIN (\.localdomain)? 3 | LOCALHOST localhost 4 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/postgresql: -------------------------------------------------------------------------------- 1 | # Default postgresql pg_log format pattern 2 | POSTGRESQL %{DATESTAMP:timestamp} %{TZ} %{DATA:user_id} %{GREEDYDATA:connection_id} %{POSINT:pid} 3 | 4 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/rails: -------------------------------------------------------------------------------- 1 | RUUID \h{32} 2 | # rails controller with action 3 | RCONTROLLER (?[^#]+)#(?\w+) 4 | 5 | # this will often be the only line: 6 | RAILS3HEAD (?m)Started %{WORD:verb} "%{URIPATHPARAM:request}" for %{IPORHOST:clientip} at (?%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{HOUR}:%{MINUTE}:%{SECOND} %{ISO8601_TIMEZONE}) 7 | # for some a strange reason, params are stripped of {} - not sure that's a good idea. 8 | RPROCESSING \W*Processing by %{RCONTROLLER} as (?\S+)(?:\W*Parameters: {%{DATA:params}}\W*)? 9 | RAILS3FOOT Completed %{NUMBER:response}%{DATA} in %{NUMBER:totalms}ms %{RAILS3PROFILE}%{GREEDYDATA} 10 | RAILS3PROFILE (?:\(Views: %{NUMBER:viewms}ms \| ActiveRecord: %{NUMBER:activerecordms}ms|\(ActiveRecord: %{NUMBER:activerecordms}ms)? 11 | 12 | # putting it all together 13 | RAILS3 %{RAILS3HEAD}(?:%{RPROCESSING})?(?(?:%{DATA}\n)*)(?:%{RAILS3FOOT})? 14 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/redis: -------------------------------------------------------------------------------- 1 | REDISTIMESTAMP %{MONTHDAY} %{MONTH} %{TIME} 2 | REDISLOG \[%{POSINT:pid}\] %{REDISTIMESTAMP:timestamp} \* 3 | 4 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/ruby: -------------------------------------------------------------------------------- 1 | RUBY_LOGLEVEL (?:DEBUG|FATAL|ERROR|WARN|INFO) 2 | RUBY_LOGGER [DFEWI], \[%{TIMESTAMP_ISO8601:timestamp} #%{POSINT:pid}\] *%{RUBY_LOGLEVEL:loglevel} -- +%{DATA:progname}: %{GREEDYDATA:message} 3 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/squid: -------------------------------------------------------------------------------- 1 | SQUIDLINE ^%{TIMESTAMP_ISO8601:timestamp8601} +%{NUMBER:resptime} +%{IP:squidclient} +%{WORD:squidstatus}/%{NUMBER:remotestatus} +%{NUMBER:replysize} +%{WORD:reqmethod} +%{QUOTEDSTRING:request} +%{WORD:squidhierastatus}/(%{IP:ipremote}|-) +%{NOTSPACE:contenttype} 2 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/patterns/time: -------------------------------------------------------------------------------- 1 | # Months: January, Feb, 3, 03, 12, December 2 | MONTH \b(?:Jan(?:uary|uar)?|Feb(?:ruary|ruar)?|M(?:a|ä)?r(?:ch|z)?|Apr(?:il)?|Ma(?:y|i)?|Jun(?:e|i)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|O(?:c|k)?t(?:ober)?|Nov(?:ember)?|De(?:c|z)(?:ember)?)\b 3 | MONTHNUM (?:0?[1-9]|1[0-2]) 4 | MONTHNUM2 (?:0[1-9]|1[0-2]) 5 | MONTHDAY (?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9]) 6 | 7 | # Days: Monday, Tue, Thu, etc... 8 | DAY (?:Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?) 9 | 10 | # Years? 11 | YEAR (?>\d\d){1,2} 12 | HOUR (?:2[0123]|[01]?[0-9]) 13 | MINUTE (?:[0-5][0-9]) 14 | # '60' is a leap second in most time standards and thus is valid. 15 | SECOND (?:(?:[0-5]?[0-9]|60)(?:[:.,][0-9]+)?) 16 | TIME (?!<[0-9])%{HOUR}:%{MINUTE}(?::%{SECOND})(?![0-9]) 17 | # datestamp is YYYY/MM/DD-HH:MM:SS.UUUU (or something like it) 18 | DATE_US %{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR} 19 | DATE_EU %{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR} 20 | ISO8601_TIMEZONE (?:Z|[+-]%{HOUR}(?::?%{MINUTE})) 21 | TIMESTAMP_ISO8601 (?:%{YEAR})-(?:%{MONTHNUM})-%{MONTHDAY}[T ](?:%{HOUR}):?(?:%{MINUTE})(?::?%{SECOND})?(?:%{ISO8601_TIMEZONE})? 22 | DATE %{DATE_US}|%{DATE_EU} 23 | DATESTAMP %{DATE}[- ]%{TIME} 24 | TZ (?:[PMCEWH][SDE]S?T|UTC|GMT) 25 | DATESTAMP_RFC822 %{DAY} %{MONTH} %{MONTHDAY} %{YEAR} %{TIME} %{TZ} 26 | DATESTAMP_RFC2822 %{DAY}, %{MONTHDAY} %{MONTH} %{YEAR} %{TIME} %{ISO8601_TIMEZONE} 27 | DATESTAMP_OTHER %{DAY} %{MONTH} %{MONTHDAY} %{TIME} %{TZ} %{YEAR} 28 | DATESTAMP_EVENTLOG %{YEAR}%{MONTHNUM2}%{MONTHDAY}%{HOUR}%{MINUTE}%{SECOND} 29 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/propertiestype.properties: -------------------------------------------------------------------------------- 1 | hprofDumpPath=STRING 2 | includes=OPTIONAL_ARRAY 3 | jaasConfig=STRING 4 | locale=STRING 5 | maxSteps=INTEGER 6 | numWorkers=INTEGER 7 | plugins=OPTIONAL_ARRAY 8 | poller=STRING 9 | queueDepth=INTEGER 10 | queueWeight=INTEGER 11 | secrets.source=STRING 12 | timezone=STRING 13 | 14 | http.SSLClientAuthentication=STRING 15 | http.SSLKeyAlias=STRING 16 | http.hstsDuration=STRING 17 | http.jaasName=STRING 18 | http.jwt=BOOLEAN 19 | http.listen=STRING 20 | http.port=INTEGER 21 | http.sslContext=IMPLICIT_OBJECT 22 | http.sslParams=IMPLICIT_OBJECT 23 | http.withSSL=BOOLEAN 24 | 25 | jmx.hostname=STRING 26 | jmx.jaasName=STRING 27 | jmx.listen=STRING 28 | jmx.port=INTEGER 29 | jmx.protocol=STRING 30 | jmx.providerPackages=STRING 31 | jmx.serviceUrl=STRING 32 | jmx.sslContext=IMPLICIT_OBJECT 33 | jmx.sslParams=IMPLICIT_OBJECT 34 | jmx.withSsl=BOOLEAN 35 | 36 | jwt.alg=STRING 37 | jwt.secret=STRING 38 | 39 | log4j.configFile=STRING 40 | log4j.configURL=STRING 41 | log4j.defaultlevel=STRING 42 | 43 | ssl.context=STRING 44 | ssl.ephemeralDHKeySize=INTEGER 45 | ssl.issuers=OPTIONAL_ARRAY 46 | ssl.keymanageralgorithm=STRING 47 | ssl.providerclass=STRING 48 | ssl.rejectClientInitiatedRenegotiation=INTEGER 49 | ssl.securerandom=STRING 50 | ssl.trustmanageralgorithm=STRING 51 | ssl.trusts=OPTIONAL_ARRAY 52 | ssl.clientSessionTimeout=INTEGER 53 | ssl.clientSessionCacheSize=INTEGER 54 | ssl.serverSessionTimeout=INTEGER 55 | ssl.serverSessionCacheSize=INTEGER 56 | 57 | zmq.certsDirectory=STRING 58 | zmq.keystore=STRING 59 | zmq.linger=INTEGER 60 | zmq.numSocket=INTEGER 61 | zmq.withZap=BOOLEAN 62 | -------------------------------------------------------------------------------- /loghub-core/src/main/resources/static/Lato:400,700.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Lato'; 3 | font-style: normal; 4 | font-weight: 400; 5 | src: local('Lato Regular'), local('Lato-Regular'), url(https://fonts.gstatic.com/s/lato/v11/v0SdcGFAl2aezM9Vq_aFTQ.ttf) format('truetype'); 6 | } 7 | @font-face { 8 | font-family: 'Lato'; 9 | font-style: normal; 10 | font-weight: 700; 11 | src: local('Lato Bold'), local('Lato-Bold'), url(https://fonts.gstatic.com/s/lato/v11/DvlFBScY1r-FMtZSYIYoYw.ttf) format('truetype'); 12 | } 13 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/TestMime.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class TestMime { 7 | 8 | @Test 9 | public void test() { 10 | Assert.assertEquals("text/html", Helpers.getMimeType("index.html")); 11 | Assert.assertEquals("text/javascript", Helpers.getMimeType("charts.js")); 12 | Assert.assertEquals("text/css", Helpers.getMimeType("Lato:400,700.css")); 13 | Assert.assertEquals("application/x-pkcs12", Helpers.getMimeType("trust.p12")); 14 | Assert.assertEquals("application/x-pem-file", Helpers.getMimeType("trust.pem")); 15 | Assert.assertEquals("application/pkix-cert", Helpers.getMimeType("trust.crt")); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/commands/TestTimePattern.java: -------------------------------------------------------------------------------- 1 | package loghub.commands; 2 | 3 | import java.io.IOException; 4 | 5 | import org.junit.Test; 6 | 7 | import loghub.Tools; 8 | 9 | public class TestTimePattern { 10 | 11 | @Test 12 | public void testParseArgumensts() throws IOException { 13 | Parser parser = new Parser(); 14 | Tools.executeCmd(parser, "1970-01-01 01:00Z -> 1970-01-01T01:00Z\n",0, "--timepattern", "yyyy-MM-dd HH:mm:ssZ", "1970-01-01 01:00Z"); 15 | Tools.executeCmd(parser, "failed parsing \"a\" with \"seconds\": Not a number\n",0, "--timepattern", "seconds", "a"); 16 | Tools.executeCmd(parser, "Invalid date time pattern \"invalid\": Unknown pattern letter: i\n", ExitCode.INVALIDARGUMENTS, "--timepattern", "invalid", "0"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/configuration/TestSslContextConfiguration.java: -------------------------------------------------------------------------------- 1 | package loghub.configuration; 2 | 3 | import java.io.IOException; 4 | import java.io.StringReader; 5 | 6 | import org.apache.logging.log4j.Level; 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | import org.junit.Assert; 10 | import org.junit.BeforeClass; 11 | import org.junit.Test; 12 | 13 | import loghub.LogUtils; 14 | import loghub.Tools; 15 | import loghub.receivers.TcpLinesStream; 16 | 17 | public class TestSslContextConfiguration { 18 | 19 | @BeforeClass 20 | public static void configure() { 21 | Tools.configure(); 22 | Logger logger = LogManager.getLogger(); 23 | LogUtils.setLevel(logger, Level.TRACE, "loghub.configuration"); 24 | } 25 | 26 | @Test 27 | public void loadConf() throws IOException { 28 | String config = "input { loghub.receivers.TcpLinesStream { port: 0, decoder: loghub.decoders.StringCodec, sslContext: {trusts: [\"target/test-classes/loghub.p12\"]} }} | $main pipeline[main]{}"; 29 | StringReader configReader = new StringReader(config); 30 | Properties p = Tools.loadConf(configReader); 31 | TcpLinesStream receiver = (TcpLinesStream) p.receivers.stream().findAny().get(); 32 | Assert.assertNotEquals(p.ssl, receiver.getSslContext()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/events/Mocker.java: -------------------------------------------------------------------------------- 1 | package loghub.events; 2 | 3 | import static org.mockito.Mockito.mock; 4 | 5 | public class Mocker { 6 | 7 | private Mocker() { 8 | //Empty 9 | } 10 | 11 | public static Event getMock() { 12 | return mock(EventInstance.class); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/netty/transport/TestPoller.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.transport; 2 | 3 | import org.apache.logging.log4j.Level; 4 | import org.apache.logging.log4j.LogManager; 5 | import org.apache.logging.log4j.Logger; 6 | import org.junit.Assert; 7 | import org.junit.BeforeClass; 8 | import org.junit.Test; 9 | 10 | import loghub.LogUtils; 11 | import loghub.Tools; 12 | 13 | public class TestPoller { 14 | 15 | private static final boolean IS_MAC; 16 | private static final boolean IS_LINUX; 17 | 18 | static { 19 | String operatingSystem = System.getProperty("os.name", ""); 20 | IS_MAC = operatingSystem.startsWith("Mac"); 21 | IS_LINUX = operatingSystem.startsWith("Linux"); 22 | } 23 | 24 | @BeforeClass 25 | public static void configure() { 26 | Tools.configure(); 27 | Logger logger = LogManager.getLogger(); 28 | LogUtils.setLevel(logger, Level.TRACE, "loghub.netty"); 29 | } 30 | 31 | @Test 32 | public void testPollers() { 33 | Assert.assertTrue(POLLER.NIO.isAvailable()); 34 | Assert.assertTrue(POLLER.OIO.isAvailable()); 35 | Assert.assertEquals(IS_MAC, POLLER.KQUEUE.isAvailable()); 36 | Assert.assertEquals(IS_LINUX, POLLER.EPOLL.isAvailable()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/processors/TestFailure.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import org.junit.Test; 4 | 5 | import loghub.Processor; 6 | import loghub.ProcessorException; 7 | import loghub.events.Event; 8 | import loghub.events.EventsFactory; 9 | 10 | public class TestFailure { 11 | 12 | private final EventsFactory factory = new EventsFactory(); 13 | 14 | @Test(expected = ProcessorException.class) 15 | public void test() throws ProcessorException { 16 | Processor p = new Processor() { 17 | 18 | @Override 19 | public boolean process(Event event) throws ProcessorException { 20 | throw event.buildException("test failure", new RuntimeException("test failure")); 21 | } 22 | 23 | @Override 24 | public String getName() { 25 | return null; 26 | } 27 | 28 | }; 29 | 30 | Event event = factory.newEvent(); 31 | 32 | event.process(p); 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/processors/TestFire.java: -------------------------------------------------------------------------------- 1 | package loghub.processors; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.logging.log4j.Level; 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | import org.junit.Assert; 9 | import org.junit.BeforeClass; 10 | import org.junit.Test; 11 | 12 | import loghub.Helpers; 13 | import loghub.LogUtils; 14 | import loghub.Tools; 15 | import loghub.configuration.ConfigException; 16 | import loghub.configuration.Properties; 17 | import loghub.events.Event; 18 | import loghub.events.EventsFactory; 19 | 20 | public class TestFire { 21 | 22 | private final EventsFactory factory = new EventsFactory(); 23 | 24 | @BeforeClass 25 | public static void configure() { 26 | Tools.configure(); 27 | Logger logger = LogManager.getLogger(); 28 | LogUtils.setLevel(logger, Level.TRACE); 29 | } 30 | 31 | @Test 32 | public void test() throws ConfigException, IOException { 33 | Properties conf = Tools.loadConf("fire.conf"); 34 | Helpers.parallelStartProcessor(conf); 35 | Event sent = factory.newEvent(); 36 | sent.put("count", 2); 37 | 38 | Tools.runProcessing(sent, conf.namedPipeLine.get("main"), conf); 39 | Event old = conf.mainQueue.remove(); 40 | Event newevent = conf.mainQueue.remove(); 41 | Assert.assertEquals("Not matching old event", old.get("count"), 2); 42 | Assert.assertEquals("Event not fired", 6, newevent.get("c")); 43 | 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/receivers/ReceiverTools.java: -------------------------------------------------------------------------------- 1 | package loghub.receivers; 2 | 3 | import loghub.ConnectionContext; 4 | import loghub.decoders.DecodeException; 5 | import loghub.decoders.Decoder; 6 | 7 | import static org.mockito.ArgumentMatchers.any; 8 | import static org.mockito.Mockito.mock; 9 | import static org.mockito.Mockito.when; 10 | 11 | public class ReceiverTools { 12 | 13 | private ReceiverTools() { 14 | 15 | } 16 | 17 | public static Decoder getFailingDecoder() { 18 | try { 19 | Decoder decoder = mock(Decoder.class); 20 | when(decoder.decode(any(ConnectionContext.class), any(byte[].class))).thenThrow(new DecodeException("Dummy exception")); 21 | return decoder; 22 | } catch (DecodeException e) { 23 | // never reached 24 | return null; 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/senders/BlockingConnectionContext.java: -------------------------------------------------------------------------------- 1 | package loghub.senders; 2 | 3 | import java.util.concurrent.Semaphore; 4 | 5 | import loghub.BuildableConnectionContext; 6 | 7 | /** 8 | * Allows to check that asynchronous acknowledge is indeed being called 9 | * @author Fabrice Bacchella 10 | * 11 | */ 12 | public class BlockingConnectionContext extends BuildableConnectionContext { 13 | 14 | final Semaphore lock = new Semaphore(1); 15 | 16 | public BlockingConnectionContext() { 17 | lock.drainPermits(); 18 | setOnAcknowledge(lock::release); 19 | } 20 | 21 | @Override 22 | public Semaphore getLocalAddress() { 23 | return lock; 24 | } 25 | 26 | @Override 27 | public Semaphore getRemoteAddress() { 28 | return lock; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/senders/InMemorySender.java: -------------------------------------------------------------------------------- 1 | package loghub.senders; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import loghub.BuilderClass; 8 | import loghub.events.Event; 9 | 10 | @BuilderClass(InMemorySender.Builder.class) 11 | public class InMemorySender extends Sender { 12 | 13 | public static class Builder extends Sender.Builder { 14 | 15 | @Override 16 | public InMemorySender build() { 17 | return new InMemorySender(this); 18 | } 19 | 20 | } 21 | public static Builder getBuilder() { 22 | return new Builder(); 23 | } 24 | 25 | public InMemorySender(Builder builder) { 26 | super(builder); 27 | } 28 | 29 | private final List received = new ArrayList<>(); 30 | 31 | @Override 32 | public boolean send(Event e) { 33 | received.add(e); 34 | return true; 35 | } 36 | 37 | @Override 38 | public String getSenderName() { 39 | return toString(); 40 | } 41 | 42 | public List getSendedEvents() { 43 | return Collections.unmodifiableList(received); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/sources/TestFailed.java: -------------------------------------------------------------------------------- 1 | package loghub.sources; 2 | 3 | import java.io.IOException; 4 | import java.io.StringReader; 5 | 6 | import org.junit.Test; 7 | 8 | import loghub.configuration.ConfigException; 9 | import loghub.configuration.Configuration; 10 | 11 | public class TestFailed { 12 | 13 | @Test(expected = ConfigException.class) 14 | public void testLog() throws ConfigException, IOException { 15 | String confile = "pipeline[main] {[a] @ [a] %source1}"; 16 | Configuration.parse(new StringReader(confile)); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/types/TestDn.java: -------------------------------------------------------------------------------- 1 | package loghub.types; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class TestDn { 7 | 8 | @Test 9 | public void test() { 10 | compare("cn=Mango, ou=Fruits, o=Food", "cn=Mango, ou=Fruits, o=Food"); 11 | compare("o=Food; ou=Fruits; cn=Mango", "o=Food, ou=Fruits, cn=Mango"); 12 | compare("CN=Steve Kille,O=Isode Limited,C=GB", "CN=Steve Kille, O=Isode Limited, C=GB"); 13 | compare(" CN=Steve Kille , O=Isode Limited , C=GB ", "CN=Steve Kille, O=Isode Limited, C=GB"); 14 | compare("OU=Sales+CN=J. Smith,O=Widget Inc.,C=US", "CN=J. Smith+OU=Sales, O=Widget Inc., C=US"); 15 | compare("OU=Sales+CN=J. Smith,O=Widget Inc.;C=US", "CN=J. Smith+OU=Sales, O=Widget Inc., C=US"); 16 | compare("OU=Sales+CN=J. Smith,O=Widget Inc.;C=US", "CN=J. Smith+OU=Sales, O=Widget Inc., C=US"); 17 | compare("OU=Sales + CN=J. Smith,O=Widget Inc.;C=US", "CN=J. Smith+OU=Sales, O=Widget Inc., C=US"); 18 | compare("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB", "CN=L. Eagle, O=Sue\\, Grabbit and Runn, C=GB"); 19 | } 20 | 21 | private void compare(String dn, String expected) { 22 | Assert.assertEquals(new Dn(expected), new Dn(dn)); 23 | Assert.assertEquals(expected, new Dn(dn).toString()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/types/TestMimeType.java: -------------------------------------------------------------------------------- 1 | package loghub.types; 2 | 3 | import java.util.Map; 4 | 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | import loghub.VarFormatter; 9 | 10 | public class TestMimeType { 11 | 12 | private static final VarFormatter vf = new VarFormatter("${%j}"); 13 | 14 | @Test 15 | public void testJson() { 16 | MimeType json = MimeType.of("AppliCation / json"); 17 | Assert.assertEquals("application", json.getPrimaryType()); 18 | Assert.assertEquals("json", json.getSubType()); 19 | Assert.assertEquals("application/json", json.toString()); 20 | Assert.assertEquals("{\"json\":\"application/json\"}", vf.format(Map.of("json", json))); 21 | } 22 | 23 | @Test 24 | public void testProtoProtobuf() { 25 | MimeType protobuf = MimeType.of("application/vnd.google.protobuf; proto = loghub.Message; encoding=delimited"); 26 | Assert.assertEquals("application", protobuf.getPrimaryType()); 27 | Assert.assertEquals("vnd.google.protobuf", protobuf.getSubType()); 28 | Assert.assertEquals("loghub.Message", protobuf.getParameter("proto")); 29 | Assert.assertEquals("application/vnd.google.protobuf; encoding=delimited; proto=loghub.Message", protobuf.toString()); 30 | Assert.assertEquals("{\"protobuf\":\"application/vnd.google.protobuf; encoding=delimited; proto=loghub.Message\"}", vf.format(Map.of("protobuf", protobuf))); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/zmq/TestContext.java: -------------------------------------------------------------------------------- 1 | package loghub.zmq; 2 | 3 | import java.net.InetSocketAddress; 4 | 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | import loghub.cloners.NotClonableException; 9 | import loghub.events.Event; 10 | import loghub.events.EventsFactory; 11 | import zmq.Msg; 12 | import zmq.io.Metadata; 13 | import zmq.io.mechanism.Mechanisms; 14 | 15 | public class TestContext { 16 | 17 | private final EventsFactory factory = new EventsFactory(); 18 | 19 | @Test 20 | public void testContext() throws NotClonableException { 21 | InetSocketAddress sa = InetSocketAddress.createUnresolved("127.0.0.1", 32000); 22 | Msg msg = new Msg(10); 23 | Metadata md = new Metadata(); 24 | md.put(Metadata.PEER_ADDRESS, sa.toString()); 25 | md.put("X-Self-Address", sa.toString()); 26 | md.put(Metadata.USER_ID, "loghub"); 27 | msg.setMetadata(md); 28 | Event ev = factory.newEvent(new ZmqConnectionContext(msg, Mechanisms.CURVE)); 29 | Event forked = ev.duplicate(); 30 | Assert.assertEquals("loghub", forked.getConnectionContext().getPrincipal().getName()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /loghub-core/src/test/java/loghub/zmq/TestHeader.java: -------------------------------------------------------------------------------- 1 | package loghub.zmq; 2 | 3 | import java.io.IOException; 4 | 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | import loghub.zmq.MsgHeaders.Header; 9 | 10 | public class TestHeader { 11 | 12 | @Test 13 | public void testHeader() throws IOException { 14 | MsgHeaders header = new MsgHeaders(); 15 | header.addHeader(Header.MIME_TYPE, "cbor"); 16 | header.addHeader(Header.ENCODING, "none"); 17 | Assert.assertEquals(header, new MsgHeaders(header.getContent())); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/TestProcessor.noclass: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/TestProcessor.noclass -------------------------------------------------------------------------------- /loghub-core/src/test/resources/array.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { 2 | loghub.processors.SyslogPriority { 3 | fields: [ "a", "b" ] 4 | } | 5 | loghub.configuration.TestConfigurations$TestArrayProcessor { 6 | expressions: [ [a], [b] ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/conditions.conf: -------------------------------------------------------------------------------- 1 | pipeline [ifpipe] { 2 | loghub.processors.Convert { 3 | className: "java.lang.Integer", 4 | field: "a", 5 | if: false 6 | } 7 | } 8 | pipeline [successpipe] { 9 | loghub.processors.Convert { 10 | className: "java.lang.Integer", 11 | field: "a", 12 | success: [test] = "success" 13 | } 14 | } 15 | pipeline [failurepipe] { 16 | loghub.processors.Convert { 17 | className: "java.lang.Integer", 18 | field: "a", 19 | exception: ([test] = "failure" | [lastException] = [@lastException]) 20 | } 21 | } 22 | pipeline [subpipe] { 23 | loghub.processors.Convert { 24 | className: "java.lang.Integer", 25 | field: "a", 26 | success: { [b] = 1 | [c] = 2} 27 | } 28 | } 29 | pipeline [ignore] { 30 | loghub.processors.Convert { 31 | className: "java.lang.Integer", 32 | field: "a", 33 | success: [b] = 1, 34 | failure: [c] = 1, 35 | exception: [d] = 1, 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/crypto/domain.policy: -------------------------------------------------------------------------------- 1 | domain loghub { 2 | keystore loghubca 3 | keystoreType="PKCS12" 4 | keystoreURI="src/test/resources/loghub.p12"; 5 | }; 6 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/crypto/isrg-root-x2.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICGzCCAaGgAwIBAgIQQdKd0XLq7qeAwSxs6S+HUjAKBggqhkjOPQQDAzBPMQsw 3 | CQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2gg 4 | R3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBYMjAeFw0yMDA5MDQwMDAwMDBaFw00 5 | MDA5MTcxNjAwMDBaME8xCzAJBgNVBAYTAlVTMSkwJwYDVQQKEyBJbnRlcm5ldCBT 6 | ZWN1cml0eSBSZXNlYXJjaCBHcm91cDEVMBMGA1UEAxMMSVNSRyBSb290IFgyMHYw 7 | EAYHKoZIzj0CAQYFK4EEACIDYgAEzZvVn4CDCuwJSvMWSj5cz3es3mcFDR0HttwW 8 | +1qLFNvicWDEukWVEYmO6gbf9yoWHKS5xcUy4APgHoIYOIvXRdgKam7mAHf7AlF9 9 | ItgKbppbd9/w+kHsOdx1ymgHDB/qo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0T 10 | AQH/BAUwAwEB/zAdBgNVHQ4EFgQUfEKWrt5LSDv6kviejM9ti6lyN5UwCgYIKoZI 11 | zj0EAwMDaAAwZQIwe3lORlCEwkSHRhtFcP9Ymd70/aTSVaYgLXTWNLxBo1BfASdW 12 | tL4ndQavEi51mI38AjEAi/V3bNTIZargCyzuFJ0nN6T5U6VR5CmD1/iQMVtCnwr1 13 | /q4AaOeMSQ+2b1tbFfLn 14 | -----END CERTIFICATE----- 15 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/crypto/openssh.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW 3 | QyNTUxOQAAACDu5gXJ3fQrkx20FNGWTRkX1l0KaAyn6CI/XYlv6c0xLwAAAJiBbHEegWxx 4 | HgAAAAtzc2gtZWQyNTUxOQAAACDu5gXJ3fQrkx20FNGWTRkX1l0KaAyn6CI/XYlv6c0xLw 5 | AAAEAGIVXhatISzJIN0gV8hDf52L74e0lTQDQeTrr06yFYVO7mBcnd9CuTHbQU0ZZNGRfW 6 | XQpoDKfoIj9diW/pzTEvAAAAEGZhNEBsbWFjLWZhNC1kc3kBAgMEBQ== 7 | -----END OPENSSH PRIVATE KEY----- 8 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/etl.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { 2 | [a] == "a" ? loghub.processors.Identity 3 | } 4 | 5 | pipeline[third] { 6 | [a] < [b c] 7 | } 8 | 9 | pipeline[timestamp] { 10 | [reception_time] = [@timestamp] | [@timestamp] = 0 11 | } 12 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/filesbuffer.conf: -------------------------------------------------------------------------------- 1 | input { 2 | loghub.receivers.TimeSerie { 3 | decoder: loghub.decoders.StringCodec, 4 | frequency: 200, 5 | } 6 | } 7 | pipeline[main] { 8 | } 9 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/fire.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { 2 | fire { [a] = 1 ; [b] = 2 * 3 ; [c] = [count] * 3 } > $main 3 | } 4 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/forkforward.conf: -------------------------------------------------------------------------------- 1 | pipeline[mainfork] { loghub.processors.Identity + $forked | [a] = 1} 2 | pipeline[mainforward] { true ? ( > $forked ) | [a] = 2 } 3 | pipeline[forked] { [b] = 3 } 4 | output $mainfork | { loghub.senders.InMemorySender } 5 | output $forked | { loghub.senders.InMemorySender } 6 | output $mainforward | { loghub.senders.InMemorySender } 7 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/includes/.hidden.conf: -------------------------------------------------------------------------------- 1 | Not a valid configuration -------------------------------------------------------------------------------- /loghub-core/src/test/resources/includes/a.conf: -------------------------------------------------------------------------------- 1 | a: true -------------------------------------------------------------------------------- /loghub-core/src/test/resources/includes/b.conf: -------------------------------------------------------------------------------- 1 | b: true 2 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/includes/recurse.conf: -------------------------------------------------------------------------------- 1 | includes: "target/test-classes/includes/?.conf" 2 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/includes/sub.conf: -------------------------------------------------------------------------------- 1 | output $empty | { 2 | loghub.senders.Stdout { encoder: loghub.encoders.Gelf } 3 | } 4 | pipeline[empty] { 5 | } 6 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/loghub.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/loghub.p12 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/map.conf: -------------------------------------------------------------------------------- 1 | pipeline[mapper1] { 2 | [d] @ [a] { 3 | 1: "b", 4 | 2: "c", 5 | } 6 | } 7 | pipeline[mapper2] { 8 | [a] @ [a] { 9 | 1: "b", 10 | 2: "c", 11 | } 12 | } 13 | pipeline[mapper3] { 14 | [a] @ [a] * 2 { 15 | 2: "b", 16 | 4: "c", 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/mapping.csv: -------------------------------------------------------------------------------- 1 | key,value,comment 2 | 1,A,"comment A" 3 | 2,B,"comment B" 4 | 3,C,"comment C" 5 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1, 3 | "b": true 4 | } -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/DSA_2048.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/DSA_2048.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/DSA_4096.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/DSA_4096.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/ED25519.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/ED25519.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/RSA_2048.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/RSA_2048.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/RSA_4096.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/RSA_4096.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/prime192v1.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/prime192v1.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/prime256v1.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/prime256v1.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/secp224r1.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/secp224r1.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/secp384r1.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/secp384r1.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/pkcs8/secp521r1.pk8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-core/src/test/resources/pkcs8/secp521r1.pk8 -------------------------------------------------------------------------------- /loghub-core/src/test/resources/resolv.conf: -------------------------------------------------------------------------------- 1 | nameserver 8.8.8.8 2 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/scanbinary.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { 2 | loghub.processors.ScanBinary { 3 | fieldsLength: [3, 2, 1], 4 | bitsNames: ["a", "b", "c"], 5 | field: "binary" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/script.js: -------------------------------------------------------------------------------- 1 | var configure = function(properties) { 2 | }; 3 | 4 | var transform = function(event) { 5 | event.put("done", true); 6 | }; 7 | 8 | var a = new java.util.HashMap(); 9 | a.put("configure", "configure") 10 | a.put("transform", "transform") 11 | a; 12 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/script.py: -------------------------------------------------------------------------------- 1 | import java.util.HashMap 2 | 3 | def transform(event): 4 | event['done'] = True 5 | 6 | def configure(properties): 7 | pass 8 | 9 | settings = java.util.HashMap() 10 | settings.put("configure", "configure") 11 | settings.put("transform", "transform") 12 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/simple.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { loghub.processors.Identity | loghub.processors.Identity | loghub.processors.Identity } 2 | pipeline[parent] { $main } 3 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/simpleinput.conf: -------------------------------------------------------------------------------- 1 | input { 2 | loghub.receivers.ZMQ { listen: "inproc://listener", decoder: loghub.decoders.StringCodec, topic: "", type: "SUB" } 3 | } | $main 4 | pipeline[main] {loghub.processors.Identity } 5 | output $main | { 6 | loghub.senders.ZMQ { destination: "inproc://sender", encoder: loghub.encoders.StringField { format: "${message}"} , type: "PUB"} 7 | } 8 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/sources.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { 2 | [a] @ [a] %source1 3 | } 4 | 5 | sources: 6 | source1: loghub.sources.FileMap { 7 | mappingFile: "target/test-classes/mapping.csv", 8 | keyName: "key", 9 | valueName: "value" 10 | } 11 | source2: loghub.sources.FileMap { 12 | mappingFile: "src/test/resources/mapping.json", 13 | } 14 | 15 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/sub.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { (loghub.processors.Identity | loghub.processors.Identity) } 2 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/subpipeline.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { 2 | loghub.processors.Identity { 3 | success: { 4 | (java.lang.Integer) [a] 5 | | (java.lang.Integer) [b] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/testclause.conf: -------------------------------------------------------------------------------- 1 | pipeline [main] { 2 | [a] == 1 ? [b] < [a] : [c] < [a] 3 | } 4 | pipeline [subpipe] { 5 | [a] == 1 ? [b] < [a] : [c] < [a] 6 | | [c] == 2 ? $other 7 | } 8 | pipeline [other] { 9 | [d] = 2 10 | } 11 | pipeline [missingpath] { 12 | [a b] == 1 ? [c] = 1 : [c] = 2 13 | } 14 | output $subpipe | { loghub.senders.InMemorySender } 15 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/testlog4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/twopipe.conf: -------------------------------------------------------------------------------- 1 | pipeline[pipeone] { loghub.processors.Identity } | $main 2 | pipeline[main] { } 3 | output $main | { loghub.senders.InMemorySender } 4 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/types.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { 2 | loghub.processors.Identity { 3 | string: "0", 4 | int: 1, 5 | double: 1.0, 6 | boolean: true, 7 | array: [ "0", 1, 1.0, true ], 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /loghub-core/src/test/resources/wrap.conf: -------------------------------------------------------------------------------- 1 | pipeline[main] { 2 | path [a] ( 3 | [b] = "b" 4 | | [c] < [b] 5 | | [#d] = 1 6 | | [timestamp8601] = "1970-01-01T00:00:00+0000" 7 | | loghub.processors.DateParser { 8 | field: "timestamp8601", 9 | patterns: ["yyyy-MM-dd'T'HH:m:ssXXXX",], 10 | destination: [@timestamp], 11 | success: [timestamp8601]- 12 | } 13 | | [ . e] = [c] 14 | | [ "#f" ] = 1 15 | | [ "@timestamp" ] = 2 16 | ) 17 | | path [a] ( loghub.processors.Identity ) 18 | } 19 | output $main | { loghub.senders.InMemorySender } 20 | -------------------------------------------------------------------------------- /loghub-csv/src/main/java/loghub/jackson/CsvHelpers.java: -------------------------------------------------------------------------------- 1 | package loghub.jackson; 2 | 3 | import java.util.Arrays; 4 | import java.util.Locale; 5 | 6 | import com.fasterxml.jackson.dataformat.csv.CsvGenerator; 7 | import com.fasterxml.jackson.dataformat.csv.CsvMapper; 8 | import com.fasterxml.jackson.dataformat.csv.CsvParser; 9 | 10 | public class CsvHelpers { 11 | 12 | private CsvHelpers() { 13 | // Only static usage 14 | } 15 | public static void csvFeatures(CsvMapper mapper, String[] features) { 16 | Arrays.stream(features).forEach(i -> { 17 | CsvParser.Feature feature = CsvParser.Feature.valueOf(i.toUpperCase(Locale.ENGLISH)); 18 | mapper.enable(feature); 19 | }); 20 | } 21 | 22 | public static void csvGeneratorFeatures(CsvMapper mapper, String[] features) { 23 | Arrays.stream(features).forEach(i -> { 24 | CsvGenerator.Feature feature = CsvGenerator.Feature.valueOf(i.toUpperCase(Locale.ENGLISH)); 25 | mapper.enable(feature); 26 | }); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /loghub-espipeline/src/main/resources/META-INF/services/loghub.commands.CommandLineHandler: -------------------------------------------------------------------------------- 1 | loghub.commands.EsPipelineConvert 2 | -------------------------------------------------------------------------------- /loghub-executable/src/main/resources.linux/META-INF/services/loghub.netty.transport.PollerServiceProvider: -------------------------------------------------------------------------------- 1 | loghub.netty.transport.EpollPollerServiceProvider 2 | loghub.netty.transport.IoUringPollerServiceProvider 3 | loghub.netty.transport.NioPollerServiceProvider 4 | loghub.netty.transport.OioPollerServiceProvider 5 | -------------------------------------------------------------------------------- /loghub-executable/src/main/resources.osx/META-INF/services/loghub.netty.transport.PollerServiceProvider: -------------------------------------------------------------------------------- 1 | loghub.netty.transport.KQueuePollerServiceProvider 2 | loghub.netty.transport.NioPollerServiceProvider 3 | loghub.netty.transport.OioPollerServiceProvider 4 | -------------------------------------------------------------------------------- /loghub-geoip/src/test/resources/GeoLite2-City.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-geoip/src/test/resources/GeoLite2-City.mmdb -------------------------------------------------------------------------------- /loghub-geoip/src/test/resources/GeoLite2-Country.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-geoip/src/test/resources/GeoLite2-Country.mmdb -------------------------------------------------------------------------------- /loghub-jolokia/src/main/java/loghub/jolokia/JolokiaDashboardService.java: -------------------------------------------------------------------------------- 1 | package loghub.jolokia; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import io.netty.channel.SimpleChannelInboundHandler; 7 | import io.netty.handler.codec.http.FullHttpRequest; 8 | import loghub.netty.DashboardService; 9 | 10 | public class JolokiaDashboardService implements DashboardService { 11 | 12 | @Override 13 | public String getName() { 14 | return "jolokia"; 15 | } 16 | 17 | @Override 18 | public List> getHandlers(Map properties) { 19 | JolokiaEndpoint.Builder builder = JolokiaEndpoint.getBuilder(); 20 | if (properties.containsKey("policyLocation")) { 21 | builder.setPolicyLocation(properties.get("policyLocation").toString()); 22 | } 23 | JolokiaEndpoint ps = builder.build(); 24 | return List.of(ps); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /loghub-jolokia/src/main/java/loghub/netty/http/JolokiaService.java: -------------------------------------------------------------------------------- 1 | package loghub.netty.http; 2 | 3 | import java.util.Map; 4 | 5 | import io.netty.channel.SimpleChannelInboundHandler; 6 | import io.netty.handler.codec.http.FullHttpRequest; 7 | import loghub.jolokia.JolokiaEndpoint; 8 | 9 | /** 10 | * A compatibility class, kept for pre-service era. 11 | * @deprecated 12 | */ 13 | @Deprecated 14 | public class JolokiaService { 15 | 16 | // Kept for compatibility 17 | public static SimpleChannelInboundHandler of(Map properties) { 18 | JolokiaEndpoint.Builder builder = JolokiaEndpoint.getBuilder(); 19 | if (properties.containsKey("policyLocation")) { 20 | builder.setPolicyLocation(properties.get("policyLocation").toString()); 21 | } 22 | return builder.build(); 23 | } 24 | 25 | private JolokiaService() { 26 | // Kept empty on purpose 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /loghub-jolokia/src/main/resources/META-INF/services/loghub.netty.DashboardService: -------------------------------------------------------------------------------- 1 | loghub.jolokia.JolokiaDashboardService 2 | -------------------------------------------------------------------------------- /loghub-jolokia/src/main/resources/jolokia-access.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | version 5 | list 6 | search 7 | read 8 | notification 9 | 10 | 11 | -------------------------------------------------------------------------------- /loghub-jolokia/src/main/resources/propertiestype.properties: -------------------------------------------------------------------------------- 1 | http.jolokiaPolicyLocation=STRING 2 | http.jolokia.policyLocation=STRING 3 | -------------------------------------------------------------------------------- /loghub-kaitai/src/test/java/loghub/CaptureStream.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.util.stream.Stream; 7 | 8 | import io.kaitai.struct.ByteBufferKaitaiStream; 9 | import kaitai.EthernetFrame; 10 | import kaitai.Ipv4Packet; 11 | import kaitai.Pcap; 12 | import kaitai.UdpDatagram; 13 | 14 | public class CaptureStream { 15 | 16 | public static Stream readUdpStream(InputStream in) throws IOException { 17 | try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { 18 | out.write(in.readAllBytes()); 19 | ByteBufferKaitaiStream pcapcontent = new ByteBufferKaitaiStream(out.toByteArray()); 20 | Pcap pcap = new Pcap(pcapcontent); 21 | return pcap.packets().stream() 22 | .map(p -> (EthernetFrame)p.body()) 23 | .map(p -> (Ipv4Packet)p.body()) 24 | .map(Ipv4Packet::body) 25 | .map(p -> (UdpDatagram)p.body()) 26 | .map(UdpDatagram::body); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /loghub-netflow/src/main/java/loghub/netflow/IpfixPacket.java: -------------------------------------------------------------------------------- 1 | package loghub.netflow; 2 | 3 | import java.io.IOException; 4 | import java.net.InetAddress; 5 | 6 | import io.netty.buffer.ByteBuf; 7 | 8 | public class IpfixPacket extends TemplateBasedPacket implements NetflowPacket { 9 | 10 | public IpfixPacket(InetAddress remoteAddr, ByteBuf bbuf, NetflowRegistry registry) throws IOException { 11 | super(remoteAddr, bbuf, registry); 12 | } 13 | 14 | @Override 15 | protected HeaderInfo readHeader(ByteBuf bbuf) { 16 | TemplateBasedPacket.HeaderInfo hi = new TemplateBasedPacket.HeaderInfo(); 17 | hi.length = Short.toUnsignedInt(bbuf.readShort()); 18 | return hi; 19 | } 20 | 21 | @Override 22 | public int getVersion() { 23 | return 10; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /loghub-netflow/src/main/java/loghub/netflow/Netflow9Packet.java: -------------------------------------------------------------------------------- 1 | package loghub.netflow; 2 | 3 | import java.io.IOException; 4 | import java.net.InetAddress; 5 | import java.time.Duration; 6 | import java.time.temporal.ChronoUnit; 7 | 8 | import io.netty.buffer.ByteBuf; 9 | import lombok.Getter; 10 | 11 | @Getter 12 | public class Netflow9Packet extends TemplateBasedPacket implements NetflowPacket { 13 | 14 | private Duration sysUpTime; 15 | 16 | public Netflow9Packet(InetAddress remoteAddr, ByteBuf bbuf, NetflowRegistry registry) throws IOException { 17 | super(remoteAddr, bbuf, registry); 18 | } 19 | 20 | @Override 21 | public int getVersion() { 22 | return 9; 23 | } 24 | 25 | @Override 26 | protected HeaderInfo readHeader(ByteBuf bbuf) { 27 | TemplateBasedPacket.HeaderInfo hi = new TemplateBasedPacket.HeaderInfo(); 28 | hi.count = Short.toUnsignedInt(bbuf.readShort()); 29 | hi.sysUpTime = Integer.toUnsignedLong(bbuf.readInt()); 30 | sysUpTime = Duration.of(hi.sysUpTime, ChronoUnit.MILLIS); 31 | return hi; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /loghub-netflow/src/main/java/loghub/netflow/NetflowPacket.java: -------------------------------------------------------------------------------- 1 | package loghub.netflow; 2 | 3 | import java.time.Instant; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public interface NetflowPacket { 8 | 9 | String EXCEPTION_KEY = "__exception"; 10 | 11 | int getVersion(); 12 | Instant getExportTime(); 13 | long getSequenceNumber(); 14 | Object getId(); 15 | List> getRecords(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_barracuda_data256.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_barracuda_data256.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_barracuda_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_barracuda_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_mikrotik_data258.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_mikrotik_data258.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_mikrotik_data259.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_mikrotik_data259.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_mikrotik_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_mikrotik_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_netscaler_data.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_netscaler_data.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_netscaler_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_netscaler_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_openbsd_pflow_data.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_openbsd_pflow_data.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_openbsd_pflow_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_openbsd_pflow_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_vmware_vds_data264.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_vmware_vds_data264.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_vmware_vds_data266.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_vmware_vds_data266.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_vmware_vds_data266_267.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_vmware_vds_data266_267.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/ipfix_test_vmware_vds_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/ipfix_test_vmware_vds_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow5.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow5.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow5_test_invalid01.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow5_test_invalid01.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow5_test_invalid02.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow5_test_invalid02.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow5_test_juniper_mx80.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow5_test_juniper_mx80.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow5_test_microtik.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow5_test_microtik.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_cisco_asr1001x_tpl259.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_cisco_asr1001x_tpl259.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_0length_fields_tpl_data.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_0length_fields_tpl_data.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_1941K9.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_1941K9.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_1_data.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_1_data.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_1_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_1_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_2_data.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_2_data.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_2_tpl_26x.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_2_tpl_26x.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_2_tpl_27x.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asa_2_tpl_27x.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_data256.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_data256.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_data260.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_data260.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_opttpl256.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_opttpl256.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_opttpl257.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_opttpl257.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_opttpl334.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_opttpl334.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_tpl260.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_tpl260.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_tpl266.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_asr9k_tpl266.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_nbar_data262.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_nbar_data262.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_nbar_opttpl260.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_nbar_opttpl260.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_nbar_tpl262.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_nbar_tpl262.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_wlc_8510_tpl_262.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_wlc_8510_tpl_262.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_wlc_data261.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_wlc_data261.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_cisco_wlc_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_cisco_wlc_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_fortigate_fortios_521_data256.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_fortigate_fortios_521_data256.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_fortigate_fortios_521_data257.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_fortigate_fortios_521_data257.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_fortigate_fortios_521_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_fortigate_fortios_521_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_invalid01.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_invalid01.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_juniper_srx_tplopt.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_juniper_srx_tplopt.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_macaddr_data.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_macaddr_data.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_macaddr_tpl.dat: -------------------------------------------------------------------------------- 1 | uHVЀaD  8P 8P*) -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_nprobe_data.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_nprobe_data.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_nprobe_dpi.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_nprobe_dpi.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_nprobe_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_nprobe_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_softflowd_tpl_data.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_softflowd_tpl_data.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_streamcore_tpl_data256.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_streamcore_tpl_data256.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_streamcore_tpl_data260.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_streamcore_tpl_data260.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_ubnt_edgerouter_data1024.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_ubnt_edgerouter_data1024.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_ubnt_edgerouter_data1025.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_ubnt_edgerouter_data1025.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_ubnt_edgerouter_tpl.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_ubnt_edgerouter_tpl.dat -------------------------------------------------------------------------------- /loghub-netflow/src/test/resources/packets/netflow9_test_valid01.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-netflow/src/test/resources/packets/netflow9_test_valid01.dat -------------------------------------------------------------------------------- /loghub-prometheus/src/main/resources/META-INF/services/loghub.netty.DashboardService: -------------------------------------------------------------------------------- 1 | loghub.prometheus.PrometheusDashboardService 2 | -------------------------------------------------------------------------------- /loghub-prometheus/src/main/resources/propertiestype.properties: -------------------------------------------------------------------------------- 1 | http.prometheus.openTelemetry.endpoint: STRING 2 | http.prometheus.openTelemetry.headers: MAP 3 | http.prometheus.openTelemetry.interval: INTEGER 4 | http.prometheus.openTelemetry.protocol: STRING 5 | http.prometheus.openTelemetry.resourceAttributes: MAP 6 | http.prometheus.openTelemetry.serviceInstanceId: STRING 7 | http.prometheus.openTelemetry.serviceName: STRING 8 | http.prometheus.openTelemetry.serviceNamespace: STRING 9 | http.prometheus.openTelemetry.serviceVersion: STRING 10 | http.prometheus.openTelemetry.timeoutSeconds: INTEGER 11 | http.prometheus.withExporter: BOOLEAN 12 | http.prometheus.withJvmMetrics: BOOLEAN 13 | http.prometheus.withOpenTelemetry: BOOLEAN 14 | -------------------------------------------------------------------------------- /loghub-protobuf/src/main/resources/prometheus.binpb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-protobuf/src/main/resources/prometheus.binpb -------------------------------------------------------------------------------- /loghub-protobuf/src/test/java/loghub/ProtobufTestUtils.java: -------------------------------------------------------------------------------- 1 | package loghub; 2 | 3 | import prometheus.Remote; 4 | import prometheus.Types; 5 | 6 | public class ProtobufTestUtils { 7 | 8 | public static Remote.WriteRequest getWriteRequest() { 9 | return Remote.WriteRequest.newBuilder().addTimeseries( 10 | Types.TimeSeries.newBuilder() 11 | .addLabels(Types.Label.newBuilder().setName("__name__").setValue("test_event")) 12 | .addLabels(Types.Label.newBuilder().setName("label").setValue("value") 13 | ).addSamples(Types.Sample.newBuilder().setValue(1.0).setTimestamp(1)) 14 | ).build(); 15 | } 16 | 17 | private ProtobufTestUtils() { 18 | // Only static usage 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/DataSource.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public class DataSource { 7 | public enum SourceType { 8 | UNKOWN("Unknown"), 9 | IF_INDEX("ifIndex"), 10 | SMON_VLAN_DATA_SOURCE("smonVlanDataSource"), 11 | ENT_PHYSICAL_ENTRY("entPhysicalEntry"); 12 | private final String display; 13 | 14 | SourceType(String display) { 15 | this.display = display; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return display; 21 | } 22 | } 23 | private final SourceType sourceType; 24 | private final int index; 25 | public DataSource(int value) { 26 | switch (value >> 24) { 27 | case 0: 28 | sourceType = SourceType.IF_INDEX; 29 | break; 30 | case 1: 31 | sourceType = SourceType.SMON_VLAN_DATA_SOURCE; 32 | break; 33 | case 2: 34 | sourceType = SourceType.ENT_PHYSICAL_ENTRY; 35 | break; 36 | default: 37 | sourceType = SourceType.UNKOWN; 38 | } 39 | index = value & ((2 << 23) - 1); 40 | } 41 | @Override 42 | public String toString() { 43 | return sourceType + "/" + index; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/HeaderProtocol.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow; 2 | 3 | public enum HeaderProtocol { 4 | UNKNOWN, 5 | ETHERNET_SO88023, 6 | ISO88024_TOKENBUS, 7 | ISO88025_TOKENRING, 8 | FDDI, 9 | FRAME_RELAY, 10 | X25, 11 | PPP, 12 | SMDS, 13 | AAL5, 14 | AAL5_IP, /* e.g. Cisco AAL5 mux */ 15 | IPv4, 16 | IPv6, 17 | MPLS, 18 | POS /* RFC 1662, 2615 */; 19 | 20 | public static HeaderProtocol parse(int protocol) { 21 | switch (protocol) { 22 | case 1: return ETHERNET_SO88023; 23 | case 2: return ISO88024_TOKENBUS; 24 | case 3: return ISO88025_TOKENRING; 25 | case 4: return FDDI; 26 | case 5: return FRAME_RELAY; 27 | case 6: return X25; 28 | case 7: return PPP; 29 | case 8: return SMDS; 30 | case 9: return AAL5; 31 | case 10: return AAL5_IP; 32 | case 11: return IPv4; 33 | case 12: return IPv6; 34 | case 13: return MPLS; 35 | case 14: return POS; 36 | default: 37 | return UNKNOWN; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/IfDirection.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow; 2 | 3 | public enum IfDirection { 4 | UNKNOWN, 5 | FULL_DUPLEX, 6 | HALF_DUPLEX, 7 | IN, 8 | OUT; 9 | public static IfDirection parse(int ifDirection) { 10 | switch (ifDirection) { 11 | case 1: return FULL_DUPLEX; 12 | case 2: return HALF_DUPLEX; 13 | case 3: return IN; 14 | case 4: return OUT; 15 | default: 16 | return UNKNOWN; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/SFlowDatagram.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow; 2 | 3 | import java.net.InetAddress; 4 | import java.time.Duration; 5 | import java.util.List; 6 | 7 | import com.fasterxml.jackson.annotation.JsonIgnore; 8 | 9 | import loghub.sflow.structs.Struct; 10 | import lombok.Builder; 11 | import lombok.Data; 12 | import lombok.Getter; 13 | 14 | @Data 15 | @Builder 16 | @Getter 17 | public class SFlowDatagram { 18 | private final int version; 19 | private final InetAddress agent_address; 20 | private final long sub_agent_id; 21 | private final long sequence_number; 22 | private final Duration uptime; 23 | @JsonIgnore 24 | private final List samples; 25 | } 26 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/StructureClass.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow; 2 | 3 | public enum StructureClass { 4 | SAMPLE_DATA, 5 | FLOW_DATA, 6 | COUNTER_DATA; 7 | 8 | public static StructureClass resolve(String name) { 9 | switch (name) { 10 | case "sample_data": 11 | return SAMPLE_DATA; 12 | case "flow_data": 13 | return FLOW_DATA; 14 | case "counter_data": 15 | return COUNTER_DATA; 16 | default: 17 | throw new IllegalArgumentException("Invalid struct name " + name); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/structs/DynamicStruct.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow.structs; 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | 6 | import com.fasterxml.jackson.core.JsonGenerator; 7 | import com.fasterxml.jackson.databind.JsonSerializer; 8 | import com.fasterxml.jackson.databind.SerializerProvider; 9 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 10 | 11 | import io.netty.buffer.ByteBuf; 12 | import loghub.sflow.SflowParser; 13 | 14 | @JsonSerialize(using = DynamicStruct.DynamicStructSerializer.class) 15 | public class DynamicStruct extends Struct { 16 | 17 | static public class DynamicStructSerializer extends JsonSerializer { 18 | @Override 19 | public void serialize(DynamicStruct value, JsonGenerator gen, SerializerProvider serializers) 20 | throws IOException { 21 | gen.writeObject(value.data); 22 | } 23 | } 24 | 25 | private final Map data; 26 | 27 | public DynamicStruct(String name, SflowParser parser, ByteBuf buf) throws IOException { 28 | super(parser.getByName(name)); 29 | buf = extractData(buf); 30 | data = parser.readDynamicStructData(getFormat(), buf); 31 | } 32 | 33 | @Override 34 | public String getName() { 35 | return getFormat().getName(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/structs/ExtendedRouter.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow.structs; 2 | 3 | import java.io.IOException; 4 | import java.net.InetAddress; 5 | 6 | import io.netty.buffer.ByteBuf; 7 | import loghub.sflow.SflowParser; 8 | import lombok.Getter; 9 | import lombok.ToString; 10 | 11 | @ToString 12 | @Getter 13 | public class ExtendedRouter extends Struct { 14 | 15 | public static final String NAME = "extended_router"; 16 | 17 | private final InetAddress nexthop; 18 | private final int src_mask_len; 19 | private final int dst_mask_len; 20 | 21 | public ExtendedRouter(SflowParser parser, ByteBuf buffer) throws IOException { 22 | super(parser.getByName(NAME)); 23 | buffer = extractData(buffer); 24 | nexthop = parser.readIpAddress(buffer); 25 | src_mask_len = Math.toIntExact(buffer.readUnsignedInt()); 26 | dst_mask_len = Math.toIntExact(buffer.readUnsignedInt()); 27 | } 28 | 29 | @Override 30 | public String getName() { 31 | return NAME; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/structs/ExtendedUser.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow.structs; 2 | 3 | import java.nio.charset.Charset; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import loghub.sflow.SflowParser; 7 | import lombok.Getter; 8 | 9 | @Getter 10 | public class ExtendedUser extends Struct { 11 | 12 | public static final String NAME = "extended_user"; 13 | 14 | private final String src_user; 15 | private final String dst_user; 16 | 17 | public ExtendedUser(SflowParser parser, ByteBuf buf) { 18 | super(parser.getByName(NAME)); 19 | buf = extractData(buf); 20 | Charset src_user_charset = parser.readCharset(buf); 21 | int src_user_len = Math.toIntExact(buf.readUnsignedInt()); 22 | byte[] src_user_bytes = new byte[src_user_len]; 23 | buf.readBytes(src_user_bytes); 24 | src_user = new String(src_user_bytes, src_user_charset); 25 | Charset dst_user_charset = parser.readCharset(buf); 26 | int dst_user_len = Math.toIntExact(buf.readUnsignedInt()); 27 | byte[] dst_user_bytes = new byte[dst_user_len]; 28 | buf.readBytes(dst_user_bytes); 29 | dst_user = new String(dst_user_bytes, dst_user_charset); 30 | } 31 | 32 | @Override 33 | public String getName() { 34 | return NAME; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/structs/OpaqueStruct.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow.structs; 2 | 3 | import loghub.sflow.DataFormat; 4 | import io.netty.buffer.ByteBuf; 5 | import lombok.Getter; 6 | 7 | @Getter 8 | public class OpaqueStruct extends Struct { 9 | 10 | private final ByteBuf data; 11 | public OpaqueStruct(DataFormat si, ByteBuf data) { 12 | super(si); 13 | this.data = extractData(data).copy(); 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return String.format("%s(%s)", getName(), getFormat()); 19 | } 20 | 21 | @Override 22 | public String getName() { 23 | return "UnknownStruct(" + getFormat() + ")"; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/structs/SampledHeader.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow.structs; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import loghub.sflow.HeaderProtocol; 5 | import loghub.sflow.SflowParser; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | public class SampledHeader extends Struct { 10 | 11 | public static final String NAME = "sampled_header"; 12 | 13 | private final HeaderProtocol protocol; 14 | private final long frame_length; 15 | private final long stripped; 16 | private final byte[] header; 17 | 18 | public SampledHeader(SflowParser parser, ByteBuf buf) { 19 | super(parser.getByName(NAME)); 20 | ByteBuf buffer = extractData(buf); 21 | protocol = HeaderProtocol.parse(buffer.readInt()); 22 | frame_length = buffer.readUnsignedInt(); 23 | stripped = buffer.readUnsignedInt(); 24 | int length = Math.toIntExact(buffer.readUnsignedInt()); 25 | header = new byte[length]; 26 | buffer.readBytes(header); 27 | } 28 | 29 | @Override 30 | public String getName() { 31 | return NAME; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "SampledHeader(" + "protocol=" + protocol + ", frame_length=" + frame_length + ", stripped=" + stripped + ", header=byte[" + header.length + "])"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/sflow/structs/Struct.java: -------------------------------------------------------------------------------- 1 | package loghub.sflow.structs; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import loghub.sflow.DataFormat; 7 | import lombok.Getter; 8 | 9 | @Getter 10 | public abstract class Struct { 11 | 12 | @JsonIgnore 13 | private final DataFormat format; 14 | 15 | protected Struct(DataFormat format) { 16 | this.format = format; 17 | } 18 | 19 | protected ByteBuf extractData(ByteBuf buffer) { 20 | int length = Math.toIntExact(buffer.readUnsignedInt()); 21 | assert length != 0 && length <= buffer.readableBytes() : length; 22 | int readPosition = buffer.readerIndex(); 23 | buffer.skipBytes(length); 24 | return buffer.slice(readPosition, length); 25 | } 26 | 27 | @JsonIgnore 28 | public abstract String getName(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/xdr/EnumTypeSpecifier.java: -------------------------------------------------------------------------------- 1 | package loghub.xdr; 2 | 3 | import java.util.Map; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | 7 | public class EnumTypeSpecifier extends TypeSpecifier> { 8 | 9 | private final Map enumEntries; 10 | 11 | EnumTypeSpecifier(String name, Map enumEntries) { 12 | super(name); 13 | this.enumEntries = Map.copyOf(enumEntries); 14 | } 15 | 16 | public String resolve(Number n) { 17 | return enumEntries.get(n); 18 | } 19 | 20 | @Override 21 | public Map getType() { 22 | return enumEntries; 23 | } 24 | 25 | @SuppressWarnings("unchecked") 26 | @Override 27 | public String read(ByteBuf b) { 28 | return enumEntries.get(b.readInt()); 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "enum%s" + enumEntries; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/xdr/FixedOpaqueTypeSpecifier.java: -------------------------------------------------------------------------------- 1 | package loghub.xdr; 2 | 3 | import java.io.IOException; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | public class FixedOpaqueTypeSpecifier extends TypeSpecifier { 10 | 11 | private final int size; 12 | 13 | public FixedOpaqueTypeSpecifier(int size) { 14 | super(NativeType.BYTE_ARRAY.typeName); 15 | this.size = size; 16 | } 17 | 18 | @Override 19 | public NativeType getType() { 20 | return null; 21 | } 22 | 23 | @Override 24 | public O read(ByteBuf b) throws IOException { 25 | byte[] data = new byte[size]; 26 | b.readBytes(data); 27 | return (O) data; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/xdr/FixedStringTypeSpecifier.java: -------------------------------------------------------------------------------- 1 | package loghub.xdr; 2 | 3 | import java.io.IOException; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | public class FixedStringTypeSpecifier extends TypeSpecifier { 10 | 11 | private final int size; 12 | 13 | public FixedStringTypeSpecifier(int size) { 14 | super(NativeType.BYTE_ARRAY.typeName); 15 | this.size = size; 16 | } 17 | 18 | @Override 19 | public NativeType getType() { 20 | return null; 21 | } 22 | 23 | @Override 24 | public O read(ByteBuf b) throws IOException { 25 | byte[] data = new byte[size]; 26 | b.readBytes(data); 27 | return (O) data; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/xdr/IndirectTypeSpecifier.java: -------------------------------------------------------------------------------- 1 | package loghub.xdr; 2 | 3 | import java.io.IOException; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | 7 | public class IndirectTypeSpecifier extends TypeSpecifier> { 8 | 9 | private final TypeSpecifier type; 10 | 11 | protected IndirectTypeSpecifier(String name, TypeSpecifier type) { 12 | super(name); 13 | this.type = type; 14 | } 15 | 16 | @Override 17 | public TypeSpecifier getType() { 18 | return type; 19 | } 20 | 21 | @Override 22 | public O read(ByteBuf b) throws IOException { 23 | return type.read(b); 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return '(' + getName() + "->" + type.toString() + ')'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/xdr/InvalidTypeSpecifier.java: -------------------------------------------------------------------------------- 1 | package loghub.xdr; 2 | 3 | import java.io.IOException; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | 7 | public class InvalidTypeSpecifier extends TypeSpecifier { 8 | 9 | String typeName; 10 | protected InvalidTypeSpecifier(String name, String typeName) { 11 | super(name); 12 | this.typeName = typeName; 13 | } 14 | 15 | @Override 16 | public String getType() { 17 | return "InvalidType/" + getName(); 18 | } 19 | 20 | @Override 21 | public O read(ByteBuf b) throws IOException { 22 | throw new IOException("Unspecified type '" + getName() + "', not readable for declaration '" + typeName + "'"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/xdr/NativeTypeSpecifier.java: -------------------------------------------------------------------------------- 1 | package loghub.xdr; 2 | 3 | import java.io.IOException; 4 | import java.util.Objects; 5 | 6 | import io.netty.buffer.ByteBuf; 7 | import lombok.Getter; 8 | 9 | @Getter 10 | public class NativeTypeSpecifier extends TypeSpecifier { 11 | 12 | private final NativeType type; 13 | int size; 14 | 15 | protected NativeTypeSpecifier(NativeType type, int size) { 16 | super(type.typeName); 17 | this.type = type; 18 | this.size = size; 19 | } 20 | 21 | @Override 22 | public boolean equals(Object o) { 23 | if (!(o instanceof NativeTypeSpecifier)) 24 | return false; 25 | NativeTypeSpecifier that = (NativeTypeSpecifier) o; 26 | return type == that.type && size == that.size; 27 | } 28 | 29 | @Override 30 | public int hashCode() { 31 | return Objects.hash(type, size); 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return type.getString(size); 37 | } 38 | 39 | @SuppressWarnings("unchecked") 40 | @Override 41 | public O read(ByteBuf b) throws IOException { 42 | return (O) type.reader.read(b); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/xdr/ReadType.java: -------------------------------------------------------------------------------- 1 | package loghub.xdr; 2 | 3 | import java.io.IOException; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | 7 | public interface ReadType { 8 | T read(ByteBuf buf) throws IOException; 9 | } 10 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/java/loghub/xdr/TypeSpecifier.java: -------------------------------------------------------------------------------- 1 | package loghub.xdr; 2 | 3 | import java.io.IOException; 4 | 5 | import io.netty.buffer.ByteBuf; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | public abstract class TypeSpecifier { 10 | 11 | private final String name; 12 | protected TypeSpecifier(String name) { 13 | this.name = name; 14 | } 15 | public abstract T getType(); 16 | public abstract O read(ByteBuf b) throws IOException; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/resources/xdr/bv-sflow.xdr: -------------------------------------------------------------------------------- 1 | /* Percentage expressed in hundredths of a percent 2 | (e.g., 100 = 1%). If a percentage value is unknown then 3 | use the value -1. */ 4 | 5 | typedef int percentage; 6 | 7 | The following structures are used to report peak buffer usage: 8 | 9 | /* Device level buffer utilization */ 10 | /* buffers_used metrics represent peak since last export */ 11 | /* opaque = counter_data; enterprise = 4413; format = 1 */ 12 | struct bst_device_buffers { 13 | percentage uc_pc; /* unicast buffers percentage utilization */ 14 | percentage mc_pc; /* multicast buffers percentage utilization */ 15 | } 16 | 17 | /* Port level buffer utilization */ 18 | /* buffers_used metrics represent peak buffers used since last export */ 19 | /* opaque = counter_data; enterprise = 4413; format = 2 */ 20 | struct bst_port_buffers { 21 | percentage ingress_uc_pc; /* ingress unicast buffers utilization */ 22 | percentage ingress_mc_pc; /* ingress multicast buffers utilization */ 23 | percentage egress_uc_pc; /* egress unicast buffers utilization */ 24 | percentage egress_mc_pc; /* egress multicast buffers utilization */ 25 | percentage egress_queue_uc_pc<8>; /* per egress queue unicast buffers utilization */ 26 | percentage egress_queue_mc_pc<8>; /* per egress queue multicast buffers utilization*/ 27 | } 28 | 29 | /* Selected egress queue */ 30 | /* opaque = flow_data; enterprise = 4413; format = 1 */ 31 | struct extended_bst_egress_queue { 32 | unsigned int queue; /* eqress queue number selected for sampled packet */ 33 | } 34 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/resources/xdr/sflow_broadcom_tables.xdr: -------------------------------------------------------------------------------- 1 | /* Table utilizations */ 2 | /* utilization of ASIC hardware tables */ 3 | /* opaque = counter_data; enterprise = 4413; format = 3 */ 4 | struct hw_tables { 5 | unsigned int host_entries; 6 | unsigned int host_entries_max; 7 | unsigned int ipv4_entries; 8 | unsigned int ipv4_entries_max; 9 | unsigned int ipv6_entries; 10 | unsigned int ipv6_entries_max; 11 | unsigned int ipv4_ipv6_entries; 12 | unsigned int ipv6_ipv6_entries_max; 13 | unsigned int long_ipv6_entries; 14 | unsigned int long_ipv6_entries_max; 15 | unsigned int total_routes; 16 | unsigned int total_routes_max; 17 | unsigned int ecmp_nexthops; 18 | unsigned int ecmp_nexthops_max; 19 | unsigned int mac_entries; 20 | unsigned int mac_entries_max; 21 | unsigned int ipv4_neighbors; 22 | unsigned int ipv6_neighbors; 23 | unsigned int ipv4_routes; 24 | unsigned int ipv6_routes; 25 | unsigned int acl_ingress_entries; 26 | unsigned int acl_ingress_entries_max; 27 | unsigned int acl_ingress_counters; 28 | unsigned int acl_ingress_counters_max; 29 | unsigned int acl_ingress_meters; 30 | unsigned int acl_ingress_meters_max; 31 | unsigned int acl_ingress_slices; 32 | unsigned int acl_ingress_slices_max; 33 | unsigned int acl_egress_entries; 34 | unsigned int acl_egress_entries_max; 35 | unsigned int acl_egress_counters; 36 | unsigned int acl_egress_counters_max; 37 | unsigned int acl_egress_meters; 38 | unsigned int acl_egress_meters_max; 39 | unsigned int acl_egress_slices; 40 | unsigned int acl_egress_slices_max; 41 | } 42 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/resources/xdr/sflow_lag.xdr: -------------------------------------------------------------------------------- 1 | /* LAG Port Statistics - see IEEE8023-LAG-MIB */ 2 | /* opaque = counter_data; enterprise = 0; format = 7 */ 3 | 4 | struct lag_port_stats { 5 | mac dot3adAggPortActorSystemID; 6 | mac dot3adAggPortPartnerOperSystemID; 7 | unsigned int dot3adAggPortAttachedAggID; 8 | opaque dot3adAggPortState[4]; /* 9 | Bytes are assigned in following order: 10 | byte 0, value dot3adAggPortActorAdminState 11 | byte 1, value dot3adAggPortActorOperState 12 | byte 2, value dot3adAggPortPartnerAdminState 13 | byte 3, value dot3adAggPortPartnerOperState 14 | */ 15 | unsigned int dot3adAggPortStatsLACPDUsRx; 16 | unsigned int dot3adAggPortStatsMarkerPDUsRx; 17 | unsigned int dot3adAggPortStatsMarkerResponsePDUsRx; 18 | unsigned int dot3adAggPortStatsUnknownRx; 19 | unsigned int dot3adAggPortStatsIllegalRx; 20 | unsigned int dot3adAggPortStatsLACPDUsTx; 21 | unsigned int dot3adAggPortStatsMarkerPDUsTx; 22 | unsigned int dot3adAggPortStatsMarkerResponsePDUsTx; 23 | } 24 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/resources/xdr/sflow_openflow.xdr: -------------------------------------------------------------------------------- 1 | /* OpenFlow port */ 2 | /* opaque = counter_data; enterprise = 0; format = 1004 */ 3 | struct of_port { 4 | unsigned hyper datapath_id; 5 | unsigned int port_no; 6 | } 7 | 8 | /* Port name */ 9 | /* opaque = counter_data; enterprise = 0; format = 1005 */ 10 | struct port_name { 11 | string name<255>; 12 | } 13 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/resources/xdr/sflow_optics.xdr: -------------------------------------------------------------------------------- 1 | struct lane { 2 | unsigned int index; /* 1-based index of lane within module, 0=unknown */ 3 | unsigned int tx_bias_current; /* microamps */ 4 | unsigned int tx_power; /* microwatts */ 5 | unsigned int tx_power_min; /* microwatts */ 6 | unsigned int tx_power_max; /* microwatts */ 7 | unsigned int tx_wavelength; /* nanometers */ 8 | unsigned int rx_power; /* microwatts */ 9 | unsigned int rx_power_min; /* microwatts */ 10 | unsigned int rx_power_max; /* microwatts */ 11 | unsigned int rx_wavelength; /* nanometers */ 12 | } 13 | 14 | /* Optical SFP / QSFP metrics */ 15 | /* opaque = counter_data; enterprise=0; format=10 */ 16 | struct sfp { 17 | unsigned int module_id; 18 | unsigned int module_num_lanes; /* total number of lanes in module */ 19 | unsigned int module_supply_voltage; /* millivolts */ 20 | int module_temperature; /* thousandths of a degree Celsius */ 21 | lane<> lanes; 22 | } 23 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/resources/xdr/sflow_transit.xdr: -------------------------------------------------------------------------------- 1 | /* Delay for sampled packet traversing switch */ 2 | /* opaque = flow_data; enterprise = 0; format = 1039 */ 3 | struct extended_transit { 4 | unsigned int delay; /* transit delay in nanoseconds 5 | 0xffffffff indicates value >= 0xffffffff */ 6 | } 7 | 8 | /* Queue depth for sampled packet traversing switch */ 9 | /* extended_egress_queue structure must be included */ 10 | /* opaque = flow_data; enterprise = 0; format = 1040 */ 11 | struct extended_queue { 12 | unsigned int depth; /* queue depth in bytes */ 13 | } 14 | -------------------------------------------------------------------------------- /loghub-sflow/src/main/resources/xdr/sflow_tunnels.xdr: -------------------------------------------------------------------------------- 1 | /* opaque = flow_data; enterprise = 0; format = 1021 */ 2 | struct extended_L2_tunnel_egress { 3 | sampled_ethernet header; 4 | } 5 | 6 | /* opaque = flow_data; enterprise = 0; format = 1022 */ 7 | struct extended_L2_tunnel_ingress { 8 | sampled_ethernet header; 9 | } 10 | 11 | /* opaque = flow_data; enterprise = 0; format = 1023 */ 12 | struct extended_ipv4_tunnel_egress { 13 | sampled_ipv4 header; 14 | } 15 | 16 | /* opaque = flow_data; enterprise = 0; format = 1024 */ 17 | struct extended_ipv4_tunnel_ingress { 18 | sampled_ipv4 header; 19 | } 20 | 21 | /* opaque = flow_data; enterprise = 0; format = 1025 */ 22 | struct extended_ipv6_tunnel_egress { 23 | sampled_ipv6 header; 24 | } 25 | 26 | /* opaque = flow_data; enterprise = 0; format = 1026 */ 27 | struct extended_ipv6_tunnel_ingress { 28 | sampled_ipv6 header; 29 | } 30 | 31 | /* opaque = flow_data; enterprise = 0; format = 1027 */ 32 | struct extended_decapsulate_egress { 33 | unsigned int inner_header_offset; 34 | } 35 | 36 | /* opaque = flow_data; enterprise = 0; format = 1028 */ 37 | struct extended_decapsulate_ingress { 38 | unsigned int inner_header_offset; 39 | } 40 | 41 | /* opaque_flow_data; enterprise = 0; format = 1029 */ 42 | struct extended_vni_egress { 43 | unsigned int vni; 44 | } 45 | 46 | /* opaque_flow_data; enterprise = 0; format = 1030 */ 47 | struct extended_vni_ingress { 48 | unsigned int vni; 49 | } 50 | -------------------------------------------------------------------------------- /loghub-sflow/src/test/resources/sflow.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbacchella/LogHub/6edb11eb9a5b669c14819b5726d677d8de6d0d13/loghub-sflow/src/test/resources/sflow.pcap -------------------------------------------------------------------------------- /loghub-snmp/src/main/resources/propertiestype.properties: -------------------------------------------------------------------------------- 1 | mibdirs=ARRAY 2 | -------------------------------------------------------------------------------- /lombok.config: -------------------------------------------------------------------------------- 1 | config.stopBubbling = true 2 | lombok.addLombokGeneratedAnnotation = true 3 | --------------------------------------------------------------------------------