Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 将cloudwatch请求id替换为自定义唯一id_Amazon Web Services_Amazon S3_Amazon Ec2_Aws Lambda_Serverless - Fatal编程技术网

Amazon web services 将cloudwatch请求id替换为自定义唯一id

Amazon web services 将cloudwatch请求id替换为自定义唯一id,amazon-web-services,amazon-s3,amazon-ec2,aws-lambda,serverless,Amazon Web Services,Amazon S3,Amazon Ec2,Aws Lambda,Serverless,我想向我的cloudwatch活动发送一个唯一的id。 下图显示了请求id。必须更改此唯一id 下面是我的lambda函数的serverless.yml代码。 我试图添加一个输入(输入变压器),但效果不大。 我能在这里做什么 functions: stream-function: handler: src/stream-handler/stream.handler memorySize: 1024 #in MB, also control CPU throughput

我想向我的cloudwatch活动发送一个唯一的id。
下图显示了请求id。必须更改此唯一id

下面是我的lambda函数的serverless.yml代码。
我试图添加一个输入(输入变压器),但效果不大。
我能在这里做什么

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

这是为lambda函数调用指定的AWS。你不能改变它

RequestId–调用的唯一请求ID


相反,在函数代码中,您可以生成一些额外的ID,与您的其他数据一起输出到CloudWatch日志中。

注意。好的,我想给我的日志发送一个额外的唯一ID。最好的方法是什么???@grooot它的用例说明。在python中,只需执行
print(f“MyRequestId:{id,您根据应用程序需求生成的id}”)
@grooot它进行得如何?你成功生成身份证了吗?是的,谢谢你。