Reputation: 10297
I have a service that emits messages of two types:
Type_1 / Type_2
(a unique Type_2 always follows a Type_1)
I've been thinking about using AWS Lambda to emit metrics on the latency between receiving Type_1
messages and their corresponding Type_2
messages that follow (they're 1:1). For example:
1. Type_1 arrives
2. Type_2's corresponding Type_2 arrives
3. Lambda (Type_2.timestamp - Type_1.timestamp) = latency between the messages.
Is there any simple way to do this in Lambdas? I'm guessing I'll need to cache all of the Type_1
messages and then grab/diff them as their sister Type_2
messages come through.
My use case is essentially that if a Type_2
takes too long (aka over 1 second) to follow its sister message, I'd like to emit some metrics on it.
Upvotes: 1
Views: 129
Reputation: 16067
I am assuming you want to do your own metrics and alarms instead of using Cloudwatch.
My solution would be this:
Upvotes: 1
Reputation: 4197
A very simple way to achieve this would be writing the timestamp
of Type_1
under an id on S3 (e.g. s3://bucket-name/id/type_1.timestamp
) and have the Type_2
function download the file from S3, calculate the delta and decide on any further work based on the timestamps difference.
Upvotes: 1