Skip to content
This repository was archived by the owner on Jun 1, 2024. It is now read-only.
This repository was archived by the owner on Jun 1, 2024. It is now read-only.

Configure authentication like api key from appsettings.json #476

Open
@snebjorn

Description

@snebjorn

Does this issue relate to a new feature or an existing bug?

  • Bug
  • New Feature

What version of Serilog.Sinks.Elasticsearch is affected? Please list the related NuGet package.
serilog.sinks.elasticsearch v8.4.1

What is the target framework and operating system? See target frameworks & net standard matrix.

  • netCore 2.0
  • netCore 1.0
  • 4.7
  • 4.6.x
  • 4.5.x

Please describe the current behavior?

Not possible to set api keys from appsettings.json.
Today it has to be done from code

.UseSerilog(
    (context, services, configuration) =>
    {
        configuration.WriteTo.Elasticsearch(
            new ElasticsearchSinkOptions(new Uri("..."))
            {
                ModifyConnectionSettings = (x) =>
                    x.ApiKeyAuthentication(new ApiKeyAuthenticationCredentials("my api key"))
            }
        );
    }
)

Please describe the expected behavior?

It would be handy if we could configure authentication like api keys from appsettings.json

Something like

{
  "Serilog": {
    "Using": ["Serilog.Sinks.Elasticsearch"],
    "WriteTo": {
      "ElasticsearchSink": {
        "Name": "Elasticsearch",
        "Args": {
          "nodeUris": "...",
          "apiKey": "my api key"
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions