I am using Logstash to output a JSON message in the API. I use the "mapping" attribute to display my message. See Following parts of my shipper configurations.
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}"]
}
}
This configuration works fine and produces the following output:
{
"MessageId": "654656",
"TimeStamp": "2001-12-31T12:00:00",
"CorrelationId": "986565",
"MessageType": "INFO",
"MessageTitle": "TestTittle",
"Message": "Sample Message"
}
Entry Log Entry:
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}
Grok Sample:
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}
Problem:
I need the following output through an HTTP mapping. I wanted the built-in JSON type inside my post, how to add it to the mapping tag.
Expected Result:
{
"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"
}
}
I tried several options, but getting errors.