Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to send to Kinesis with missing partition tag #4894

Closed
DimaRabkin opened this issue Oct 21, 2018 · 10 comments
Closed

Failed to send to Kinesis with missing partition tag #4894

DimaRabkin opened this issue Oct 21, 2018 · 10 comments
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@DimaRabkin
Copy link

Relevant telegraf.conf:

[[outputs.kinesis]]

  region = "us-east-1"
  streamname = "MY_STREAM"

  data_format = "json"

  tagexclude = ["database"]

  [outputs.kinesis.partition]
    method = "tag"
    key = "task-name"

  [outputs.kinesis.tagpass]
    database = ["task_stats"]

System info:

Telegraf 1.6

Steps to reproduce:

  1. Use the attached telegraf.conf
  2. Try to send a metric to the telegraf's input without the tag "task-name"

Expected behavior:

As explained in https://github.com/influxdata/telegraf/tree/master/plugins/outputs/kinesis#tag
It should send the record to Kinesis and use an empty string with partition key

Actual behavior:

It throws exceptions:

018-10-21T08:37:40Z E! Wrote a 2 point batch to Kinesis in 17.697303ms.
2018-10-21T08:37:40Z E! Wrote a 1 point batch to Kinesis in 19.77042ms.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis : You have configured a Partition using tag task-name which does not exist.
2018-10-21T08:37:50Z E! kinesis: Unable to write to Kinesis : InvalidParameter: 19 validation error(s) found.
- minimum field size of 1, PutRecordsInput.Records[0].PartitionKey.
- minimum field size of 1, PutRecordsInput.Records[1].PartitionKey.
- minimum field size of 1, PutRecordsInput.Records[2].PartitionKey.
- minimum field size of 1, PutRecordsInput.Records[3].PartitionKey.
- minimum field size of 1, PutRecordsInput.Records[4].PartitionKey.
@glinton
Copy link
Contributor

glinton commented Oct 22, 2018

Thanks, I believe this is an issue with the implementation rather than simply a docs bug, but I may be wrong.

@glinton glinton added the bug unexpected problem or unintended behavior label Oct 22, 2018
@glinton
Copy link
Contributor

glinton commented Oct 22, 2018

Seems like an easy fix, add return "" after this if block and remove the log entry.

@danielnelson
Copy link
Contributor

We should remove this log message, since it is not an error. Documentation needs to be updated to mention the fallback to random uuid if configured. Also, we ought to use metric.GetTag(k.Partition.Key) now.

@danielnelson danielnelson added this to the 1.8.3 milestone Oct 22, 2018
@marcosnils
Copy link
Contributor

Seems like an easy fix, add return "" after this if block and remove the log entry.

I've been looking at this issue and the code is actually returning "" in this case. The thing is that you can't use empty partition keys in kinesis. What would be the desired output in this case?, generate a UUID for those metrics that don't contain the tag-name or just error out sending to kinesis?

@danielnelson
Copy link
Contributor

Maybe we should have a default value option when using the tag method, since this is the only type that can fail:

[outputs.kinesis.partition]
  method = "tag"
  key = "host"
  default = "telegraf"

@marcosnils
Copy link
Contributor

Sounds good. Shall we make the default option required?, or just set it to telegrapf if unspecified?

@danielnelson
Copy link
Contributor

Will need to default to telegraf so older config files will continue to work.

marcosnils pushed a commit to marcosnils/telegraf that referenced this issue Oct 23, 2018
@DimaRabkin
Copy link
Author

@marcosnils Are you sure Kinesis doesn't support empty string as a Partition key?
If so, then the output should check the tag's value and use the default value (or "telegraf") when tag's value is empty string, no?

In this option, I think there should be a warning log

@marcosnils
Copy link
Contributor

@marcosnils Are you sure Kinesis doesn't support empty string as a Partition key?

Yup. From the AWS documentation (https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html#Streams-PutRecord-request-PartitionKey)

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: Yes

If so, then the output should check the tag's value and use the default value (or "telegraf") when tag's value is empty string, no?

That's what I did in my PR.

In this option, I think there should be a warning log

Is this necessary if the behavior is expected and documented?. I've added the corresponding documentation in the PR.

@DimaRabkin
Copy link
Author

@marcosnils 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants