0

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"
                        }
                    }
                ]
            }, 
alwaysAStudent
  • 2,110
  • 4
  • 24
  • 47
  • Did you get any results on aws console ? Executing the query such as service("your-lambda-service-name") and annotation.lambdaAccountId = "12345" – Ersoy Apr 20 '20 at 15:30
  • Yes. Adding `annotation.lambdaAccountId = "12345"` in the console search, gives all traces with the annotation. However, not sure how to use this filter from cli – alwaysAStudent Apr 20 '20 at 15:59
  • Another option could be; aws xray get-trace-summaries --start-time=1587398166 --end-time=1587398566 --filter-expression "annotation.lambdaAccountId=\"12345\"" aws cli documentation doesn't provide a lot about the example usages. edit: you need to escape double quotes – Ersoy Apr 20 '20 at 16:11
  • I think this issue is related to https://stackoverflow.com/a/61299691/2188922 - please let me know if it works - i will update the answer in the given link. anyone may need it in the future. – Ersoy Apr 20 '20 at 16:18
  • 1
    Its kind-off related... But the above command works... You can move it to "Answers" and I accept it.. Thanks – alwaysAStudent Apr 20 '20 at 16:20

1 Answers1

3
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

Ersoy
  • 8,816
  • 6
  • 34
  • 48