elasticsearch 如何从Elastic.CommonSchema格式化EcsTextFormatter?

s71maibg  于 7个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(49)

我正在使用EcsTextFormatter,但我看到你可以有自定义Map。我想删除主机字段,但我不确定如何在自定义Map中做到这一点。
我在我的代码中设置了它,但是MapCustom不会接受这两个参数。

var config = new EcsTextFormatterConfiguration();

        config.MapCustom((EcsDocument ecs1, LogEvent logEvent, EcsDocument ecs2) =>
        {
            ecs.Host = null;
        });

字符串
但是,我收到来自MapCustom的此错误。

Severity    Code    Description Project File    Line    Suppression State
Error   CS7036  There is no argument given that corresponds to the required formal parameter 'arg2' of 'Func<EcsDocument, LogEvent, EcsDocument>'   TestPOC

dl5txlt9

dl5txlt91#

要排除host属性,您不需要向MapCustom提供函数,只需使用IncludeHost配置选项。

var config = new EcsTextFormatterConfiguration()
{
    IncludeHost = false
}

字符串
如果你想使用MapCustom,你应该改变你的语法。MapCustom有两个参数:EcsDocument和LogEvent。它返回一个EcsDocument

MapCustom = (EcsDocument ecs1, LogEvent logEvent) =>
{
    // Configure ecs2 based on ecs1 and logEvent
    var ecs2 = ...
    return ecs2;
}

相关问题