Skip to content

johnkors/IdentityServer3.Contrib.ElasticSearchEventService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

master:master dev:dev NuGet Stable NuGet Prerelease Downloads

Contents

Implementation of IdentityServerV3s IEventService using Serilogs ElasticSearchSink to push IdentityServerv3 events on a format useful for Kibana.

Usage

   var elasticUri = new Uri("http://your.elasticsearch.instance/");
   var options = new ElasticsearchSinkOptions(elasticUri);
   var eventService = new ElasticSearchEventService(options);

Also support for custom mapping through the MappingConfigurationBuilder class.

    var configuration = new MappingConfigurationBuilder()
        .DetailMaps(b => b
            .For<AccessTokenIssuedDetails>(t => t
                .Map(d => d.ClientId)
                .Map("ScopeCount", d => d.Scopes.Count())
                .MapRemainingMembersAsJson()
            )
            .DefaultMapAllMembers()
        )
        .AlwaysAdd("key", "value")
        .AlwaysAdd("WeekDay", () => DateTime.Now.DayOfWeek)
        .GetConfiguration();
    
    var eventMapper = new DefaultLogEventMapper(configuration);
    var elasticUri = new Uri("http://your.elasticsearch.instance/");
    var options = new ElasticsearchSinkOptions(elasticUri);
    var eventService = new ElasticSearchEventService(options, eventMapper);

where a simple implementation is

    public class MyOwnPropertiesAdder : IAddExtraPropertiesToEvents
    {
        public IDictionary<string, string> GetNonIdServerFields()
        {
            return new Dictionary<string, string>{ { "SomeFieldName", "SomeValue" } };
        }
    }

This example adds SomeFieldName : "SomeValueIWantOnEveryEvent" to every log statement sent to ElasticSearch.

Install

  PM> Install-Package IdentityServer3.ElasticSearchEventService

NuGet: https://www.nuget.org/packages/IdentityServer3.ElasticSearchEventService

Kibana screenshots Kibana

Dependencies

About

Implementations of some of the extension points to IdentityServerV3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published