Configuring Apache Exporter with Prometheus in Kubernetes (Minikube)

Published: (February 23, 2026 at 11:53 PM EST)
4 min read
Source: Dev.to

Source: Dev.to

Lab Objectives

By completing this lab, you will:

  • Deploy Apache in Kubernetes
  • Deploy Apache Exporter
  • Deploy Prometheus
  • Configure Prometheus to scrape Apache metrics
  • Generate load and observe real‑time metrics
  • Clean up the environment

Lab Prerequisites

Ensure the following are installed:

  • Docker
  • kubectl
  • Minikube
  • Git
  • curl

Verify installation:

kubectl version --client
minikube version
docker --version

Lab 1 – Start Kubernetes Environment

1. Start Minikube

minikube start --driver=docker

Verify the cluster:

kubectl get nodes

2. Create Namespace

kubectl create namespace monitoring

Set the default namespace:

kubectl config set-context --current --namespace=monitoring

Verify:

kubectl get ns

Lab 2 – Deploy Apache Web Server

1. Create Apache Deployment

Create file apache-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: apache
spec:
  replicas: 1
  selector:
    matchLabels:
      app: apache
  template:
    metadata:
      labels:
        app: apache
    spec:
      containers:
      - name: apache
        image: httpd:2.4
        ports:
        - containerPort: 80

Apply the manifest:

kubectl apply -f apache-deployment.yaml

2. Expose Apache Service

Create file apache-service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: apache-service
spec:
  selector:
    app: apache
  ports:
    - port: 80
      targetPort: 80

Apply the manifest:

kubectl apply -f apache-service.yaml

Verify:

kubectl get pods
kubectl get svc

Lab 3 – Deploy Apache Exporter

We will use the official Apache Exporter image: quay.io/prometheuscommunity/apache-exporter

1. Create Exporter Deployment

Create file apache-exporter.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: apache-exporter
spec:
  replicas: 1
  selector:
    matchLabels:
      app: apache-exporter
  template:
    metadata:
      labels:
        app: apache-exporter
    spec:
      containers:
      - name: apache-exporter
        image: quay.io/prometheuscommunity/apache-exporter
        args:
          - --scrape_uri=http://apache-service/server-status?auto
        ports:
        - containerPort: 9117

Apply the manifest:

kubectl apply -f apache-exporter.yaml

2. Create Exporter Service

Create file apache-exporter-service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: apache-exporter-service
spec:
  selector:
    app: apache-exporter
  ports:
    - port: 9117
      targetPort: 9117

Apply the manifest:

kubectl apply -f apache-exporter-service.yaml

Verify:

kubectl get pods
kubectl get svc

Lab 4 – Deploy Prometheus

1. Create Prometheus ConfigMap

Create file prometheus-config.yaml:

apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-config
data:
  prometheus.yml: |
    global:
      scrape_interval: 5s

    scrape_configs:
      - job_name: 'apache-exporter'
        static_configs:
          - targets: ['apache-exporter-service:9117']

Apply the manifest:

kubectl apply -f prometheus-config.yaml

2. Create Prometheus Deployment

Create file prometheus-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: prometheus
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prometheus
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      containers:
      - name: prometheus
        image: prom/prometheus
        ports:
        - containerPort: 9090
        volumeMounts:
        - name: config-volume
          mountPath: /etc/prometheus/
      volumes:
      - name: config-volume
        configMap:
          name: prometheus-config

Apply the manifest:

kubectl apply -f prometheus-deployment.yaml

3. Expose Prometheus

kubectl expose deployment prometheus --type=NodePort --port=9090

Check the service:

kubectl get svc

Lab 5 – Verify Exporter Metrics

1. Port‑Forward Exporter

kubectl port-forward svc/apache-exporter-service 9117:9117

2. Test Metrics

In another terminal:

curl http://localhost:9117/metrics

You should see metrics such as:

apache_up
apache_workers
apache_scoreboard

Lab 6 – Access Prometheus UI

1. Get Prometheus URL

minikube service prometheus

Open the displayed URL in a browser and explore the metrics scraped from the Apache Exporter.

2. Port‑Forward Prometheus

kubectl port-forward svc/prometheus 9090:9090

Open the browser:

http://localhost:9090

3. Verify Target

In the Prometheus UI go to Status → Targets and ensure:

apache-exporter = UP

4. Query Metrics

Try the following queries:

apache_up

or

apache_workers

Lab 7 – Generate Load (Apache Benchmark)

Use Apache Benchmark (ab) to simulate traffic.

If ab is installed locally

ab -n 1000 -c 50 http://$(minikube service apache-service --url)/

Or port‑forward Apache

kubectl port-forward svc/apache-service 8080:80

Then run:

ab -n 1000 -c 50 http://localhost:8080/

Observe Metrics in Prometheus

Watch the following metrics while the load test runs:

apache_workers
apache_scoreboard
apache_cpu_load

You should see real‑time metric changes.

Lab 8 – Troubleshooting

Check pod logs

kubectl logs deployment/apache-exporter
kubectl logs deployment/prometheus

Verify endpoints

kubectl get endpoints

Check Prometheus configuration

kubectl describe configmap prometheus-config

Lab 9 – Cleanup Environment

Delete the monitoring namespace

kubectl delete namespace monitoring

Stop Minikube

minikube stop

(Optional) Full cleanup

minikube delete

Lab Summary

You have successfully:

  • Deployed Apache in Kubernetes
  • Deployed Apache Exporter
  • Configured Prometheus
  • Verified metric scraping
  • Generated load and observed real‑time metrics
  • Cleaned up the environment
0 views
Back to Blog

Related posts

Read more »

DevOps and Vibe Coding: A Journey

Things to Do Map Your Application - Map your application on paper, in a spreadsheet, or using graphics/flowcharts. This is the first step. - Understanding the...

OpenAI just raised $110 billion. Wow

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as we...