-
Notifications
You must be signed in to change notification settings - Fork 6
Producer Writeable metrics
How to get the same metrics as the official KPL
Sample code based on Prom Client
const promClient = require('prom-client')
Count of how many logical user records were received by the KPL core for putting.
Periodic sample of how many user records are currently pending. A record is pending if it is either currently buffered and waiting for to be sent, or sent and in-flight to the backend.
Count of how many logical user records were put successfully.
userRecordsPutCounter = new promClient.Counter({
name: 'kinesis_user_records_put_total',
help: 'Count of how many logical user records were put successfully',
labelNames: ['topic', 'shard'],
})
kinesisWriter.on('kinesis.putRecords', (response) => {
response.Records.forEach((x) => {
if (x.ShardId) {
userRecordsPutCounter.labels(TOPIC, x.ShardId).inc();
}
});
});
Bytes in the logical user records successfully put.
Count of how many Amazon Kinesis records were put successfully. Recall that each Amazon Kinesis record can contain multiple user records.
exports.kinesisRecordsPutCounter = new promClient.Counter({
name: 'kinesis_records_put_total',
help: 'Count of how many Amazon Kinesis records were put successfully',
labelNames: ['topic'],
})
kinesisWriter.on('kinesis.putRecords', (response) => {
kinesisRecordsPutCounter.labels(TOPIC).inc()
})
Bytes in the Amazon Kinesis records.
Count of each type of error code. This introduces an additional dimension of ErrorCode, on top of the normal ones like StreamName and ShardId.
This is triggered by the same errors as above, but does not distinguish between types. This is useful as a general monitor of the error rate without having to manually sum the counts from all the different types of errors.
Number of retries performed per user record. Zero is emitted for records that succeed in one try.
The time between a user record arriving at the KPL and leaving for the backend. This information is transmitted back to the user on a per-record basis, but is also available as an aggregated statistic.
The time it takes to perform PutRecordsRequests.
The number of logical user records aggregated into a single Amazon Kinesis record.
The number of Amazon Kinesis records aggregated into a single PutRecordsRequest.
The total number of user records contained within a PutRecordsRequest. This is roughly equivalent to the product of the previous two metrics.