简体   繁体   English

使用 Kinesis Firehose 将数据写入 S3 时出现问题,所有记录都是 404 条消息

[英]Problem writing data to S3 with Kinesis Firehose, all records are 404 messages

I've set up a Kinesis Firehose stream which successfully runs the "test" in the AWS console.我已经设置了一个 Kinesis Firehose stream,它在 AWS 控制台中成功运行了“测试”。 My code writing to the stream looks like this:我写入 stream 的代码如下所示:

return graphqlHTTP(
(request: Object, response: Object, params: Object): Object => {
  const firehoseConfig: Object = {
    region: config.get('awsRegion'),
    credentials = {
      accessKeyId: config.get('awsAccessKey'),
      secretAccessKey: config.get('secretAccessKey'),
    }
  }
  // Init Kinesis Firehose
  const firehose = new AWS.Firehose(firehoseConfig)
  // Prep response object for sending
  const stringifiedResponse = JSON.stringify(response)
  // Send to Kinesis Firehose stream
  const firehoseParams = {
    DeliveryStreamName: 'test-stream',
    Record: {
      Data: Buffer.from(stringifiedResponse),
    },
  }
  firehose.putRecord(firehoseParams, (err: Object, data: Object) => {
    // eslint-disable-next-line no-console
    if (err) console.log('FIREHOSE ERROR: ', err, err.stack)
    // eslint-disable-next-line no-console
    else console.log(data)
  })

Records are writing to the stream when the endpoint is hit, however all records look like this:当端点被命中时,记录正在写入 stream,但是所有记录如下所示:

 {
  "status": 404,
  "message": "Not Found",
  "header": {
    "x-frame-options": "SAMEORIGIN",
    "strict-transport-security": "max-age=86400",
    "x-download-options": "noopen",
    "x-content-type-options": "nosniff",
    "x-xss-protection": "1; mode=block",
    "vary": "Accept-Encoding, Origin",
    "cache-control": "max-age=60, s-maxage=60",
    "access-control-allow-origin": "<redacted internal site>",
    "access-control-allow-credentials": "true",
    "access-control-expose-headers": "content-length,etag",
    "x-ratelimit-remaining": "996",
    "x-ratelimit-reset": "1571372307",
    "x-ratelimit-limit": "1000"
  }
} {
  "status": 404,
  "message": "Not Found",
  "header": {
    "x-frame-options": "SAMEORIGIN",
    "strict-transport-security": "max-age=86400",
    "x-download-options": "noopen",
    "x-content-type-options": "nosniff",
    "x-xss-protection": "1; mode=block",
    "vary": "Accept-Encoding, Origin",
    "cache-control": "max-age=60, s-maxage=60",
    "access-control-allow-origin": "<redacted internal site>",
    "access-control-allow-credentials": "true",
    "access-control-expose-headers": "content-length,etag",
    "x-ratelimit-remaining": "995",
    "x-ratelimit-reset": "1571372307",
    "x-ratelimit-limit": "1000"
  }
}

What I'm trying to do is have this Firehose send the response to S3 so that I can later run queries on it with Athena.我想要做的是让这个 Firehose 将response发送到 S3,以便我以后可以使用 Athena 对其运行查询。

It turns out that a 404 from Kinesis, per the docs , indicates a malformed query.事实证明,根据文档,来自 Kinesis 的 404 表示查询格式错误。 In this context it means that the Data being provided in Record isn't valid JSON.在这种情况下,这意味着Record中提供的Data不是有效的 JSON。 The response object, which here is provided by Koa/ koa-graphql , is a large object with circular references, and somewhere therein is invalid JSON or JSON that AWS considers to be invalid. The response object, which here is provided by Koa/ koa-graphql , is a large object with circular references, and somewhere therein is invalid JSON or JSON that AWS considers to be invalid.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM