grooot
grooot

Reputation: 466

replace the cloudwatch request id with a custom unique id

I want to send an unique id to my cloudwatch event.
The below image shows the request id. This unique id has to be changed.

enter image description here

Below is the serverless.yml code for my lambda function.
I tried to add an input (InputTransformers) but it didn't do much.
What can i do here???

functions:
  stream-function:
    handler: src/stream-handler/stream.handler
    memorySize: 1024 #in MB, also control CPU throughput
    timeout: 31 #in seconds, match with downstream to avoid concurrent request
    events:
      - stream:
          type: kinesis
          arn:
            Fn::GetAtt: [HagoStream, Arn]
          batchSize: 1
          parallelizationFactor: 2
          Id: "my cloud watch rule name"
          InputTransformer: {
               InputTemplate: '{"uniqueId": "96c80428-14fe-c8d0-f6e3-639384992391"}',
                InputPathsMap: {
                  id: '$.uniqueId'
                }
            }
          maximumRetryAttempts: 2
          destinations:
            onFailure:
              arn:
                Fn::GetAtt: [HagoFailedQueue, Arn]
              type: sqs

    environment:
      DLQ_URL:
        Ref: HagoDlqQueue

Upvotes: 2

Views: 3093

Answers (1)

Marcin
Marcin

Reputation: 238209

This is AWS assigned unique ID for your lambda function invocation. You can't change it.

RequestId – The unique request ID for the invocation.

Instead, in your function code, you can generate some extra ID that you output in CloudWatch Logs alongside with other data of yours.

Upvotes: 2

Related Questions