XRAY Flashcards

1
Q

Xray overview

A

Visual Analysis of application

  • can see distributed applications and see requests that do well or fail
  • can visualize how services call other services
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Xray Advantages
when and where to use it
what it can see

A

Troubleshoot bottlenecks
Understand dependencies in Microservice architecture
-see how microservices interact
-method calls to one another.

Pinpoint service issues

See how each request behaives

Find error and exceptions

See if we are meeting SLA, time requirements

See Throttle location issues

Identity users that are impacted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

XRAY tracing
request
trace
security

A

trace: End to end tracking of “request”
request: Services that call to one another, each call leaves a “trace”
Trace: made of segments and subsegments,

Trace:

  • Every request
  • Sample request: % rate per minute

X-ray Security:
IAM authorization
KMS for encryption at rest

Segment: The compute resources running your application logic send data about their work as segments. A segment provides the resource’s name, details about the request, and details about the work done. For example, when an HTTP request reaches your application, it can record the following data about:
The host – hostname, alias or IP address
The request – method, client address, path, user agent
The response – status, content
The work done – start and end times, subsegments
Issues that occur – errors, faults and exceptions, including automatic capture of exception stacks.

SUBSEGMENTS: A segment can break down the data about the work done into subsegments. Subsegments provide more granular timing information and details about downstream calls that your application made to fulfill the original request. A subsegment can contain additional details about a call to an AWS service, an external HTTP API, or an SQL database. You can even define arbitrary subsegments to instrument specific functions or lines of code in your application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

X-ray how to enable

code
X-ray Daemon
X-ray aws integration

A

1: VIA CODE: import aws X-ray SDK
- very little code modding is needed
- Application SDK will capture:
Calls to AWS services
HTTP / HTTPS request
DB calls MYSQL, postresql, Dynamodb
Queue Calls (SQS)

  1. X-ray Daemon, X-ray integration
    A. X-ray Daemon: Works like UDP packet interceptor
    (linux, windows, mac)

B. X-ray aws integration: already done, AWS lambda/ other services run the daemon for you

each application MUST HAVE IAM RIGHTS TO write data to X-ray.

DIAGRAM

  1. Ec2: application code needs to add AWS XRAY SDK
  2. Traces sent to XRAY DAEMON, which runs on machine
  3. XRAY DAEMON SENDS BATCH 1 EVERY SECOND TO AWS XRAY (NEED IAM PERMISSIONS)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

X-RAY data aggregation

A
  • Collection of data from Xray batches from daemon

- Service Map is created/computed from all SEGMENTS and TRACE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

x-ray Troubleshooting:
ec2
lambda

A

NOT WORKING ON EC2

  1. permissions issue
  2. instance needs to run daemon

AWS LAMBDA

  1. needs to have IAM EXECUTION ROLE with proper policy (AWSX-RayWriteOnlyAccess)
  2. MAKE SURE CODE IS IMPORTED AND INTEGRATION IS ENABLED ON LAMBDA
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

X-ray Instrumentation in code

A

Instrumentation :

  1. measure of performance
  2. Diagnose errors
  3. write trace information

Instrument an AWS application via, XRAY SDK
Many SDK require only requires config changes

Modification of app code to customize annotation of SDK data sent to Xray VIA:
Interceptors
Filters
Handlers
Middleware
*takeway: you can customize how x-ray works via code configuration changes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
XRAY
Segments
Subsegments
trace
sampling
annotations
metadata
annotation vs metadata
A

Segments: Each application and service send them. how we see things in UI

Subsegments: Give more details in segments

trace: aggregation of segments, show end to end trace of entire API call

Sampling: Decrease amounts of requests sent to Xray to reduce cost

Annotations: KeyValue pairs used to INDEX traces and use with FILTERS (able to search traces with NEW indexes)

Metadata: Keyvalue pairs, NOT INDEXED, NOT used for searching

Xray daemon send trace accross account:
make sure IAM permissions are correct, agent assumes role
allows central account for all app tracing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

XRAY SAMPLING RULES

Default

A

Sampling rules

Control amount of data you record, can be modified without changing rule.

*CHANGING RULES IN CONSOLE WILL NOT NEED CODE MODIFICATION

BY DEFAULT:
SDK records first request each second**, then five percent* of additional requests.

**One request per second: RESIVOIR. ensures at least one! trace is recorded each second as long as the service is serving requests.

*Five percent is: RATE; rate at which additional requests beyond the reservoir rate are sampled.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

XRAY CUSTOM SAMPLING RULES

A

Define custom
RESIVOIR and RATE
example

Reservoir:10 Rate:0.10
10 requests per second will be sent to x-ray, then also 10% of rest

Reservoir:1 rate 1.0
one will be sent per second, and also 100% of rest.

*CHANGING RULES IN CONSOLE WILL NOT NEED CODE MODIFICATION

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
X-RAY API
X-Ray WRITE
PutTraceSegments: 
PutTelemetryRecords
GetSamplingRules
GetSamplingTargets
GetSamplingStatistics
A

PutTraceSegments:
Upload segment document into X-ray

PutTelemetryRecords:
X-ray daemon, upload information of metrics.
Segmentsreceivedcount: Segments received
Segmentrejectedcounts: Segments rejected
BackendConnectionErrors: backend errors

GetSamplingRules: Retrieve all sampling rules
GetSamplingTargets: related to above
GetSamplingStatistics related to above
**Get rules allow Daemon to understand sampling changes done in console, these changes in console do not need to be changed on each machine’s code.

FOR API CALLS TO WORK:
X-ray Daemon needs IAM authorization for these calls to function correct.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

X-RAY API
X-Ray READ

GetServiceGraph:
BatchGetTraces:
GetTraceSummaries:
GetTraceGraph:

A

GetServiceGraph: Main graph in console

GetTraceSummaries:
Get ID and Annotations for traces available for TIME:
for full traces pass this into BatchGetTraces

BatchGetTraces: FULL TRACES
*Retrieves a list of traces specified by ID. Each trace is a collection of segment documents that originates from a single request. Use GetTraceSummaries to get a list of trace IDs.

GetTraceGraph: Get a service graph for for one or more trace ID’s

TRACE ID:
A trace ID tracks the path of a request through your application. A trace collects all the segments generated by a single request. That request is typically an HTTP GET or POST request that travels through a load balancer, hits your application code, and generates downstream calls to other AWS services or external web APIs. The first supported service that the HTTP request interacts with adds a trace ID header to the request, and propagates it downstream to track the latency, disposition, and other request data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

XRAY ECS

  1. ECS cluster container as daemon
  2. ECS cluster container as sidecar
  3. ECS Fargate cluster sidecar
A
  1. ECS cluster container as daemon
    in every EC2 instance we have multiple App containers, these app containers will be mapped through network configuration and UDP routing to a daemon XRAY container separate
    EX 2 containers connect to same daemon shared in one ec2 instance
  2. ECS cluster container as sidecar
    In one Ec2 instance we have multiple containers that are linked to an X-ray Sidecar, each container has its own x-ray daemon
  3. ECS Fargate cluster sidecar

Each fargate task launches a sidecar with an Xray Daemon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

XRAY ECS

TASK DEFINITON

A

SIDECAR
Hostport: 0
containerport: 2000
protocol UDP

Enviroment variable
AWS_XRAY_DAEMON_ADDRESS: variable that allows SDK to find Xray daemon
Value: is Xray-daemon:2000

Links: X-ray Daemon, : allows containers to map above

process

  1. map container port to 2000 udp
  2. set environment variable
  3. link via networking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

XRAY BEANSTALK

methods to enable

A
AWS beanstalk comes with X-ray
can be enabled two ways
1. Set option in elastic beanstalk console
2. with config file placed in
.EBextensions/xray-daemon.cfg

AWS:elasticbeanstalk:xray
Xrayenabled: True

Make sure to give instance profile correct IAM permissions so that X-ray Daemon can function correctly.

Application code in instrumented with the X-ray SDK: add sdk capability in app code.

DAEMON DOES NOT WORK SAME IN MULTIDOCKER CONTAINER!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly