我在Kibana中遇到問題,在以下行中解釋了字段value
。我會盡力解釋這種情況。實際值無法識別從Kinesis Firehose發送JSON數據到elasticsearch
我將dynamoDB流發送到Lambda,然後發送到Kenesis Firehouse,最後從Firehose發送到Elasticsearch。我使用Kibana來可視化數據,這裏是我遇到問題的地方。
比方說,我要送這個JSON來DynamoDB:
拉姆達我收到以下:
{
"data": {
"M": {
"machine": {
"M": {
"application": {
"S": "application"
},
"brand": {
"S": "band"
}
}
},
"description": {
"S": "This is the description"
},
"id": {
"S": "identificator"
},
"units": {
"S": "units"
},
"value": {
"N": "33"
},
"_msgid": {
"S": "85209b75.f51ee8"
},
"timestamp": {
"S": "2017-05-09T06:38:00.337Z"
}
}
},
"id": {
"S": "85209b75.f51ee8"
}
}
如果我轉發這最後JSON來室壁運動流水,在Kibana時我配置索引模式,它自動識別"timestamp"
(這很好)。這裏的問題是字段"value"
就像一個字符串,它不被識別。
我試圖修改JSON,然後再發送到流水,但隨後Kibana不承認"timestamp"
:
{
"data": {
"machine": {
"application": "application",
"brand": "brand"
},
"description": "This is the description",
"id": "identificator",
"units": "KWh",
"value": 33,
"_msgid": "85209b75.f51ee8",
"timestamp": "2017-05-09T06:38:00.337Z"
},
"id": "85209b75.f51ee8"
}
我想知道我怎麼能發送這個數據和Kibana承認「時間戳「和」值「字段。
這是我使用的拉姆達的代碼示例:
var AWS = require('aws-sdk');
var unmarshalJson = require('dynamodb-marshaler').unmarshalJson;
var firehose = new AWS.Firehose();
exports.lambda_handler = function(event, context) {
var record = JSON.stringify(event.Records[0].dynamodb.NewImage);
console.log("[INFO]:"+JSON.stringify(event.Records[0].dynamodb.NewImage));
var params = {
DeliveryStreamName: 'DeliveryStreamName',
Record:{
Data: record
}
};
firehose.putRecord(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(JSON.stringify(data)); // successful response
context.done();
});
};