我正在使用 Logstash 将 JSON 消息输出到 API。我正在使用“映射”属性来映射我的消息。看,按照我的托运人配置。
output {
stdout { }
http {
url => "http://localhost:8087/messages"
http_method => "post"
format => "json"
mapping => ["MessageId","654656","TimeStamp","2001-12-31T12:00:00","CorrelationId","986565","MessageType","%{log_MessageType}" ,"MessageTitle","%{log_MessageTitle}","Message","%{log_Message}"]
}
}
此配置运行良好,并产生以下输出:
{
"MessageId": "654656",
"TimeStamp": "2001-12-31T12:00:00",
"CorrelationId": "986565",
"MessageType": "INFO",
"MessageTitle": "TestTittle",
"Message": "Sample Message"
}
输入日志条目:
TID: [0] [ESB] [2016-05-30 23:02:02,602] INFO {org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService} - Configured Registry in 572ms {org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService}
格罗模式:
TID:%{SPACE}\[%{INT:log_SourceSystemId}\]%{SPACE}\[%{DATA:log_ProcessName}\]%{SPACE}\[%{TIMESTAMP_ISO8601:log_TimeStamp}\]%{SPACE}%{LOGLEVEL:log_MessageType}%{SPACE}{%{JAVACLASS:log_MessageTitle}}%{SPACE}-%{SPACE}%{GREEDYDATA:log_Message}
问题陈述:
我想通过 HTTP 的映射来跟踪输出。我想要一个嵌套的 JSON 类型在我的消息中,我应该如何在映射标签中添加它。
预期输出:
{
"MessageId": "654656",
"TimeStamp": "2001-12-31T12:00:00",
"CorrelationId": "986565",
"MessageType": "INFO",
"MessageTitle": "TestTittle",
"Message": "Sample Message",
"MessageDetail": {
"FieldA": "65656",
"FieldB": "192.168.1.1",
"FieldC": "sample value"
}
}
我尝试了几个选项,但我收到错误。