Logstash 在作为参数传递给脚本时截断 %{message}

Logstash truncating %{message} when passed as parameter to script

问题

如何在将 %{message} 作为参数传递给脚本时不被截断?

情况

我设置了 logstash 来标记特定错误、错误原因和错误解决方案(如果我知道的话)。我的配置文件中有一些如下所示。

exec {
        command => "Powershell C:\ELK-Stack\logstash\bin\SendEmail.ps1 -source %{source} -message %{message} -error %{error_cause_} -solution %{error_troubleshoot_}"
    }

上面的工作,唯一的问题是我只从每个字段中得到第一个词。

我试过的

我记得 [message] 被分解成更小的部分,然后进行分析。所以我尝试允许一个字符串数组作为参数并将它们连接在一起。我运气不好。

问题不是 logstash。问题是我调用 Powershell 脚本的方式。 改变

exec {
    command => "Powershell C:\ELK-Stack\logstash\bin\SendEmail.ps1 -source %{source} -message %{message} -error %{error_cause_} -solution %{error_troubleshoot_}"
}

exec {
    command => "Powershell -file C:\ELK-Stack\logstash\bin\SendEmail.ps1 -source %{source} -message \"%{message}\" -error \"%{error_cause_}\" -solution \"%{error_troubleshoot_}\""
}

解决了我的问题。