Chapter 3
Monitoring and Observability Architecture
Diploma in Cloud Computing
Cloud Resource Monitoring and Cost Optimization
•
Diploma
Monitoring and Observability Architecture
Introduction
Cloud systems are distributed, elastic, and continuously changing. A single user request may pass through a web front end, load balancer, container, service mesh, application service, database, cache, message broker, and external API. Each component can be healthy in isolation while the complete transaction is slow or unsuccessful. Monitoring and observability architecture provides the evidence needed to understand this behaviour, operate services reliably, control cloud consumption, and improve customer experience.
Monitoring traditionally asks whether known conditions are being met: Is CPU utilization above a threshold? Is a service available? Is a database connection pool exhausted? Observability extends this practice by asking whether the internal state of a complex system can be inferred from its externally produced telemetry. The distinction is important. Monitoring is usually associated with predefined signals and alerts; observability emphasizes exploration, correlation, context, and the ability to investigate previously unknown failure modes.
This chapter explains how telemetry is generated, collected, transported, stored, visualized, and used. It introduces the three principal observability signals—metrics, logs, and traces—along with profiles and events, OpenTelemetry fundamentals, dashboard design, alerting, data governance, and cost-aware architecture.
Learning Objectives
By the end of this chapter, you should be able to:
Distinguish monitoring, observability, telemetry, and event management.
Explain the roles of agents, exporters, APIs, collectors, back ends, and dashboards.
Compare metrics, logs, traces, and profiles as observability signals.
Design a practical telemetry pipeline for a cloud-native application.
Describe OpenTelemetry components and instrumentation approaches.
Apply useful principles for dashboard, alert, retention, and cost design.
Evaluate security, privacy, reliability, and governance risks in observability systems.
1. Monitoring, Observability, and Telemetry
Monitoring is the systematic collection and interpretation of data about system behaviour. It normally uses known indicators, thresholds, service-level objectives, and alerts. For example, an operations team may monitor HTTP error rate and alert when it exceeds 5% for five minutes.
Observability is a property of a system and its instrumentation. A system is more observable when engineers can infer its internal state from outputs such as metrics, logs, traces, and profiles. Observability is not simply the quantity of data collected. High-volume, poorly structured data may make diagnosis harder and increase cost.
Telemetry is data emitted by a system for remote measurement. Telemetry can be generated by an application, operating system, container runtime, cloud service, network device, or managed platform. A telemetry pipeline moves this data from sources to destinations where it can be queried and acted upon.
A useful architecture separates five logical stages:
Production: applications and infrastructure generate signals.
Collection: agents, SDKs, APIs, or collectors receive signals.
Processing: data is enriched, filtered, sampled, transformed, or redacted.
Storage and analysis: a metrics store, log platform, trace back end, or data lake indexes the data.
Presentation and action: dashboards, alerts, tickets, automation, and incident processes use the results.
These stages may be supplied by one cloud provider or assembled from multiple tools. Separating the stages reduces vendor dependence and makes it easier to apply consistent security and cost controls.
2. The Observability Signals
2.1 Metrics
A metric is a numerical measurement recorded over time. Examples include request count, request duration, CPU utilization, queue depth, memory usage, and monthly cloud expenditure. Metrics are efficient for aggregation and alerting because they store values rather than complete event details.
Common metric types include:
Type
Meaning
Example
Counter
A value that normally increases and may reset
Total HTTP requests
Gauge
A value that can rise or fall
Current queue depth
Histogram
A distribution represented by buckets or summaries
Request latency
Summary
Quantile-oriented observation, often calculated at the source
Response-time quantiles
A counter should generally be interpreted as a rate over an interval rather than as a raw total. If a counter records 12,000 requests at time t1 and 15,000 at time t2, the average request rate is:
r = (C2 − C1) ÷ (t2 − t1)
Here, C1 and C2 are counter values and time is measured in the same unit at both observations. For the example, if the interval is 60 seconds, r = (15000 − 12000) ÷ 60 = 50 requests per second. This calculation assumes the counter did not reset during the interval. Production monitoring systems must detect resets.
Metric labels, also called dimensions or attributes, enable filtering by service, region, status code, or environment. Excessive label cardinality is dangerous. A label containing a unique user ID, request ID, or timestamp can create millions of time series, increasing memory, storage, and query cost. Stable, bounded labels are preferable.
2.2 Logs
A log is a time-stamped record of an event or message. Logs are useful for detailed context: an authorization decision, a deployment event, an exception stack trace, or a database query failure. Structured logs, usually represented as JSON, are more useful than unstructured text because fields can be searched and correlated consistently.
A sound log record commonly contains a timestamp, severity, service name, environment, message, trace identifier when available, and relevant contextual attributes. Sensitive data such as passwords, access tokens, payment-card data, and unnecessary personal information must not be logged.
Logs have high expressive power but are often expensive to ingest and index. Teams should define useful severity levels, eliminate repetitive messages, sample successful high-volume events where appropriate, and retain security or audit records according to policy.
2.3 Traces and Spans
A distributed trace represents the path of one operation through multiple components. A trace consists of spans. Each span describes a timed unit of work, such as an HTTP request, database call, queue operation, or external API call. Parent-child relationships show causal structure.
A trace normally includes a trace ID, span ID, parent span ID, start time, duration, service identity, operation name, status, and attributes. Trace context can be propagated through HTTP headers, messaging metadata, or other supported protocols. Correct propagation allows an engineer to move from a front-end request to a slow downstream database call.
The approximate duration of a parent span is not necessarily the sum of all child spans. Parallel child operations overlap, and some work may occur outside explicitly instrumented spans. Therefore, traces should be interpreted as a causal and temporal model rather than a simple accounting ledger.
2.4 Profiles and Events
A profile samples resource consumption inside a running process, such as CPU time, memory allocation, lock contention, or goroutine/thread activity. Profiling is especially useful when metrics indicate high resource use but traces do not identify the internal cause.
Events are discrete occurrences such as deployments, autoscaling actions, configuration changes, security findings, and cloud-provider status changes. Events provide change context and can explain why a previously healthy service became unhealthy.
The signals complement one another. Metrics reveal that latency increased, traces identify the affected dependency, logs provide detailed error context, profiles reveal inefficient code, and events may show that a new version was deployed immediately before the incident.
3. Telemetry Pipeline Architecture
A practical telemetry architecture can be represented as follows:
Telemetry pipeline from sources through collection and processing to storage, visualization, and action
Figure: Telemetry pipeline from sources through collection and processing to storage, visualization, and action
Figure: Logical stages of a telemetry pipeline.
Sources and Instrumentation
Instrumentation may be automatic, manual, or infrastructure-based. An application library can create spans and metrics through an SDK. An agent can read operating-system statistics and local log files. A cloud API can expose managed database or load-balancer metrics. Instrumentation should identify the service, version, deployment environment, and region consistently.
Agents, Exporters, and APIs
An agent is a process running near a workload that collects local telemetry. Agents are useful for host metrics, log files, and node-level data. An exporter converts or sends data from one system to another; for example, it may read a database endpoint and expose metrics in a monitoring format. A cloud API supplies provider-managed measurements, billing data, configuration information, or audit events.
Agents provide local access and buffering but consume CPU and memory. APIs reduce the need to install software but may have rate limits, delayed measurements, incomplete dimensions, or provider-specific semantics. A sound design documents each source, collection interval, timestamp behaviour, failure mode, and ownership boundary.
Collectors and Processing
A collector is a service that receives telemetry, processes it, and exports it to one or more destinations. Processing may include:
adding environment, region, cluster, or team attributes;
normalizing names and units;
removing sensitive fields;
filtering low-value records;
batching and compressing data;
sampling traces;
routing security data to a separate protected destination; and
buffering during temporary back-end failure.
Collector placement is an architectural decision. A node-level collector can receive local signals efficiently. A gateway collector can centralize policy, routing, and credentials. Larger environments commonly use both: local collection followed by gateway processing.
Storage and Query
Metrics databases are optimized for time-series aggregation. Log platforms are optimized for indexed event search. Trace stores support retrieval by trace ID, service, operation, duration, and status. Object storage or data lakes may hold lower-cost long-term archives, but they usually provide slower interactive investigation.
A retention policy should reflect operational value, legal requirements, investigation needs, and cost. Hot, searchable data can have a short retention period, while compressed archives may be retained longer. Retention must not be used to avoid defining deletion responsibilities.
4. OpenTelemetry Fundamentals
OpenTelemetry (OTel) is a vendor-neutral, open-source framework and specification for generating, collecting, and exporting telemetry. It is not itself a storage or visualization product. Its purpose is to provide common APIs, SDKs, semantic conventions, protocols, and collector components so that instrumentation can be connected to different back ends.
Important OpenTelemetry concepts include:
API: interfaces used by application code to create or access telemetry.
SDK: language-specific implementation providing processing, sampling, and export.
Instrumentation library: code that observes a framework or library such as an HTTP server or database client.
Resource: attributes describing the entity producing telemetry, such as service name, version, host, or container.
Span: one timed operation within a trace.
Context propagation: transfer of trace and related context across process or service boundaries.
Exporter: component that sends telemetry to a destination or protocol endpoint.
Collector: independent service with receivers, processors, exporters, and pipelines.
Automatic instrumentation can provide broad coverage quickly, but it may use generic operation names or miss business meaning. Manual instrumentation can create spans such as “calculate-invoice” or “reserve-stock,” but excessive custom instrumentation increases maintenance and cardinality risk. A professional implementation combines both and reviews the resulting data.
The OpenTelemetry Protocol (OTLP) is a standard protocol for transporting telemetry. A collector pipeline may have a receiver for OTLP, processors for batching and filtering, and exporters for a metrics, logs, or traces back end. The exact deployment and supported features vary by language, collector version, and vendor; designs should therefore verify compatibility rather than assume that every component supports every signal equally.
5. Dashboards, Service Levels, and Alerting
A dashboard is a decision-support interface, not merely a collection of attractive charts. A service dashboard should answer: Is the service available? Is it meeting user expectations? What is changing? Which dependency is responsible? What action should an operator take?
Useful dashboard layers include:
Executive or portfolio view: availability, major incidents, service-level performance, and cost trends.
Service view: request rate, error rate, latency, saturation, dependency health, and deployment markers.
Investigation view: logs, traces, exemplars, distributions, and detailed dimensions.
The four golden signals are latency, traffic, errors, and saturation. They provide a practical starting point, but teams should adapt them to the service. A batch-processing system may emphasize backlog age and completion time; a financial system may emphasize transaction correctness and reconciliation failures.
A service-level indicator (SLI) is a measured aspect of service performance, such as successful request proportion. A service-level objective (SLO) is the target value, such as 99.9% successful requests over a defined period. An error budget is the tolerated unreliability implied by the SLO. If the SLO is 99.9%, the error-budget fraction is:
B = 1 − S
where S is the SLO expressed as a fraction and B is the permitted failure fraction. Thus, S = 0.999 gives B = 0.001, or 0.1%. The interpretation depends on the precise SLI definition and measurement window.
Alerts should be actionable, sufficiently specific, and connected to a runbook. Alerting on every unusual value produces fatigue. Multi-window or burn-rate alerts can detect both rapid severe failures and slower degradation, but their design requires clear SLO definitions and tested query logic. A dashboard may support exploration without generating an alert; not every visible anomaly requires immediate human action.
6. Cost-Aware Observability
Observability itself is a cloud workload. Costs can arise from data generation, network transfer, processing, indexed storage, query execution, dashboards, and alert evaluations. The highest-cost design is not always the one with the most data; it is often the one that stores high-cardinality, low-value data in an expensive indexed tier.
Practical controls include:
define the questions that telemetry must answer before collecting it;
use metrics for high-volume trends and traces for representative transaction detail;
sample successful traces more aggressively than failures when appropriate;
preserve complete error traces and important audit events when policy requires;
monitor telemetry volume and cost as first-class metrics; and
assign ownership using service, team, environment, and cost-centre attributes.
Sampling must be evaluated carefully. Head sampling decides near the start of a trace and may discard a trace before its eventual error is known. Tail sampling waits for more information and can retain slow or failed traces, but it requires buffering and more collector resources. Sampling changes the interpretation of counts and rates; dashboards must clearly distinguish sampled observations from complete populations.
An illustrative retailer runs a web application on containers. The application uses a payment service, product database, cache, and message queue. The company has experienced intermittent checkout failures and unexpectedly high telemetry charges.
Problem
The existing design sends verbose application logs from every container to a centralized indexed platform. Metrics use customer ID and request ID as labels. Traces are generated by some services but context is not propagated through the queue. During incidents, engineers can see that checkout latency is high but cannot identify whether the database, payment provider, or queue is responsible.
Analysis
The team first defines the customer transaction: a checkout is successful when an order is accepted and a valid payment result is recorded. It identifies the principal SLI as the proportion of eligible checkout requests that complete successfully within a specified time limit. It then inventories signals and discovers three major problems:
unbounded metric cardinality caused by customer and request labels;
high-volume debug logs with little operational value; and
broken trace continuity across asynchronous messaging.
Approach and Solution
The team removes customer ID and request ID from metric labels. Request IDs remain in structured logs and traces, where they are used for individual investigations rather than creating time-series dimensions. It retains bounded labels such as service, region, environment, and outcome.
Each service adopts a common resource model and OpenTelemetry instrumentation. HTTP and database libraries receive automatic instrumentation, while manual spans are added around checkout, payment authorization, and order publication. Trace context is injected into queue messages and extracted by consumers.
A gateway collector receives OTLP data, adds deployment metadata, removes sensitive fields, batches records, and applies tail sampling. Failed and slow checkout traces are retained at a higher rate than successful traces. Debug logs are disabled by default in production; warning and error logs remain searchable. Metrics are stored in a time-series back end, while long-term logs are moved to lower-cost archive storage.
Dashboards are reorganized around customer journeys and the four golden signals. Deployment events are displayed alongside latency and error charts. Alerts are linked to runbooks that explain how to inspect traces, queue age, payment responses, and database saturation.
Outcome
The redesigned system allows engineers to follow a checkout request across synchronous and asynchronous components. Metric ingestion becomes more predictable because cardinality is bounded. Storage cost declines because low-value logs and unnecessary indexed dimensions are reduced. The organization also gains a clearer separation between operational telemetry, security audit data, and archived records.
Learning Points
The case demonstrates that observability quality depends on context and design, not volume alone. Consistent identity, trace propagation, bounded dimensions, appropriate sampling, and clear service objectives provide more operational value than indiscriminate collection. Cost optimization must preserve evidence required for reliability, security, and compliance.
8. Reliability, Security, and Governance
Telemetry pipelines must be reliable enough to support incidents but must not become a single point of failure for the application. Asynchronous queues, local buffering, back-pressure, retry limits, and bounded memory can prevent a failing observability back end from overwhelming workloads. Applications should normally continue operating when telemetry export is unavailable, although critical audit workflows may require stronger guarantees.
Access to telemetry should follow least privilege. Logs and traces can contain personal data, tokens, internal hostnames, or commercially sensitive information. Encryption in transit and at rest, role-based access control, tenant isolation, audit logging, and retention enforcement are essential. Redaction should occur as close to the source as practical, but it must not be treated as a substitute for preventing sensitive data from being emitted.
Governance should define data ownership, approved destinations, retention periods, deletion procedures, schema conventions, incident access, and cross-border transfer rules. Regulatory obligations vary by jurisdiction and sector. Security audit logs may require immutability and restricted deletion, while ordinary debug logs may have no justification for long retention.
Artificial intelligence can assist with anomaly detection, log summarization, correlation, and suggested root causes. However, AI-generated explanations are hypotheses, not proof. Models may miss rare failures, expose sensitive data through prompts, or create false confidence. Human verification, access controls, traceable evidence, and well-defined escalation remain necessary.
9. Best-Practice Design Method
A diploma-level implementation can use the following sequence:
Map critical user journeys and dependencies.
Define SLIs, SLOs, ownership, and incident responsibilities.
Select signals that answer explicit operational questions.
Establish naming, resource, timestamp, and unit conventions.
Instrument application boundaries and important business operations.
Deploy collectors with buffering, authentication, and failure limits.
Apply filtering, enrichment, redaction, sampling, and routing.
Build dashboards for decisions rather than decoration.
Create actionable alerts with runbooks and escalation paths.
Measure telemetry quality, pipeline health, and observability cost.
Test failure scenarios, collector outages, clock problems, and schema changes.
Review the design after incidents and remove data that no longer provides value.
Important quality indicators include coverage of critical services, percentage of traces with valid context propagation, alert precision, mean time to detect, mean time to restore, query performance, dropped telemetry, and cost per monitored service or transaction. These indicators should be interpreted together; reducing cost by dropping essential error evidence is not a successful optimization.
Challenges and Limitations
No telemetry architecture provides perfect visibility. Clock skew can distort event ordering and span duration. Sampling can hide rare failures. Instrumentation may add CPU, memory, network, and latency overhead. Managed-service metrics may be delayed or aggregated. Different vendors may interpret names, units, status values, or histogram quantiles differently. High-cardinality exploration can be expensive, while overly aggressive filtering can make diagnosis impossible.
Observability also depends on organizational practice. If teams do not own services, maintain runbooks, review alerts, or learn from incidents, sophisticated tooling will not produce reliable operations. Architecture must therefore combine technical controls with clear responsibilities and continuous improvement.
Chapter Summary
Monitoring measures known conditions; observability supports inference about internal system state from emitted evidence. Telemetry pipelines consist of sources, collection, processing, storage, and presentation or action. Metrics are efficient for trends and alerting, logs provide event detail, traces show distributed request paths, profiles expose internal resource behaviour, and events supply change context.
Agents, APIs, SDKs, exporters, and collectors have different placement, compatibility, and failure characteristics. OpenTelemetry provides vendor-neutral APIs, SDKs, semantic conventions, context propagation, OTLP transport, and collector pipelines, but it does not replace a storage or visualization back end. Effective dashboards focus on user journeys, service levels, dependencies, and actionable decisions.
Cost-aware observability controls cardinality, volume, sampling, retention, indexing, and ownership without discarding evidence needed for reliability or compliance. Security, privacy, access control, redaction, encryption, and governance are fundamental design requirements. The strongest architecture is not the one that collects everything; it is the one that produces trustworthy, relevant, secure, and economically sustainable evidence.
Key Terms
Telemetry: Data emitted for remote measurement of system behaviour.
Monitoring: Collection and evaluation of predefined system indicators.
Observability: The ability to infer internal system state from external outputs.
Metric: A numerical measurement recorded over time.
Counter: A normally increasing metric that may reset.
Gauge: A metric whose value can increase or decrease.
Histogram: A representation of the distribution of observed values.
Log: A time-stamped record of an event or message.
Trace: A representation of one operation across distributed components.
Span: A timed, causally related unit within a trace.
Context propagation: Transfer of trace identity across process or service boundaries.
Cardinality: The number of distinct combinations of metric label values.
Agent: A nearby process that collects telemetry from a workload or host.
Collector: A service that receives, processes, and exports telemetry.
Exporter: A component that sends telemetry to another system.
OpenTelemetry: A vendor-neutral framework for generating and collecting telemetry.
SLI: A measured indicator of service performance.
SLO: A target value for a service-level indicator.
Sampling: Selecting a subset of telemetry for retention or analysis.
Error budget: The unreliability permitted by an SLO over a defined period.
Review Questions
Short Answer Questions
What is the principal difference between monitoring and observability?
Why can high-cardinality metric labels increase cost and reduce performance?
Name the three principal observability signals and state one use for each.
What is the role of a collector in a telemetry pipeline?
Why is trace-context propagation important in distributed systems?
Long Answer Questions
Explain the stages of a telemetry pipeline from signal production to operational action.
Compare agents, cloud APIs, SDKs, and collectors in terms of placement, advantages, and limitations.
Explain how OpenTelemetry supports vendor-neutral observability architecture.
Discuss how dashboards, SLIs, SLOs, and alerts should work together.
Design a cost-aware observability strategy for a containerized application.
Analytical / Application Questions
A service has rising latency but normal CPU utilization. Explain how you would use metrics, traces, logs, events, and profiles to investigate.
A team adds customer ID and timestamp as metric labels. Analyze the likely consequences and propose a safer design.
Design a telemetry architecture for an asynchronous order-processing system, including collection, context propagation, sampling, storage, security, and failure handling.
Multiple Choice Questions with Answers
Question 1
Which statement best describes observability?
A. The ability to infer internal system state from emitted outputs
B. The practice of installing only host monitoring agents
C. A method of replacing all logs with metrics
D. A guarantee that every system failure will be predicted
Correct Answer: A. The ability to infer internal system state from emitted outputs
Question 2
Which metric type normally increases over time and may reset?
A. Gauge
B. Counter
C. Histogram
D. Profile
Correct Answer: B. Counter
Question 3
A counter rises from 12,000 to 15,000 over 60 seconds. What is the average rate?
A. 5 requests per second
B. 20 requests per second
C. 50 requests per second
D. 180,000 requests per second
Correct Answer: C. 50 requests per second
Question 4
What is a major risk of using customer ID as a metric label?
A. It prevents metrics from having timestamps
B. It creates excessive cardinality and cost
C. It automatically encrypts the metric
D. It converts the metric into a log
Correct Answer: B. It creates excessive cardinality and cost
Question 5
What does a distributed trace primarily represent?
A. The monthly cost of a cloud account
B. The path of one operation across components
C. The average CPU capacity of a region
D. A list of all system users
Correct Answer: B. The path of one operation across components
Question 6
Which OpenTelemetry component receives, processes, and exports telemetry?
A. Collector
B. Dashboard widget
C. Firewall rule
D. Database index only
Correct Answer: A. Collector
Question 7
Which signal is most directly designed to show the causal path and timing of a request across services?
A. Trace
B. Gauge
C. Billing invoice
D. Static configuration file
Correct Answer: A. Trace
Question 8
If an SLO is 99.9%, what is the permitted unreliability fraction under the basic error-budget definition?
A. 0.001, or 0.1%
B. 0.01, or 1%
C. 0.099, or 9.9%
D. 0.999, or 99.9%
Correct Answer: A. 0.001, or 0.1%
Question 9
Which action is generally most appropriate for reducing unnecessary telemetry cost?
A. Add unique request IDs to every metric label
B. Index every debug message permanently
C. Use bounded labels and apply suitable filtering and sampling
D. Delete all error traces immediately
Correct Answer: C. Use bounded labels and apply suitable filtering and sampling
Question 10
Why is trace-context propagation through a message queue useful?
A. It allows related asynchronous work to be correlated with the originating trace
B. It guarantees that messages will never be delayed
C. It converts queue messages into infrastructure metrics
D. It removes the need for authentication
Correct Answer: A. It allows related asynchronous work to be correlated with the originating trace
Cloud Resource Monitoring and Cost Optimization
Chapter 3
of 14