Tutorial: Monitor Apache running on Kubernetes

Tutorial: Monitor Apache running on Kubernetes.

Requirements: Helm, Minikube or any Kubernetes cluster.

1. Deploy Apache deployment, service and configMap.

The trickiest part for monitoring Apache on Kubernetes was to enable Apache status module.
To achieve this I have used configMap that includes modstatus which is required for monitoring Apache. Here is the snipped:

<Location /server-status>
    SetHandler server-status
    Order allow,deny
    Allow from all

mod_status is an Apache module that helps to monitor web server load and current httpd connections with an HTML interface that can be accessed via a web browser.

The below command creates the apache namespace and applies the manifest file which is generated from the bitnami apache helm chart. The manifest file contains deployments, services and configmap.

kubectl create ns apache
kubectl apply -f https://raw.githubusercontent.com/greenszpila/apache/master/manifest.yaml -n apache

Verify if the Apache resources have been deployed successfully:

kubectl get all -n apache
kubectl get cm -n apache

2. Deploy newrelic infrastructure monitoring for Apache:

  • Create my-values.yaml file that should contain the below values (please apply the license key accordingly) :
  cluster: apache-test
  licenseKey: REDACTED
  lowDataMode: true
  enabled: true
  enabled: true
  privileged: true
          exec: /var/db/newrelic-infra/nri-discovery-kubernetes --tls --port 10250
            #label.app: apache
            label.app.kubernetes.io/name: apache
      - env:
          METRICS: 1
          REMOTE_MONITORING: true
          STATUS_URL: http://${discovery.ip}:8080/server-status?auto
        name: nri-apache
  • Deploy helm chart based on the above my-values.yaml file.
helm repo add newrelic https://helm-charts.newrelic.com && helm repo update && \
kubectl create namespace newrelic ; 
helm upgrade --install newrelic-bundle newrelic/nri-bundle -f my-values.yaml -n newrelic

3. Verify the installation.

  • Execute this command to confirm if the apache-config.yaml configuration appears in the configMap:
kubectl describe cm newrelic-bundle-nrk8s-integrations-cfg -n newrelic
  • Check the agent logs:
kubectl logs newrelic-bundle-nrk8s-kubelet-xxxxx -c agent -n newrelic | grep nri-apache

time="2022-06-07T17:57:21Z" level=info msg="Integration health check finished
with success" component=integrations.runner.Runner integration_name=nri-apache
  • If there are no errors, you should see Apache data in the Infrastructure UI. To find the Apache dashboards, go to one.newrelic.com > Infrastructure > Third party services , and select the Apache dashboard.

  • You can also verify it with the below NRQL query:

SELECT uniqueCount(entity.name) as 'Servers' FROM Metric  WHERE metricName ='apache.server.net.requestsPerSecond' facet host.fullHostname