Search code examples
amazon-web-servicesaws-lambdaaws-xray

Searching AWS X-ray filtered on annotations


I have enabled X-ray tracing for my AWS Lambda function and from my code base and an annotation that captures the accountId. The AWX X-Ray doc for getting data from X-ray mentions that annotation associated with X-ray trace are indexed

I am annotating my traces with an accountId. I wish to retrieve all traces having accountId = '12345'

I have confirmed that my traces have my required annotation. I found this doc but I am just not sure of how to apply these filters from cli.

Snippet from result of a trace using the aws xray get-trace-summaries --start-time <start_time> --end-time <end_time>

"Annotations": {
                "lambdaAccountId": [
                    {
                        "AnnotationValue": {
                            "StringValue": "12345"
                        }
                    }
                ]
            }, 

Solution

  • aws xray get-trace-summaries --start-time=1587398166 --end-time=1587398566 --filter-expression "annotation.lambdaAccountId=\"12345\""
    

    would do the work. Here is the link with some sample queries