Skip to main content

HTTP metrics

Every Containers scope records HTTP metrics (requests per minute, response time, error rate, and healthchecks) so you can see how it performs. Nullplatform publishes them to the provider you use, like Prometheus or Datadog.

How metrics are recorded​

By default, every application pod runs an nginx container next to your application, called the traffic manager. It receives the scope's HTTP traffic and records each request. The logs-controller DaemonSet then publishes those metrics to your provider.

This works with any ingress, which is why it's the default.

Get metrics from Istio​

If your scopes are exposed through the Istio gateway, Istio already sees every request. Turn on the gateway's telemetry, and the scope's metrics come straight from Istio:

  • Smaller pods: each pod runs only your application, so it uses less CPU and memory
  • Same metrics: same names, labels, and providers, with no metrics lost
  • No extra infrastructure: the logs-controller you already run reads the gateway logs

You choose per scope. Scopes that use Istio metrics and scopes that use the traffic manager run side by side in the same cluster, and requests are never counted twice.

What changes with Istio metrics​

Without the traffic manager, a few things are measured or handled at the gateway:

  • Response time: measured at the gateway, so it includes the hop from the gateway to the pod
  • Response size: the size the gateway sends, without nginx gzip compression
  • Healthcheck metrics: generated from the pod's readiness status, with a response time of 0 ms
  • Proxy limits: body size and timeouts are the gateway's

When the traffic manager is required​

Istio metrics need the scope's traffic to go through the Istio gateway. Otherwise, the traffic manager is required, and a deployment set to use Istio fails with an explanatory error:

CaseWhy
Scopes exposed through a load balancer Ingress, like ALBTraffic reaches the pods directly, without going through Istio
Scopes on ARO clusters (GATEWAY_TYPE=aro_cluster)Traffic goes through OpenShift Routes, not the Istio gateway
Scopes with TRAFFIC_MANAGER_CONFIG_MAP setThe ConfigMap customizes the traffic manager

Turn on Istio metrics​

Follow these steps to turn on the Istio gateway telemetry and get a Containers scope's HTTP metrics from it.

Prerequisites​

  • Scopes exposed through the Istio gateway (HTTPRoute ingress)
  • nullplatform-base chart 2.45.0 or later
  • k8s-logs-controller 1.8.0 or later
  • Containers scope (nullplatform/scopes) 1.21.0 or later
  • An agent whose np CLI is version 2.6 or later
  • kubectl access to the cluster

1. Protect the namespaces​

Skip this step if your nullplatform-base chart is 2.43.1 or later. Older charts create the gateways namespace, and sometimes nullplatform and nullplatform-tools, without a keep policy. The next upgrade deletes them with everything inside, like the gateways, the load balancer, and the certificates, and these steps upgrade the chart.

List the namespaces the release created:

helm -n nullplatform-tools get manifest nullplatform-base | grep -A3 'kind: Namespace' | grep 'name:'

Then annotate each one so the upgrade keeps it:

kubectl annotate namespace <namespace> helm.sh/resource-policy=keep --overwrite

If the gateways namespace was already deleted, see Recover a deleted gateways namespace.

2. Turn on the gateway access logs​

Two pieces need it: istiod must know the np-gateway-access-log provider, which defines the access log format, and the logs-controller must read the gateway logs.

note

The versions below are the minimum that support Istio metrics. If you already run a later one, keep yours. Replace <istio-version> with the Istio version installed in your cluster.

Set these variables and apply:

module "istio" {
source = "git::https://github.com/nullplatform/tofu-modules.git//infrastructure/commons/istio?ref=v9.19.0"
# ...
gateway_access_log_enabled = true
}

module "base" {
source = "git::https://github.com/nullplatform/tofu-modules.git//nullplatform/base?ref=v9.19.0"
# ...
nullplatform_base_helm_version = "2.45.0"
logging_controller_image_tag = "v1.8.0"
logging_istio_access_logs_enabled = true
}

3. Check the cluster​

Confirm that each gateway has a Telemetry and that the logs-controller reads the gateway logs:

# One Telemetry per gateway
kubectl get telemetry -n gateways

# The logs-controller reads the gateway logs
kubectl -n nullplatform-tools get ds nullplatform-log-controller \
-o jsonpath='{.spec.template.spec.containers[0].env[?(@.name=="ISTIO_ACCESS_LOGS_ENABLED")].value}'

You should see np-gateway-access-log-gateway-public (and np-gateway-access-log-gateway-private if you have a private gateway), and true.

4. Set the scope to use Istio metrics​

Create a scope configuration for the scope, or for the namespace, account, or organization that contains it:

{
"deployment": {
"traffic_proxy": "istio"
}
}

If the scope configuration form doesn't show a traffic_proxy setting, add it to the specification first.

To make Istio metrics the default for every scope an agent handles, set the TRAFFIC_PROXY=istio environment variable on the agent instead. A scope configuration takes precedence over it.

5. Deploy the scope​

Start a new deployment. The change goes out with the scope's regular deployment strategy.

6. Check the scope​

Confirm that the new pods run without the traffic manager. Replace <namespace> with the scope's Kubernetes namespace, which is nullplatform by default:

kubectl get pods -n <namespace> -l scope_id=<scope-id> \
-o custom-columns=NAME:.metadata.name,CONTAINERS:.spec.containers[*].name,PROXY:.metadata.labels.traffic_proxy

Each pod runs only the application container and has the traffic_proxy=istio label. Send traffic to the scope and check its metrics in the scope's Performance tab.

Roll back​

Set traffic_proxy to nginx and deploy again. The scope goes back to recording metrics with the traffic manager.

Recover a deleted gateways namespace​

  1. Recreate the namespace and gateways:

    helm -n nullplatform-tools upgrade nullplatform-base nullplatform/nullplatform-base --version <current-version> --reuse-values
  2. Recreate the certificates:

    helm -n cert-manager upgrade cert-manager-config nullplatform/nullplatform-cert-manager-config --version <current-version> --reuse-values
  3. The load balancer comes back with a new hostname. Point the scopes' DNSEndpoint objects (kubectl get dnsendpoint -A) at the new gateway address. Scope domains don't respond until you do.

    kubectl get gateway gateway-public -n gateways -o jsonpath='{.status.addresses[0].value}'

Next steps​