Я использую Elastic.Serilog.sinks для передачи некоторых данных непосредственно в Elasticsearch. Очень простой механизм < /p>
.WriteTo.Logger(lc =>
{
lc.Filter.ByIncludingOnly(le => le.Properties.ContainsKey("ecs.version"))
.WriteTo.Elasticsearch(
new[] { new Uri("http://localhost:9200") },
opts =>
{
opts.DataStream = new DataStreamName("logs", entryAssembly.GetName().Name!.ToLowerInvariant());
opts.BootstrapMethod = BootstrapMethod.Failure;
opts.ConfigureChannel = channelOpts =>
{
channelOpts.BufferOptions = new BufferOptions { ExportMaxConcurrency = 10 };
};
},
_ =>
{
// No authentication
});
})
< /code>
вещь - это создание дополнительных полей, которые мне не нужны и хочу, как Agent.Type и так далее. Я думал, что смогу создать трубопровод черного списка что -то вроде < /p>
private static async Task IngestPipeline()
{
var pipelineDefinition = new
{
description = "Removes ECS fields we don't want",
processors = new object[]
{
new
{
remove = new
{
field = new[]
{
"agent.type",
"agent.version",
"data_stream.type"
},
ignore_missing = true
}
}
}
};
string json = JsonConvert.SerializeObject(pipelineDefinition);
using var httpClient = new HttpClient();
var requestContent = new StringContent(json, Encoding.UTF8, "application/json");
string pipelineUrl = "http://localhost:9200/_ingest/pipeline/ ... ecs_fields";
using HttpResponseMessage response = await httpClient.PutAsync(pipelineUrl, requestContent);
response.EnsureSuccessStatusCode();
}
< /code>
Но есть ли какой -то триггер событий в ElasticSearchSinkoptions, который я могу использовать для его выполнения? < /p>
Например: < /p>
opts.Pipeline = "remove_ecs_fields";
Подробнее здесь: https://stackoverflow.com/questions/794 ... d-pipeines
Elastic.serilog.sinks события и труба; ines ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Serilog с Elastic.Serilog.Sinks — минимальный уровень журнала не отражается
Anonymous » » в форуме C# - 0 Ответы
- 89 Просмотры
-
Последнее сообщение Anonymous
-