This repository was archived by the owner on Jun 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
Add Support for OpenSearch. #574
Copy link
Copy link
Open
Description
Summary
serilog.sinks.elasticsearch 8.4.1 supports OpenSearch but for OpenSearch to work you need to set TypeName option set to null. and that can only be configured through code and not through appsettings.json.
This error was fixed in version 9 but version 9 does not support OpenSearch
If TypeName option is not set to null below error occurs:
Caught exception while preforming bulk operation to Elasticsearch: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute.
Call: Status code 400 from: POST /_bulk. ServerError: Type: illegal_argument_exception Reason: "Action/metadata line [1] contains an unknown
parameter [_type]"
Steps to reproduce
// Program.cs
using Serilog;
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog( (context, config) => { config.ReadFrom.Configuration(context.Configuration); } );
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.Run();{
"_comment1": "This is 'appsettings.json' file",
"Serilog": {
"Using": [ "Serilog.Sinks.Elasticsearch" ],
"WriteTo": [
{
"Name": "Elasticsearch",
"Args": {
"nodeUris": "http://localhost:9200",
"typeName": null,
"autoRegisterTemplate": true,
"autoRegisterTemplateVersion": "ESv7"
}
}
],
"Properties": {
"Application": "bossport"
}
}
}
Spin OpenSearch Container In docker
OpenSearch docker command:
docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "DISABLE_SECURITY_PLUGIN=true" --name opensearch opensearchproject/opensearch:latestOpenSearch Dashboard docker command:
docker run -d -p 5602:5601 -e 'OPENSEARCH_HOSTS=["http://localhost:9200"]' -e 'DISABLE_SECURITY_DASHBOARDS_PLUGIN=true' --name opensearch-dashboard opensearchproject/opensearch-dashboardsWhat is the current bug behavior?
"typeName": null does not get configured via appsettings.
Metadata
Metadata
Assignees
Labels
No labels