Skip to content

smbc-digital/StockportGovUK.AspNetCore.Logging.Elasticsearch.Aws

Repository files navigation

StockportGovUK.AspNetCore.Logging.Elasticsearch.Aws

💻 📡 ☁️
You're only as good as your logging!
A NuGet package to encapsulate Serilog.Sinks.Elasticsearch configuration for logging to Elasticsearch running in AWS

Version Download Stability

External Links GitHub | NuGet

Built with ❤︎ by Stockport Council and contributors

Table of Contents

Features

Example

public void ConfigureServices(IServiceCollection services)
{
    Log.Logger = new LoggerConfiguration()
        .ReadFrom.Configuration(Configuration)
        .WriteToElasticsearchAws(Configuration);
}

Philosophy

Kibana is a great log aggrigation service, paired with AWS infrastructure it makes for an easy Logging As a Service experience. Serilog is an easy to implament and use logging diagnostics library, however, although there is a sink in place for Elasticsearch, it doesn't encapsulate the configuration needed for Elasticsearch in AWS.

In comes this NuGet package. 👏 👏

Written to allow setup via configuration you can now enjoy the benefits of Serilog, Elasticsearch, Kibana and AWS all together!

Setup

The default convention for configuration files is as below:

"ElasticsearchAwsConfiguration": {
    "Region": "[AWS Region]<string>",
    "IndexFormat": "[Index Format]<string>",
    "InlineFields": false,
    "MinimumLevel": "[Minimum Warning Level]<string>",
    "Enabled": false,
    "Url": "[Elasticsearch URL]<string>"
}

To ensure that your Access Key and Secret Key remain secret we reccomend storing these in a seperate config file to your standard application configuration.

"ElasticsearchAwsSecretsConfiguration": {
    "AccessKey": "[AWS Access Key]<string>",
    "SecretKey": "[AWS Secret Key]<string>"
}

Once your configuration is setup you need to register Elasticsearch with your applications logger:

public void ConfigureServices(IServiceCollection services)
{
    Log.Logger = new LoggerConfiguration()
        .ReadFrom.Configuration(Configuration)
        .WriteToElasticsearchAws(Configuration);
}

Badda bing, badda boom, you have your logging working.

Installation

$ dotnet add package StockportGovUK.AspNetCore.Logging.Elasticsearch.Aws

Support

If you have any suggestions, fixes or new features please reach out to us here on GitHub!

License

MIT

About

A package that wraps setup and configuration of Serilog and log to Elasticsearch running in AWS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages