Beispiel #1
0
        public ElasticSearchAppender(IElasticClientFactory clientFactory, LogEventSmartFormatter indexName,
                                     LogEventSmartFormatter indexType, IIndexingTimer timer, ITolerateCallsFactory tolerateCallsFactory,
                                     ILogBulkSet bulk, ILogEventConverterFactory logEventConverterFactory, ElasticAppenderFilters elasticFilters,
                                     IFileAccessor fileAccessor, IExternalEventWriter eventWriter)
        {
            _logEventConverterFactory = logEventConverterFactory;
            _elasticClientFactory     = clientFactory;
            IndexName             = indexName;
            IndexType             = indexType;
            _timer                = timer;
            _timer.Elapsed       += (o, e) => DoIndexNow();
            _tolerateCallsFactory = tolerateCallsFactory;
            _bulk         = bulk;
            _fileAccessor = fileAccessor;
            _eventWriter  = eventWriter;

            FixedFields               = FixFlags.Partial;
            SerializeObjects          = true;
            BulkSize                  = 2000;
            BulkIdleTimeout           = 5000;
            DropEventsOverBulkLimit   = false;
            TotalDropEventLimit       = null;
            TimeoutToWaitForTimer     = 5000;
            ElasticSearchTimeout      = 10000;
            IndexAsync                = true;
            Template                  = null;
            AllowSelfSignedServerCert = false;
            Ssl                  = false;
            _tolerateCalls       = _tolerateCallsFactory.Create(0);
            Servers              = new ServerDataCollection();
            ElasticFilters       = elasticFilters;
            AuthenticationMethod = new AuthenticationMethodChooser();
            IndexOperationParams = new IndexOperationParamsDictionary();
        }
        public void FORMATTER_SHOULD_USE_CORRECT_DATE_TIMEZONE_ACCORDING_TO_LEADING_SYMBOL(string format,
                                                                                           string expected)
        {
            //Arrange
            var formatter = new LogEventSmartFormatter(format);
            //Act
            var result = formatter.Format();

            //Assert
            result.Should().Be(expected);
        }
Beispiel #3
0
        public void AddEventToBulk(Dictionary <string, object> logEvent, LogEventSmartFormatter indexNameFormat,
                                   LogEventSmartFormatter indexTypeFormat, IndexOperationParamsDictionary indexOperationParams)
        {
            var indexName = indexNameFormat.Format(logEvent).ToLower();
            var indexType = indexTypeFormat.Format(logEvent);
            var indexOperationParamValues = indexOperationParams.ToDictionary(logEvent);

            var operation = new InnerBulkOperation
            {
                Document             = logEvent,
                IndexName            = indexName,
                IndexType            = indexType,
                IndexOperationParams = indexOperationParamValues
            };

            lock (_lock)
            {
                _currentBulk.Add(operation);
            }
        }
Beispiel #4
0
 public ConverterDetails(LogEventSmartFormatter key, Func <object, object> convertFunc)
 {
     Key         = key;
     ConvertFunc = convertFunc;
 }