Observability

Monitoring is collecting data:

  • collecting metrics
  • collection logs
  • Monitoring network traffic

When something goes wrong, the alerts are sent.

Observability is a property of the system. It enables to understand the impact of a change quickly once the change is made in the system.

Amazon X-ray

AWS X-Ray is a service that collects data about requests that your application serves, and provides tools you can use to view, filter, and gain insights into that data to identify issues and opportunities for optimization.

  • Segment

    The compute resources running your application logic

  • Subsegments

    A segment can break down the data about the work done into subsegments.

  • Service graph

    A Json document that presents the services and resources that make up your application.

  • Trace

    A tracking of the path of a request through your system collecting the segments generated by the request.

  • Annotations and metadata

    You can add other information to the segment document as annotations and metadata.

    Annotations and metadata are aggregated at the trace level, and can be added to any segment or subsegment.

    • Annotations

      They are simple key-value pairs that are indexed for use with filter expressions.

    • Metadata

      They are key-value pairs with values of any type, including objects and lists, but that are not indexed.

Default sampling rate consists of the first request per second and 5% of additional requests.

The X-Ray Daemon

The AWS X-Ray daemon is a software application that listens for traffic on UDP port 2000, gathers raw segment data, and relays it to the AWS X-Ray API.

If you are running code on AWS Lambda, the X-ray Daemon is installed and managed for you.

Amazon CloudWatch Log

It's a log system provided by Amazon.

  • Log events

    A log event is a record of some activity recorded by the application or resource being monitored.

    It has 2 properties: timestamp and raw event message.

  • Log streams

    A log stream is a sequence of log events that share the same source. For example, a log stream for a lambda execution context.

  • Log groups

    Log groups define groups of log streams that share the same retention, monitoring, and access control settings.

    For example, a log group for a lambda functionll, which includes all its execution contexts.

  • Metric filters

    You can use metric filters to extract metric observations from ingested events and transform them to data points in a CloudWatch metric.

    Metric filters are assigned to log groups, and all of the filters assigned to a log group are applied to their log streams.

  • Retention settings

    Retention settings can be used to specify how long log events are kept in CloudWatch Logs.

    The retention assigned to a log group is applied to their log streams.

AWS Lambda and CloudWatch Logs

The only step is to make sure that Lambda is allowed to create a Log Group, create a Log Stream and put Log Events. This can easily be done by using the IAM managed policy “AWSLambdaBasicExecutionRole”.

Amazon API Gateway and CloudWatch Logs

You configure this at the stage level.