我在 Kibana 中遇到value
了以下行中解释的字段的问题。我会试着解释一下情况。
我将 dynamoDB 流发送到 Lambda,然后发送到 Kenesis Firehouse,最后从 Firehose 发送到 Elasticsearch。我正在使用 Kibana 来可视化数据,这就是我遇到问题的地方。
假设我将此 JSON 发送到 DynamoDB:
{
"id": "identificator",
"timestamp": "2017-05-09T06:38:00.337Z",
"value": 33,
"units": "units",
"description": "This is the description",
"machine": {
"brand": "brand",
"application": "application"
}
}
在 Lambda 中,我收到以下信息:
{
"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 转发到 Kinesis Firehose,当我在 Kibana 中配置索引模式时,它会"timestamp"
自动识别(这很棒)。这里的问题是该字段"value"
就像一个字符串并且无法识别。
我尝试修改 JSON,然后将其再次发送到 Firehose,但 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 可以识别“时间戳”和“值”字段。
这是我在 lambda 中使用的代码示例:
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();
});
};