elastic / ecs-dotnet

https://www.elastic.co/guide/en/ecs-logging/dotnet/current/setup.html
Apache License 2.0
108 stars 54 forks source link

[QUESTION] Support for log forwarding through Elastic Agent using Custom HTTP Logs integration #409

Open mattmichal opened 1 month ago

mattmichal commented 1 month ago

Is it possible to use the Elastic.Serilog.Sinks package to send logs to an Elastic Agent having the Custom HTTP Logs integration?

From serilog-contrib/serilog-sinks-elasticsearch#486:

Elastic.Serilog.Sinks will not only target Elasticsearch. Long term we will explore it sending data to our APM product, OTLP, Logstash, Elastic Agent and many others.

In my testing with an agent having the custom logs integration listening on port 8080, I'm getting an error.

config.WriteTo.Elasticsearch(new[] { new Uri("http://localhost:8080") }, opts =>
{
    opts.DataStream = new DataStreamName("logs", "dotnet", "default");
    opts.BootstrapMethod = BootstrapMethod.Failure;
});

Error:

System.Exception: Failure to create component template `ecs_8.11.0_agent` for logs-dotnet-*: Invalid Elasticsearch response built from a unsuccessful (405) low level call on PUT: /_component_template/ecs_8.11.0_agent
Exception: Failed to ping the specified node. Call: Status code 405 from: HEAD /

If this is not supported, is it planned?

Is there an alternate way to use Serilog to send logs via an agent? We have certain authorization considerations that will not allow us to push logs directly to our Elastic Cloud instance.