DEV Community

BAKRE JAMIU
BAKRE JAMIU

Posted on

Building an End-to-End Cloud-Native Microservice Observability Platform: My Platform Engineering Capstone 2

Introduction

As part of my platform engineering learning journey, I recently completed my second capstone project: building a cloud-native microservices observability platform.

This project was an opportunity to bring together several technologies and engineering practices that are essential in modern cloud-native environments.

Rather than focusing only on deploying an application, I wanted to build a platform that could support the application throughout its lifecycle: from containerization and orchestration to monitoring, centralized logging, distributed tracing, alerting, automation, security scanning, and operational troubleshooting.

The central question behind the project was:

How can we deploy a microservices application on Kubernetes and build the observability and operational capabilities needed to understand, monitor, troubleshoot, and maintain it?

To answer that question, I designed and implemented a three-service application and integrated it with a complete observability stack.

The project brought together:

  • Docker and Docker Compose
  • Kubernetes and Minikube
  • Helm
  • GitHub
  • Jenkins
  • Argo CD
  • Prometheus
  • Grafana
  • Grafana Loki
  • Grafana Alloy
  • Grafana Tempo
  • OpenTelemetry
  • Alertmanager
  • Ansible
  • Trivy
  • Python and FastAPI

This article documents the project from the initial design through implementation, integration, testing, and validation.

It also explains some of the challenges I encountered, the decisions I made, and what I learned along the way.


1. Understanding the Project Objectives

The first step was to establish what the platform needed to achieve.

A microservices application can be running successfully while still having operational problems that are difficult to identify.

For example:

  • A service may respond slowly.
  • An API may return HTTP errors.
  • A Kubernetes node may become unavailable.
  • Application logs may be scattered across different containers.
  • A request may fail somewhere between multiple services.
  • A container image may contain vulnerable operating-system packages.
  • An engineer may not receive an alert when something goes wrong.

These are operational problems that cannot be addressed through application deployment alone.

I therefore divided the project into several objectives.

Application objectives

  • Build a microservices application.
  • Containerize each service.
  • Expose health-check endpoints.
  • Enable communication between services.

Kubernetes objectives

  • Deploy the services to Kubernetes.
  • Configure Kubernetes Services and Deployments.
  • Apply resource requests and limits.
  • Implement container security controls.
  • Configure readiness and liveness probes.

Observability objectives

  • Collect application and infrastructure metrics.
  • Build Grafana dashboards.
  • Centralize application logs.
  • Implement distributed tracing.
  • Configure operational alerts.
  • Test notification delivery.

Automation and security objectives

  • Create a Jenkins CI pipeline.
  • Validate application images with Ansible.
  • Scan container images with Trivy.
  • Integrate GitOps deployment management.
  • Maintain operational runbooks.

The goal was to bring these capabilities together into one working platform.

[SCREENSHOT 1: Insert a screenshot of your project directory or overall project architecture here.]


2. Designing the Application Architecture

Before implementing the platform, I designed the application around three independent microservices.

The services were:

  1. API Gateway
  2. Order Service
  3. Payment Service

Each service was developed using Python and FastAPI.

2.1 API Gateway

The API Gateway acts as the entry point for incoming application requests.

Instead of allowing an external client to communicate directly with every internal service, requests enter through the API Gateway.

Its responsibilities include:

  • Receiving HTTP requests.
  • Exposing the application API.
  • Coordinating order requests.
  • Communicating with the Order Service.
  • Returning responses to the client.
  • Exposing health and metrics endpoints.

The API Gateway listens on port 8000.

2.2 Order Service

The Order Service handles order creation.

When a client submits an order through the API Gateway, the request is forwarded to the Order Service.

It handles the order-processing operation and communicates with the Payment Service.

The Order Service listens on port 8001.

2.3 Payment Service

The Payment Service handles the payment-processing portion of the workflow.

For this project, payment approval was simulated rather than integrated with a real payment provider.

This allowed me to demonstrate service-to-service communication and end-to-end request tracing without introducing an external payment dependency.

The Payment Service listens on port 8002.

2.4 Understanding the request flow

The application workflow is:

Client
  |
  v
API Gateway
  |
  v
Order Service
  |
  v
Payment Service
  |
  v
Response returned to Client
Enter fullscreen mode Exit fullscreen mode

A client submits an order request to the API Gateway.

The API Gateway communicates with the Order Service, which processes the order and calls the Payment Service.

The Payment Service returns a simulated payment result, and the response travels back through the services.

This simple workflow provides a useful foundation for demonstrating distributed application behaviour.

[SCREENSHOT 2: Insert your application architecture diagram showing API Gateway, Order Service, and Payment Service.]


3. Developing the Microservices with FastAPI

I used FastAPI to implement the three application services.

FastAPI provides a lightweight framework for building HTTP APIs in Python.

Each service has its own application code, dependencies, Dockerfile, and container image.

The services also expose health-check endpoints.

For example:

GET /health
Enter fullscreen mode Exit fullscreen mode

A successful response indicates that the service is available.

The health endpoints are useful for:

  • Docker health checks.
  • Kubernetes readiness probes.
  • Kubernetes liveness probes.
  • CI smoke tests.
  • Operational troubleshooting.

I also introduced application metrics and structured logging so that the services could produce telemetry for the observability platform.

3.1 Application metrics

The services expose Prometheus-compatible metrics.

Some of the application metrics include:

http_requests_total
http_request_duration_seconds
orders_created_total
orders_failed_total
payments_approved_total
payments_declined_total
Enter fullscreen mode Exit fullscreen mode

These metrics provide information about application activity.

For example:

  • http_requests_total tracks HTTP requests.
  • http_request_duration_seconds records request duration.
  • orders_created_total tracks successful order creation.
  • orders_failed_total tracks failed orders.
  • payments_approved_total tracks approved simulated payments.
  • payments_declined_total tracks declined simulated payments.

The metrics are exposed through the /metrics endpoint.

This makes it possible for Prometheus to scrape the application services.

3.2 Structured application logging

I implemented structured JSON logging.

Instead of producing only unstructured text messages, the application logs include fields such as:

{
  "timestamp": "2026-12-02T20:28:37.750873+00:00",
  "level": "INFO",
  "service": "api-gateway",
  "message": "HTTP request completed",
  "method": "GET",
  "route": "/health",
  "status_code": 200,
  "duration_seconds": 0.000741
}
Enter fullscreen mode Exit fullscreen mode

Structured logs are useful because individual fields can be extracted and queried.

For example, an engineer can filter logs by:

  • Service name
  • Log level
  • Timestamp
  • HTTP route
  • Status code
  • Message

This becomes especially valuable when several microservices are running inside Kubernetes.

[SCREENSHOT 3: Insert a screenshot of the application source code showing the health endpoint, metrics instrumentation, or structured JSON logging.]


4. Containerizing the Application with Docker

After developing the services, the next step was containerization.

Docker provides a consistent way to package an application together with its runtime dependencies.

I created an individual Dockerfile for each service:

app/
├── api-gateway/
│   ├── Dockerfile
│   ├── requirements.txt
│   └── app/
├── order-service/
│   ├── Dockerfile
│   ├── requirements.txt
│   └── app/
└── payment-service/
    ├── Dockerfile
    ├── requirements.txt
    └── app/
Enter fullscreen mode Exit fullscreen mode

Each service can therefore be built and managed independently.

4.1 Building the Docker images

The application images were built locally.

The image naming convention was:

observability-api-gateway:1.1
observability-order-service:1.1
observability-payment-service:1.1
Enter fullscreen mode Exit fullscreen mode

Example:

docker build \
  -t observability-api-gateway:1.1 \
  ./app/api-gateway
Enter fullscreen mode Exit fullscreen mode

Repeat the process for the other two services:

docker build \
  -t observability-order-service:1.1 \
  ./app/order-service

docker build \
  -t observability-payment-service:1.1 \
  ./app/payment-service
Enter fullscreen mode Exit fullscreen mode

To inspect the images:

docker images
Enter fullscreen mode Exit fullscreen mode

4.2 Docker image security improvements

I paid attention to container security while building the images.

The application images use a pinned Python 3.12 slim base image.

The Dockerfiles were also updated to perform operating-system package updates and clean up package metadata.

The containers run using a non-root application user rather than running the application as root.

This is important because container security should be considered during image construction, not only after deployment.

4.3 Testing with Docker Compose

Before moving to Kubernetes, I used Docker Compose to validate the application in a containerized environment.

Docker Compose made it possible to start the three services together and verify their communication.

The application containers started successfully and passed their configured health checks.

I also tested the end-to-end order workflow.

A successful request returned HTTP 200, and the payment service returned a simulated approval.

This provided an early validation of the application before introducing Kubernetes.

[SCREENSHOT 4: Insert a terminal screenshot showing docker compose ps with the three application services healthy.]

Useful commands:

docker compose -f docker/docker-compose.yml up -d
Enter fullscreen mode Exit fullscreen mode
docker compose -f docker/docker-compose.yml ps
Enter fullscreen mode Exit fullscreen mode
docker compose -f docker/docker-compose.yml logs
Enter fullscreen mode Exit fullscreen mode

5. Deploying the Application to Kubernetes with Minikube

Once the application was working in Docker, I moved to Kubernetes.

Kubernetes provides orchestration capabilities for containerized applications.

It manages application workloads, service discovery, networking, health checks, and resource allocation.

For this project, I used Minikube to run a local Kubernetes cluster.

Minikube provides a practical environment for learning and validating Kubernetes deployments without requiring a production cloud cluster.

5.1 Creating the namespaces

I separated the application workloads from the observability components using Kubernetes namespaces.

The two main namespaces are:

microservices
observability
Enter fullscreen mode Exit fullscreen mode

The microservices namespace contains:

  • API Gateway
  • Order Service
  • Payment Service

The observability namespace contains the monitoring and telemetry components.

Separating workloads into namespaces makes it easier to organize resources and apply namespace-specific configurations.

5.2 Kubernetes Deployments

I created Kubernetes Deployment manifests for the three services.

Each service was configured with one replica during the project validation.

The deployments define:

  • Container image
  • Container port
  • Environment configuration
  • Resource requests
  • Resource limits
  • Readiness probes
  • Liveness probes
  • Container security context

5.3 Kubernetes Services

I also created Kubernetes Services using the ClusterIP service type.

The services expose the application internally within the cluster.

The ports are:

Service Port
API Gateway 8000
Order Service 8001
Payment Service 8002

The services communicate through Kubernetes internal DNS.

For example, the API Gateway can reach the Order Service through its Kubernetes Service name rather than depending on a hardcoded pod IP address.

This is important because pod IP addresses can change when workloads are recreated.

5.4 Kubernetes health checks

I configured readiness and liveness probes using the application health endpoints.

A readiness probe determines whether a container is ready to receive traffic.

A liveness probe helps Kubernetes determine whether a container should be restarted.

These checks improve workload management and help Kubernetes respond to application health problems.

5.5 Resource requests and limits

I configured CPU and memory requests and limits for the application containers.

The application container configuration included:

resources:
  requests:
    cpu: 100m
    memory: 64Mi
  limits:
    cpu: 500m
    memory: 128Mi
Enter fullscreen mode Exit fullscreen mode

Requests define the resources Kubernetes should account for when scheduling a pod.

Limits define the maximum resource consumption allowed by the container configuration.

I also configured ResourceQuota objects for the application and observability namespaces.

This helps prevent workloads from consuming unlimited cluster resources.

5.6 Kubernetes container security

Security was another important part of the Kubernetes deployment.

The application containers were configured with:

  • Non-root UID/GID 999
  • Read-only root filesystem
  • Privilege escalation disabled
  • All Linux capabilities dropped
  • RuntimeDefault seccomp profile

An example of the container security configuration is:

securityContext:
  runAsNonRoot: true
  runAsUser: 999
  runAsGroup: 999
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop:
      - ALL
Enter fullscreen mode Exit fullscreen mode

The pod security configuration also uses:

seccompProfile:
  type: RuntimeDefault
Enter fullscreen mode Exit fullscreen mode

These settings reduce the privileges available to application containers.

They are not a replacement for a complete security assessment, but they establish important container-hardening controls.

5.7 Validating the Kubernetes deployment

After applying the manifests, I checked the deployments and pods.

kubectl get namespaces
Enter fullscreen mode Exit fullscreen mode
kubectl get deployments -n microservices
Enter fullscreen mode Exit fullscreen mode
kubectl get pods -n microservices
Enter fullscreen mode Exit fullscreen mode
kubectl get services -n microservices
Enter fullscreen mode Exit fullscreen mode

The three application deployments reached their expected ready state.

I also validated the application health endpoints and tested the order workflow through the Kubernetes services.

The complete request successfully traversed the API Gateway, Order Service, and Payment Service.

[SCREENSHOT 5: Insert kubectl get pods -n microservices showing all three application pods running and ready.]

[SCREENSHOT 6: Insert kubectl get services -n microservices showing the three ClusterIP services.]


6. Introducing Helm for Observability Deployment

The observability stack contains multiple components.

Managing all these components manually would make installation and configuration more difficult.

I therefore used Helm.

Helm is a Kubernetes package manager that helps install and manage applications through charts and configurable values files.

For this project, I used Helm to deploy and configure the kube-prometheus-stack and the logging and tracing components.

The kube-prometheus-stack chart provides an integrated monitoring stack that includes components such as:

  • Prometheus
  • Grafana
  • Alertmanager
  • Prometheus Operator
  • Kubernetes monitoring resources

The project also uses Helm configuration for Loki, Alloy, and Tempo.

This allowed me to maintain configuration in version-controlled YAML files instead of relying entirely on manual changes through the Kubernetes dashboard or terminal.

[SCREENSHOT 7: Insert a screenshot of helm list -n observability showing the installed observability releases.]

Useful command:

helm list -n observability
Enter fullscreen mode Exit fullscreen mode

7. Implementing Metrics Collection with Prometheus

Prometheus is the metrics collection and monitoring system used in this project.

Its main responsibility is to collect time-series metrics from the application and Kubernetes environment.

A time-series metric is a measurement associated with a timestamp.

Examples include:

  • CPU usage
  • Memory usage
  • HTTP request counts
  • Request latency
  • Filesystem capacity
  • Pod availability

7.1 Application metrics collection

The three microservices expose Prometheus metrics through their /metrics endpoints.

I configured a Prometheus ServiceMonitor to discover and scrape the application services.

The ServiceMonitor uses the appropriate service labels and selects the application workloads.

The scrape configuration includes:

endpoints:
  - port: http
    path: /metrics
    interval: 15s
Enter fullscreen mode Exit fullscreen mode

The ServiceMonitor selects the application services through their labels.

This allows Prometheus to discover the endpoints through Kubernetes service discovery.

7.2 Verifying metrics collection

I used Prometheus to check whether the application targets were being scraped successfully.

One useful query is:

up{namespace="microservices"}
Enter fullscreen mode Exit fullscreen mode

A value of 1 indicates that Prometheus successfully scraped the target.

During validation, all three application services returned healthy scrape results.

I also checked the application request metrics and histogram metrics.

For example:

http_requests_total
Enter fullscreen mode Exit fullscreen mode

This metric helps track the number of HTTP requests processed by the services.

[SCREENSHOT 8: Insert a Prometheus screenshot showing all three microservice targets as UP.]

[SCREENSHOT 9: Insert a Prometheus query screenshot showing up{namespace="microservices"} returning 1 for all three services.]


8. Building Grafana Dashboards

Prometheus provides metrics, but engineers need a clear way to understand those metrics.

Grafana provides visualization and dashboarding capabilities.

I used Grafana to build three dashboards containing ten panels.

The dashboards cover infrastructure monitoring, service-level performance, and application logs.

8.1 Dashboard 1 — Infrastructure

The Infrastructure dashboard provides visibility into the underlying Kubernetes environment.

It is intended to help an engineer understand the health and resource usage of the cluster.

Infrastructure monitoring is important because application performance can be affected by problems in the environment where the application runs.

For example:

  • High CPU usage can affect application performance.
  • Memory pressure can cause pod instability.
  • Disk exhaustion can affect workloads.
  • Node availability affects scheduling and application availability.

[SCREENSHOT 10: Insert the Infrastructure dashboard showing its panels.]

8.2 Dashboard 2 — Service Overview (RED metrics)

The second dashboard focuses on application service health.

I used the RED monitoring approach.

RED stands for:

  • Rate
  • Errors
  • Duration

These three measurements provide a useful overview of application service behaviour.

Rate

Rate measures how many requests a service processes over time.

Errors

Errors measure the number or proportion of failed requests.

Duration

Duration measures how long requests take to complete.

For request latency, I used a PromQL histogram query to calculate the 99th percentile.

histogram_quantile(
  0.99,
  sum by (le, service) (
    rate(http_request_duration_seconds_bucket[5m])
  )
)
Enter fullscreen mode Exit fullscreen mode

This query calculates the p99 request duration grouped by service.

The p99 is useful because it helps identify slower requests that may not be obvious from average latency.

During validation, the query returned values for the application services.

[SCREENSHOT 11: Insert the Service Overview dashboard showing request rate, error rate, and p99 latency panels.]

8.3 Dashboard 3 — Application Logs

The third dashboard focuses on application logging.

It contains panels for:

  • Application Log Volume
  • Application Error Count
  • Recent Application Errors

The Application Log Volume panel was validated and displayed logs from:

  • API Gateway
  • Order Service
  • Payment Service

The error-related panels were configured, but no matching ERROR events were available in the final selected time range.

This is an important distinction: a configured query is not the same as a query that has been validated against matching data.

I recorded this limitation rather than presenting the error panels as fully validated.

[SCREENSHOT 12: Insert the Application Logs dashboard showing application log volume and the three services.]


9. Centralized Logging with Grafana Loki and Grafana Alloy

One of the major objectives of this project was to centralize application logs.

In a microservices environment, each service produces its own logs.

If an engineer needs to troubleshoot an issue, manually connecting to individual containers or pods becomes inconvenient.

A centralized logging platform makes it possible to search logs from multiple services in one place.

For this project, I used:

  • Grafana Alloy
  • Grafana Loki
  • Grafana

9.1 What is Grafana Alloy?

Grafana Alloy is an observability collector.

It can collect and process telemetry before forwarding it to a backend.

In this project, Alloy collects Kubernetes pod logs and forwards them to Loki.

9.2 What is Grafana Loki?

Loki is the centralized log aggregation system.

It stores log streams and indexes their labels so that engineers can search and filter logs efficiently.

Unlike traditional full-text indexing approaches, Loki is designed around labels and log streams.

9.3 Understanding the logging pipeline

The logging flow is:

API Gateway ───────┐
                   |
Order Service ─────┼──> Kubernetes Pod Logs
                   |             |
Payment Service ───┘             v
                            Grafana Alloy
                                 |
                                 v
                              Grafana Loki
                                 |
                                 v
                               Grafana
Enter fullscreen mode Exit fullscreen mode

Each application writes logs to its container output.

Kubernetes makes these logs available through its pod log files.

Alloy discovers and reads the pod logs, processes the entries, and forwards them to Loki.

Grafana then queries Loki to display the logs.

9.4 Processing structured logs

I configured the Alloy pipeline to process container logs and extract structured JSON fields.

The pipeline includes stages for:

  • Container log processing
  • JSON field extraction
  • Label creation
  • Timestamp processing
  • Forwarding to Loki

The key processing configuration includes:

loki.process "pod_logs" {
  stage.docker {}

  stage.json {
    expressions = {
      timestamp = "timestamp",
      level     = "level",
      service   = "service",
    }
  }

  stage.labels {
    values = {
      level   = "level",
      service = "service",
    }
  }

  stage.timestamp {
    source            = "timestamp"
    format            = "RFC3339Nano"
    action_on_failure = "skip"
  }

  forward_to = [loki.write.default.receiver]
}
Enter fullscreen mode Exit fullscreen mode

This configuration extracts useful information from the JSON logs.

The service and level fields are particularly useful when filtering logs.

9.5 A logging pipeline issue I encountered

During validation, I discovered that the container log processing stage needed to match the actual log format.

The initial pipeline used:

stage.cri {}
Enter fullscreen mode Exit fullscreen mode

I changed the processing stage to:

stage.docker {}
Enter fullscreen mode Exit fullscreen mode

and added explicit JSON parsing.

This was an important troubleshooting exercise because log collection depends on understanding the format of the actual container log files.

After correcting the pipeline and validating the Alloy configuration, logs from the application services were available in Loki.

9.6 Querying logs in Grafana

I used LogQL to query Loki.

A basic query for application logs is:

{namespace="microservices"}
Enter fullscreen mode Exit fullscreen mode

To filter logs by service:

{namespace="microservices", service="api-gateway"}
Enter fullscreen mode Exit fullscreen mode

To filter by log level:

{namespace="microservices"} | json | level="ERROR"
Enter fullscreen mode Exit fullscreen mode

To count ERROR entries by service over a five-minute window:

sum by (service) (
  count_over_time(
    {namespace="microservices"} | json | level="ERROR" [5m]
  )
)
Enter fullscreen mode Exit fullscreen mode

These queries demonstrate how centralized logs can be explored and aggregated.

During the final validation, the general application log query returned entries from the API Gateway, confirming that Loki was receiving and displaying application logs.

The ERROR query returned no matching entries in the selected time range. Therefore, the error panels were recorded as configured but not fully validated against an actual error event.

[SCREENSHOT 13: Insert a Grafana Explore screenshot showing application logs returned by Loki.]

[SCREENSHOT 14: Insert an Alloy configuration screenshot showing the log-processing pipeline.]


10. Distributed Tracing with OpenTelemetry and Grafana Tempo

Metrics tell us how a system is performing.

Logs tell us what happened.

Distributed tracing helps us understand how a request moves through multiple services.

This is especially important in a microservices architecture.

Imagine a request entering the API Gateway, moving to the Order Service, and then reaching the Payment Service.

If the request becomes slow, it may be difficult to identify which service caused the delay using metrics alone.

Distributed tracing helps connect the operations performed by the different services.

10.1 What is OpenTelemetry?

OpenTelemetry is an observability framework for generating, collecting, and exporting telemetry data.

It supports:

  • Traces
  • Metrics
  • Logs

For this project, I used OpenTelemetry instrumentation to generate distributed traces from the application services.

10.2 What is Grafana Tempo?

Grafana Tempo is the distributed tracing backend.

It receives and stores trace data and allows engineers to explore the traces through Grafana.

10.3 Understanding the tracing flow

The tracing pipeline is:

Client Request
      |
      v
  API Gateway
      |
      v
  Order Service
      |
      v
 Payment Service
      |
      v
OpenTelemetry Instrumentation
      |
      v
   OTLP Export
      |
      v
  Grafana Tempo
      |
      v
     Grafana
Enter fullscreen mode Exit fullscreen mode

The application services were configured to export telemetry to Tempo through OTLP gRPC.

10.4 Validating a distributed trace

I generated an order request through the API Gateway and then explored the resulting trace in Grafana Tempo.

I used the following TraceQL query:

{
  resource.service.name = "api-gateway"
  && name = "POST /orders"
}
Enter fullscreen mode Exit fullscreen mode

The query returned a matching trace.

This confirmed that the API Gateway request was being recorded and that Tempo could retrieve it.

[SCREENSHOT 15: Insert a Grafana Tempo Explore screenshot showing the successful POST /orders trace.]

This was one of the most important validations in the project because it demonstrated distributed tracing beyond simply deploying the tracing backend.


11. Configuring Operational Alerts in Grafana

Monitoring becomes more useful when it can notify engineers about conditions that require attention.

A dashboard requires someone to open it and inspect the metrics.

An alerting system can evaluate conditions continuously and notify the responsible team when a threshold is reached.

For this project, I configured five Grafana-managed alert rules.

They cover important application and Kubernetes operational conditions.

11.1 High HTTP Error Rate

This rule monitors the proportion of failed HTTP requests.

The objective is to detect a situation where the application begins returning too many errors.

The configured threshold is greater than 5%, with a pending period of five minutes.

11.2 High p99 Latency

This rule monitors high request latency using the p99 metric.

The purpose is to detect when a significant proportion of requests are taking longer than the expected threshold.

I also tested this alert by temporarily lowering its threshold.

The rule entered a firing state, and an email notification was successfully received.

The original threshold was restored after the test.

11.3 Kubernetes Node Not Ready

This rule monitors Kubernetes node readiness.

A node that becomes unavailable can affect workload scheduling and application availability.

The rule uses a five-minute pending period.

11.4 Low Disk Space

This rule monitors available filesystem capacity.

The configured condition checks whether available space falls below 10%.

The rule was configured and the underlying Prometheus filesystem metrics were inspected.

However, the Grafana alert detail displayed an evaluation value of zero even though the direct Prometheus query showed approximately 90.17% available space.

This discrepancy remains a validation caveat and requires further investigation.

11.5 Excessive Pod Restarts

This rule monitors excessive Kubernetes pod restarts.

Frequent restarts may indicate:

  • Application crashes
  • Configuration problems
  • Resource constraints
  • Dependency failures
  • Runtime instability

The rule was configured to detect excessive restarts over the selected monitoring window.

11.6 Summary of the five rules

Alert rule Purpose
High HTTP Error Rate Detect elevated application errors
High p99 Latency Detect slow application requests
Kubernetes Node Not Ready Detect unavailable Kubernetes nodes
Low Disk Space Detect low filesystem capacity
Excessive Pod Restarts Detect unstable application pods

11.7 Configuring email notifications

I configured Grafana SMTP using Brevo as the SMTP relay provider.

The SMTP credentials were stored in a Kubernetes Secret rather than being placed directly in the configuration file.

The Secret was named:

grafana-smtp-credentials
Enter fullscreen mode Exit fullscreen mode

Grafana loaded the credentials through its environment configuration.

The Helm values referenced the Secret:

grafana:
  envFromSecret: grafana-smtp-credentials
Enter fullscreen mode Exit fullscreen mode

The SMTP settings included:

grafana.ini:
  smtp:
    enabled: true
    host: smtp-relay.brevo.com:587
    user: $__env{GF_SMTP_USER}
    password: $__env{GF_SMTP_PASSWORD}
    from_address: YOUR_VERIFIED_SENDER_ADDRESS
    from_name: Microservices Observability
    startTLS_policy: MandatoryStartTLS
Enter fullscreen mode Exit fullscreen mode

The actual credentials were kept out of the repository.

11.8 Testing notification delivery

I tested the Grafana contact point and confirmed that a test notification was successfully delivered to my email inbox.

I also tested the High p99 Latency alert.

After the alert entered the firing state, Grafana sent an email notification.

The notification included the alert name and affected service instances.

This confirmed the end-to-end notification path:

Prometheus Metrics
       |
       v
Grafana Alert Rule
       |
       v
Grafana Notification Policy
       |
       v
SMTP Contact Point
       |
       v
Email Notification
Enter fullscreen mode Exit fullscreen mode

An important architectural detail is that these project alerts are Grafana-managed rules. They are routed through Grafana notification policies and the Grafana SMTP contact point.

They are not dependent on an Alertmanager-to-email routing configuration.

[SCREENSHOT 16: Insert a screenshot showing all five Grafana alert rules.]

[SCREENSHOT 17: Insert a screenshot of the Grafana notification contact point.]

[SCREENSHOT 18: Insert a screenshot of the successful email notification received in your inbox. Hide private email addresses and sensitive information.]


12. GitOps with Argo CD

Another important part of the project was GitOps.

GitOps is an approach where the desired state of an application or infrastructure is maintained in version control.

Instead of relying entirely on manually applying configuration changes, a GitOps controller continuously compares the desired state with the actual cluster state.

For this project, I used Argo CD.

Argo CD monitors the configured Git repository and manages the Kubernetes application state based on the manifests stored in Git.

The general workflow is:

GitHub Repository
       |
       v
    Argo CD
       |
       v
Kubernetes Cluster
       |
       v
Application Workloads
Enter fullscreen mode Exit fullscreen mode

This approach makes the deployment configuration easier to review and maintain.

It also provides visibility into whether an application is synchronized with the desired Git state.

During project validation, the Argo CD application was observed in a Synced and Healthy state.

[SCREENSHOT 19: Insert your Argo CD application screenshot showing Synced and Healthy.]


13. Building the CI Pipeline with Jenkins

Continuous Integration is another important part of a platform engineering workflow.

I used Jenkins to automate application validation and container image checks.

The project includes a Jenkins pipeline defined in:

Jenkinsfile
Enter fullscreen mode Exit fullscreen mode

The pipeline uses a custom workspace and skips the default checkout because the project workspace is managed separately.

It includes several stages.

13.1 Python compilation

The pipeline performs Python compilation checks to identify syntax errors before proceeding.

13.2 Application health tests

The pipeline runs application health smoke tests.

The tests use FastAPI's testing capabilities and validate the health endpoints of the three services.

The tracing configuration is stubbed during these isolated health tests.

These tests are intended to validate service health endpoints, not the complete business workflow.

13.3 Docker image builds

The pipeline builds the three application Docker images.

This confirms that the Dockerfiles and their dependencies can produce the expected images.

13.4 Ansible image validation

The pipeline runs an Ansible playbook to verify that the expected local Docker images exist.

The playbook uses Docker image inspection.

This is a lightweight validation step that confirms the images are available in the local Docker environment.

It is not a full security or runtime assessment.

13.5 Trivy security scanning

The pipeline uses Trivy to scan the application images for known vulnerabilities.

The purpose is to identify vulnerabilities in the operating-system packages and application dependencies included in the images.

13.6 Image publishing control

Image publishing is controlled through a pipeline parameter.

For the final report-only validation, image publishing was disabled.

This allowed the pipeline to validate the images without publishing them to a registry.

[SCREENSHOT 20: Insert your Jenkins pipeline screenshot showing the stages and successful report-only build.]


14. Container Security Scanning with Trivy

Security scanning was an important part of the project.

A Docker image can build successfully and still contain vulnerable packages.

Trivy helps identify known vulnerabilities in container images.

I used Trivy to scan the three application images.

14.1 Strict security validation

During strict scanning, the images were found to contain:

  • 53 HIGH-severity operating-system findings
  • 0 CRITICAL findings
  • 13 unique CVEs

The findings were associated with Debian operating-system packages in the Python base image.

The Python dependency scan did not report corresponding application dependency findings in the final scan results.

I investigated the findings and compared available base-image options.

An alternative Bookworm image produced more findings, including CRITICAL findings, so it was not selected as an improvement.

I retained the pinned Python 3.12 slim base image and documented the remaining findings.

14.2 Strict mode and report-only mode

The Jenkins pipeline supports strict and report-only scanning behaviour.

In strict mode, HIGH or CRITICAL findings can cause the pipeline to fail.

This behaviour was demonstrated during the project.

A strict scan failed because of the outstanding HIGH-severity findings.

I then ran the pipeline in report-only mode with:

FAIL_ON_TRIVY_HIGH_OR_CRITICAL=false
PUBLISH_IMAGES=false
Enter fullscreen mode Exit fullscreen mode

The report-only pipeline completed successfully.

This distinction is important.

A successful report-only build does not mean the vulnerabilities have disappeared.

It means the pipeline completed while reporting the findings without enforcing the strict failure condition.

14.3 Documenting a narrow exception

The project also includes a Trivy ignore configuration:

.trivyignore.yaml
Enter fullscreen mode Exit fullscreen mode

It contains a narrowly scoped exception for a specific setuptools finding associated with a package detected through the scanner's software bill of materials.

The exception includes an expiry date and a rationale.

It does not suppress the Debian operating-system findings.

This approach is preferable to broadly ignoring vulnerability categories without understanding the underlying result.

[SCREENSHOT 21: Insert a Trivy scan report showing the HIGH and CRITICAL finding counts.]

[SCREENSHOT 22: Insert a Jenkins screenshot showing the strict scan failure and report-only success. Make the difference clear.]


15. Automating Image Validation with Ansible

I also included Ansible in the project.

Ansible is an automation tool that can execute tasks across managed systems.

For this project, I used it for a focused validation task: checking whether the three expected application Docker images existed locally.

The playbook is located at:

ansible/playbooks/validate-images.yml
Enter fullscreen mode Exit fullscreen mode

The playbook checks the expected images using Docker image inspection.

The validation covered:

observability-api-gateway:1.1
observability-order-service:1.1
observability-payment-service:1.1
Enter fullscreen mode Exit fullscreen mode

The validation completed successfully with:

ok=3
changed=0
failed=0
Enter fullscreen mode Exit fullscreen mode

This demonstrated how Ansible can be integrated into a CI pipeline to automate operational checks.

The scope of this playbook is deliberately limited to local image existence validation.

[SCREENSHOT 23: Insert the Ansible playbook execution output showing ok=3, changed=0, and failed=0.]


16. Operational Runbooks

Monitoring and alerting are useful, but engineers also need a documented process for responding to incidents.

I created five operational runbooks.

They are stored in the runbooks/ directory.

16.1 High HTTP Error Rate

runbooks/high-http-error-rate.md
Enter fullscreen mode Exit fullscreen mode

This runbook covers investigation of elevated HTTP error rates.

It provides guidance for checking service health, examining logs, and identifying possible causes of application failures.

16.2 High p99 Latency

runbooks/high-p99-latency.md
Enter fullscreen mode Exit fullscreen mode

This runbook addresses slow application requests.

It guides an engineer through investigating latency metrics, affected services, and potential dependencies.

16.3 Kubernetes Node Not Ready

runbooks/kubernetes-node-not-ready.md
Enter fullscreen mode Exit fullscreen mode

This runbook covers Kubernetes node availability issues.

It helps an engineer investigate node conditions and workload impact.

16.4 Low Disk Space

runbooks/low-disk-space.md
Enter fullscreen mode Exit fullscreen mode

This runbook covers filesystem capacity problems and the operational checks needed to investigate low available disk space.

16.5 Excessive Pod Restarts

runbooks/pod-excessive-restarts.md
Enter fullscreen mode Exit fullscreen mode

This runbook covers unstable pods and repeated container restarts.

It provides a structured starting point for investigating application crashes and Kubernetes workload health.

The runbooks help turn monitoring signals into actionable operational procedures.

[SCREENSHOT 24: Insert a screenshot of the runbooks/ directory showing all five runbooks.]


17. Testing and Validation Strategy

An important part of the project was validating the individual components rather than assuming that successful installation meant everything was working.

I used several validation methods.

17.1 Application validation

The three FastAPI services were tested through their health endpoints.

The project also included an end-to-end order request through the API Gateway.

The request successfully passed through the Order Service and Payment Service.

Payment approval was simulated.

17.2 Kubernetes validation

I checked:

  • Namespace creation
  • Deployment readiness
  • Pod status
  • Service availability
  • Container security settings
  • Resource requests and limits
  • Health probes

17.3 Prometheus validation

I confirmed that the application targets were being scraped.

The following query was useful:

up{namespace="microservices"}
Enter fullscreen mode Exit fullscreen mode

All three application services returned healthy scrape results during validation.

17.4 Grafana validation

I validated the three dashboards and their ten panels.

The infrastructure and service overview dashboards provided the intended monitoring views.

The application log volume panel showed logs from all three services.

The two application error panels remained configured but did not have matching ERROR events in the final validation window.

17.5 Loki validation

I queried Loki using LogQL and confirmed that application logs were available.

The log stream included structured fields such as:

namespace
service
level
pod
container
Enter fullscreen mode Exit fullscreen mode

17.6 Tempo validation

I generated an application request and searched Tempo using TraceQL.

The search returned a matching API Gateway trace for POST /orders.

17.7 Alerting validation

I reviewed the five Grafana-managed alert rules.

I also tested SMTP delivery and triggered the High p99 Latency rule temporarily.

An actual alert email was received.

The Low Disk Space rule retained an evaluation-value discrepancy that requires further investigation.

17.8 CI validation

The Jenkins pipeline completed its report-only validation successfully.

It performed Python compilation, health smoke tests, Docker image builds, Ansible image checks, and Trivy scans.

Image publishing remained disabled during that validation.

[SCREENSHOT 25: Insert a collage or separate screenshots showing Prometheus, Grafana, Loki, Tempo, and Jenkins validation.]


18. Challenges Encountered and How I Addressed Them

Building the platform was not simply a matter of installing software.

Several challenges required investigation and correction.

18.1 Kubernetes resource constraints

Running several observability components alongside application workloads requires sufficient memory and CPU.

I encountered resource pressure while working with the local Minikube environment.

I adjusted the Minikube Docker memory allocation and used resource controls to manage the workloads.

This reinforced the importance of capacity planning, especially when running a full observability stack locally.

18.2 Loki log-processing configuration

One of the more interesting challenges involved container log processing in Alloy.

The initial pipeline used the CRI processing stage.

However, the actual log format required Docker-compatible processing.

I changed the pipeline to use:

stage.docker {}
Enter fullscreen mode Exit fullscreen mode

I also introduced JSON extraction for the timestamp, level, and service fields.

This improved the processing pipeline and allowed structured application log fields to be used in Loki queries.

18.3 Alert notification configuration

Configuring email notifications required more than simply enabling SMTP.

I needed to:

  • Store SMTP credentials securely.
  • Expose the credentials to Grafana.
  • Configure the SMTP relay.
  • Configure a Grafana contact point.
  • Create notification policies.
  • Associate alert rules with the correct routing labels.
  • Test actual email delivery.

The successful test email and High p99 alert email confirmed that the notification path was working.

18.4 Trivy vulnerability findings

The image scans identified multiple HIGH-severity operating-system package findings.

Rather than hiding the results or claiming that the images were vulnerability-free, I investigated the findings and compared available base-image options.

The strict pipeline failure and report-only success also demonstrated why security findings should be handled deliberately in CI.

18.5 Distinguishing configured queries from validated queries

Another lesson came from the application error panels.

A LogQL query can be syntactically correct but return no results if matching events do not exist in the selected time range.

I confirmed that Loki was receiving application logs, but no matching ERROR events were available during the final validation window.

This reinforced an important operational principle:

A successful configuration is not automatically proof of successful functional validation.

18.6 Grafana Low Disk Space evaluation

The Low Disk Space rule exposed another issue.

Direct Prometheus queries showed approximately 90.17% available filesystem capacity, but the Grafana alert detail displayed an evaluation value of zero.

The discrepancy was not treated as a successful alert validation.

It remains an item for further investigation.

These challenges helped make the project more realistic because production engineering involves understanding and resolving problems, not only deploying tools.


19. Final Technology Stack Summary

The completed platform brings together the following technologies.

Technology Role in the project
Python Application development
FastAPI Microservices API framework
Docker Application containerization
Docker Compose Local multi-container validation
Kubernetes Container orchestration
Minikube Local Kubernetes environment
Helm Kubernetes application and observability deployment
GitHub Source code and configuration version control
Jenkins Continuous Integration pipeline
Argo CD GitOps application management
Prometheus Metrics collection
Grafana Dashboards, exploration, and alerting
Loki Centralized log storage and querying
Grafana Alloy Kubernetes log collection and processing
OpenTelemetry Application instrumentation and trace export
Tempo Distributed trace storage and exploration
Alertmanager Component included in the monitoring stack
Brevo SMTP Email relay for Grafana notifications
Ansible Local Docker image validation automation
Trivy Container image vulnerability scanning

20. Project Repository Structure

The repository is organized to separate application code, infrastructure configuration, observability resources, automation, and documentation.

The main structure is:

microservices-observability-platform/
│
├── app/
│   ├── api-gateway/
│   ├── order-service/
│   └── payment-service/
│
├── ansible/
│   ├── ansible.cfg
│   ├── inventory.ini
│   └── playbooks/
│       └── validate-images.yml
│
├── docker/
│   └── docker-compose.yml
│
├── docs/
│   ├── architecture/
│   │   └── architecture.mmd
│   └── evidence/
│       └── application-validation.md
│
├── kubernetes/
│   ├── application/
│   ├── namespaces/
│   └── resources/
│
├── observability/
│   ├── alloy/
│   ├── loki/
│   ├── prometheus/
│   ├── tempo/
│   └── kube-prometheus-stack-values.yaml
│
├── runbooks/
│   ├── high-http-error-rate.md
│   ├── high-p99-latency.md
│   ├── kubernetes-node-not-ready.md
│   ├── low-disk-space.md
│   └── pod-excessive-restarts.md
│
├── tests/
│   └── test_services.py
│
├── .gitignore
├── .trivyignore.yaml
├── Jenkinsfile
├── LICENSE
└── README.md
Enter fullscreen mode Exit fullscreen mode

This structure makes it easier to understand where each component belongs and how the different parts of the platform relate to one another.

[SCREENSHOT 26: Insert a terminal screenshot showing the repository structure.]


21. What I Learned from Capstone 2

This project significantly strengthened my understanding of Platform Engineering.

Some of my most important lessons were:

1. Application deployment is only one part of platform engineering

Getting an application running is important, but engineers also need to consider monitoring, logging, tracing, security, automation, and operational support.

2. Observability requires multiple complementary signals

Metrics, logs, and traces answer different questions.

Prometheus helped me understand system behaviour through metrics.

Loki provided centralized application logs.

Tempo helped me follow requests across the application.

Grafana brought these signals together for exploration and monitoring.

3. Kubernetes requires resource and security awareness

A cluster is not simply a place to run containers.

Workloads need resource requests and limits, health checks, appropriate security contexts, and sensible namespace organization.

4. Automation improves consistency

Jenkins and Ansible helped turn manual validation activities into repeatable pipeline steps.

Argo CD introduced the GitOps approach to application management.

5. Security scanning should influence engineering decisions

Trivy demonstrated that successful image builds do not necessarily mean secure images.

Security findings must be investigated, documented, and handled through a deliberate remediation process.

6. Alerting must be tested end to end

Creating an alert rule is not enough.

The complete notification path must be tested, including evaluation, routing, contact points, SMTP configuration, and actual delivery.

7. Documentation is part of engineering

The runbooks, architecture diagrams, validation evidence, and configuration files make the platform easier to understand, troubleshoot, and maintain.


22. Conclusion

Completing this second Platform Engineering capstone gave me the opportunity to bring several important cloud-native engineering practices together in one project.

I built and containerized a three-service FastAPI application, deployed it to Kubernetes, configured application and infrastructure monitoring, centralized logs, implemented distributed tracing, created Grafana dashboards, configured operational alerts, tested email notifications, introduced Jenkins CI, integrated Ansible validation, and scanned container images with Trivy.

I also worked through real troubleshooting scenarios involving Kubernetes resource constraints, Alloy log processing, Grafana notification configuration, and vulnerability scanning.

The project was a reminder that a platform is more than a collection of tools.

It is the combination of application workloads, infrastructure, automation, observability, security controls, and operational procedures that allows software systems to be deployed and managed reliably.

There are still documented follow-up items, particularly the Grafana Low Disk Space evaluation discrepancy, the outstanding HIGH-severity operating-system package findings, and validation of application error panels using matching ERROR events.

I consider documenting these limitations part of responsible engineering rather than hiding them behind a successful deployment status.

Most importantly, this capstone has helped me connect the concepts I have been learning into a practical end-to-end Platform Engineering implementation.

Capstone 2 completed.


References and Official Documentation

The following resources were useful throughout the project and are also valuable for anyone who wants to explore the technologies further.


Project Links

GitHub Repository: [Insert your public project repository URL]

Project Portfolio: [Insert your portfolio URL]

Author: Jamiu Olatunji Bakre

Project: Platform Engineering — Capstone 2

Top comments (0)