protected override void InitializeTarget() { base.InitializeTarget(); var uri = ConnectionStringName.GetConnectionString() ?? Uri; var nodes = uri.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); if (RequireAuth) { config.BasicAuthentication(Username, Password); } if (ElasticsearchSerializer != null) { config = new ConnectionConfiguration(connectionPool, _ => ElasticsearchSerializer); } _client = new ElasticLowLevelClient(config); if (!string.IsNullOrEmpty(ExcludedProperties)) { _excludedProperties = ExcludedProperties.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } }
protected override void InitializeTarget() { base.InitializeTarget(); if (!string.IsNullOrEmpty(ExcludedProperties)) { _excludedProperties = ExcludedProperties.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .ToList(); } }
protected override void InitializeTarget() { base.InitializeTarget(); var uri = GetConnectionString(ConnectionStringName) ?? Uri; var nodes = uri.Split(',').Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); var config = new ConnectionConfiguration(connectionPool); _client = new ElasticsearchClient(config, serializer: ElasticsearchSerializer); if (!String.IsNullOrEmpty(ExcludedProperties)) { _excludedProperties = new List <string>(ExcludedProperties.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } }
protected override void InitializeTarget() { base.InitializeTarget(); var uri = Uri; var nodes = uri.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(url => new Uri(url)); var connectionPool = new StaticConnectionPool(nodes); IConnectionConfigurationValues config = new ConnectionConfiguration(connectionPool); if (ElasticsearchSerializer != null) { config = new ConnectionConfiguration(connectionPool, _ => ElasticsearchSerializer); } this.client = new ElasticLowLevelClient(config); if (!string.IsNullOrEmpty(ExcludedProperties)) { this.excludedProperties = ExcludedProperties.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } }
private O365MessageCard BuildBody(Event <LogEventData> evt) { // Build action var url = BaseUrl; if (string.IsNullOrWhiteSpace(url)) { url = Host.BaseUri; } var(openTitle, openUrl) = SeqEvents.GetOpenLink(url, evt); var action = new O365ConnectorCardOpenUri { Name = openTitle, Type = "OpenUri", //Failure to provide this will cause a 400 badrequest Targets = new[] { new O365ConnectorCardOpenUriTarget { Uri = openUrl, Os = "default" //Failure to provide this will cause a 400 badrequest } } }; // Build message var msg = evt.Data.RenderedMessage; if (msg.Length > 1000) { msg = msg.EscapeMarkdown().Substring(0, 1000); } var color = Color; if (string.IsNullOrWhiteSpace(color)) { color = LevelColorMap[evt.Data.Level]; } var body = new O365MessageCard { Title = evt.Data.Level.ToString().EscapeMarkdown(), ThemeColor = color, Text = msg, PotentialAction = new O365ConnectorCardActionBase[] { action } }; // Build sections var sections = new List <O365ConnectorCardSection>(); var config = new PropertyConfig { ExcludedProperties = ExcludedProperties?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List <string>(), JsonSerializedProperties = JsonSerializedProperties?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List <string>(), JsonSerializedPropertiesAsIndented = JsonSerializedPropertiesAsIndented }; if (!config.ExcludedProperties.Contains(ExcludeAllPropertyName)) { var properties = SeqEvents.GetProperties(evt, config); var facts = properties.Where(x => !string.IsNullOrEmpty(x.Value)).Select(x => new O365ConnectorCardFact { Name = x.Key, Value = x.Value }).ToArray(); if (facts.Any()) { sections.Add(new O365ConnectorCardSection { Facts = facts }); } } if (!string.IsNullOrWhiteSpace(evt.Data.Exception)) { sections.Add(new O365ConnectorCardSection { Title = "Exception", Text = evt.Data.Exception.EscapeMarkdown() }); } body.Sections = sections.ToArray(); return(body); }