Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Hubble: observe, measure and audit network flows

By updated

Improve this page

Hubble, Cilium's network observation tool, lets you find a flow refused by a NetworkPolicy with hubble observe --verdict DROPPED, count the refusals Pod by Pod with the hubble_drop_total metric, and record them in a node file for audit. This lesson follows a concrete case: an API protected by a NetworkPolicy, three clients, and one of them no longer gets a response without anyone knowing which. It is aimed at readers who have already installed Cilium without kube-proxy and want to diagnose and audit network refusals without lifting the policy.

What you will learn

  • Find with hubble observe the flow that a NetworkPolicy refuses, thanks to its DROPPED verdict
  • Bound the search with --since and query the agent of the right node
  • Enable the drop metric with a Pod context so that it names the refused Pod
  • Export only the refused flows, if needed from a single namespace, to a node log
  • Tell a policy refusal from a network loss from its reason

Prerequisites

You have read Cilium: install without kube-proxy and choose your IPAM and Network Policies: you know what a Cilium agent is and what an ingress NetworkPolicy does.

The outputs of this lesson come from a three-node cluster (net-cp, net-w1, net-w2) under Ubuntu 24.04, with Kubernetes v1.37.2, Helm v4.3.0 and Cilium and Hubble 1.20.4. The Hubble Relay TLS warning is identical with Cilium 1.20.5. As in the Cilium lesson, this cluster runs Kubernetes 1.37, a version that Cilium 1.20.5 does not declare as supported: everything the lesson shows works on it.

This cluster is the lab's: Hubble, its relay and its metrics are already enabled there by the Helm values of the next section. The installation of the Cilium lesson does not set these values.

What does Hubble see, and where do you read its results?

Each Cilium agent embeds Hubble and observes the flows of the Pods on its node, with a verdict for each one, for example forwarded (FORWARDED) or refused (DROPPED). These observations come out through three paths, which the lesson goes through in order: the in-memory buffer that hubble observe reads, metrics exposed on port 9965 of each node, and a log written on the node's disk.

Look at where each arrow goes. A single agent, the one on the node where the policy applies, sees the refusal and distributes it to the three outputs. For an ingress policy, as in this lesson, that is the node of the called Pod. The buffer serves immediate diagnosis, the metric counting over time, the log keeping a trace.

The vitrine Pod calls the api Pod. The Cilium agent of the node hosting the api renders the DROPPED verdict, then writes the flow to three outputs: an in-memory buffer read by hubble observe, metrics on port 9965 including hubble_drop_total, and a node log, the events.log file.     vitrine Pod     calls the api PodCilium agent on the api nodeverdict DROPPEDIn-memory bufferread by hubble observeMetrics on port 9965hubble_drop_total     Node log     events.log
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

In the Cilium 1.20.5 chart, Hubble is enabled by default, but not its relay or its metrics: the lab cluster enables them through Cilium's Helm values. Here are those that concern Hubble before any change (collected with helm get values cilium -n kube-system):

hubble:
enabled: true
metrics:
enabled:
- dns
- drop
- tcp
- flow
- port-distribution
- icmp
- httpV2
relay:
enabled: true

The relay (relay) gathers the flows of all nodes; this lesson queries the agent of the relevant node directly, the one of the called Pod for the ingress refusal it studies.

How do you find the flow that a NetworkPolicy refuses?

The case: in the magasin namespace, the api API runs on net-w1, and three clients, vitrine, panier and compta, call it in a loop from net-w2. A NetworkPolicy, api-entrant, protects the API. One of the clients complains that it no longer receives a response, and the security team asks you not to lift the policy but to audit the refusal.

Which rule applies?

The NetworkPolicy only lets into port 80 of the API the Pods that carry the acces-api: autorise label. Here is its spec, collected with kubectl -n magasin get networkpolicy api-entrant -o yaml:

spec:
ingress:
- from:
- podSelector:
matchLabels:
acces-api: autorise
ports:
- port: 80
protocol: TCP
podSelector:
matchLabels:
app: api
policyTypes:
- Ingress

Any client without this label is refused, with no message on the client side: the connection times out. What remains is to find out which one.

Which agent should you query?

An ingress policy applies where the destination Pod lives. You must therefore query the agent of the API's node, here net-w1. An egress policy applies, on the contrary, on the node of the Pod that sends: the refusal is then read on the agent of the source Pod's node, wherever the called Pod is. To find the agent, kubectl -n magasin get pods -o wide gives the API's node, and kubectl -n kube-system get pods -l k8s-app=cilium -o wide gives the Cilium agent of that node.

What do the refusals show?

The command filters on the namespace and on the verdict. The --since 1m option bounds the search to the refusals of the last minute, because Hubble's buffer also keeps flows older than your test, and the refused client may have changed since. --last 5 limits the display.

Terminal window
kubectl -n kube-system exec <agent-of-net-w1> -c cilium-agent -- \
hubble observe --namespace magasin --verdict DROPPED --since 1m --last 5
Nov 15 16:45:38.222: magasin/vitrine:45098 (ID:6605) <> magasin/api:80 (ID:1504) policy-verdict:none INGRESS DENIED (TCP Flags: SYN)
Nov 15 16:45:38.222: magasin/vitrine:45098 (ID:6605) <> magasin/api:80 (ID:1504) Policy denied DROPPED (TCP Flags: SYN)
Nov 15 16:45:39.284: magasin/vitrine:45098 (ID:6605) <> magasin/api:80 (ID:1504) policy-verdict:none INGRESS DENIED (TCP Flags: SYN)
Nov 15 16:45:39.284: magasin/vitrine:45098 (ID:6605) <> magasin/api:80 (ID:1504) Policy denied DROPPED (TCP Flags: SYN)

Read each line from left to right: the source Pod is magasin/vitrine, the called Pod magasin/api on port 80, and (ID:6605) and (ID:1504) are Cilium's security identities, computed from the Pods' labels. Each refusal appears on two lines: policy-verdict:none INGRESS DENIED says that no ingress rule allows this flow, then Policy denied DROPPED says that the packet was dropped.

The two lines repeat about one second apart: the client retries its connection, and each attempt is a SYN packet, the first packet of a TCP connection, which never gets a response. The refused client is therefore vitrine.

How do you read the exact reason for the refusal?

With -o json, Hubble gives the reason as a field, which reappears in the metrics and in the log. Here are the useful lines of the output:

Terminal window
kubectl -n kube-system exec <agent-of-net-w1> -c cilium-agent -- \
hubble observe --namespace magasin --verdict DROPPED --since 1m --last 1 -o json
"verdict": "DROPPED",
"drop_reason": 133,
"pod_name": "vitrine"
"pod_name": "api"
"drop_reason_desc": "POLICY_DENIED",

The field to remember is drop_reason_desc: POLICY_DENIED designates a policy refusal, and this is the reason the lab asks you to record with the source Pod's name.

How do you count refusals with metrics?

Hubble exposes its metrics on port 9965 of each agent. The hubble_drop_total metric counts dropped packets. By default, with the drop value, its series carry the reason and the protocol, not the Pod: they say that something is refused, not who. For them to name the Pod, you give a context to the metric, written in its name: drop:sourceContext=pod;destinationContext=pod adds the source and destination labels.

Writing this list in --set requires quotes and escapes for the semicolon and the commas: write a values file instead, hubble-audit.yaml.

Careful, a file passed with -f replaces a list instead of completing it. The file therefore repeats the whole hubble.metrics.enabled list, with the modified drop. Its export section is used for the next part of the lesson, the refusal log.

hubble:
metrics:
enabled:
- dns
- drop:sourceContext=pod;destinationContext=pod
- tcp
- flow
- port-distribution
- icmp
- httpV2
export:
static:
enabled: true
filePath: /var/run/cilium/hubble/events.log
allowList:
- '{"verdict":["DROPPED"]}'

Apply the file with helm upgrade, keeping the other values (--reuse-values) and pinning the chart version. The --namespace kube-system option sets the release namespace; without it, Helm takes the namespace of the current kubectl context.

Terminal window
helm upgrade cilium cilium/cilium --version 1.20.5 --namespace kube-system \
--reuse-values -f hubble-audit.yaml
Release "cilium" has been upgraded. Happy Helming!
NAME: cilium
STATUS: deployed
REVISION: 2
DESCRIPTION: Upgrade complete
[...]
WARNINGS:
- WARNING: TLS is not enabled for the Hubble Relay server (hubble.relay.tls.server.enabled=false).
This means Hubble Relay communications may not be encrypted. [...]

REVISION: 2 confirms the update. The TLS warning is normal in this lab: the Hubble relay is not encrypted. On a real cluster, read the Cilium threat model before letting flows travel unencrypted. The agents restart when their configuration changes: wait for them with kubectl -n kube-system rollout status ds/cilium.

Then read the metric on the API's node (its address comes from kubectl get node net-w1.lab -o wide):

Terminal window
curl -s http://10.10.50.15:9965/metrics | grep hubble_drop_total
# HELP hubble_drop_total Number of drops
# TYPE hubble_drop_total counter
hubble_drop_total{destination="",protocol="ICMPv6",reason="UNSUPPORTED_L3_PROTOCOL",source=""} 3
hubble_drop_total{destination="magasin/api",protocol="TCP",reason="POLICY_DENIED",source="magasin/vitrine"} 78

The second series names the refusal: source="magasin/vitrine", destination="magasin/api", reason="POLICY_DENIED". Its value, 78, is a counter that only goes up as long as the client retries: reading the metric again shortly after gives a larger value, which proves that the refusal is still in place. The first series is another type of loss, explained below.

The other values of the list (dns, tcp, flow, httpV2, port-distribution, icmp) enable other families of metrics on the same port. This lesson only uses drop.

How do you keep a trace of refusals for audit?

Hubble's static export writes the flows into a node file, without you having to query the agent. Three values set above configure the export: enabled turns it on, filePath gives the file and allowList only keeps the flows that match a filter. The {"verdict":["DROPPED"]} filter only keeps the refusals.

This filter is the verdict part of those that hubble observe --namespace magasin --verdict DROPPED --print-raw-filters displays under the allowlist key; the --namespace option adds the source Pod or the destination Pod to it. The chart also accepts a denyList, which on the contrary discards the matching flows; this lesson does not use it.

To restrict the log to the refusals of a single namespace, add a filter on the source or destination Pod. Each entry of allowList is a JSON filter, and a namespace is written "<namespace>/" in source_pod or destination_pod. The fields of one entry combine (AND), and the entries add up (OR). To keep the refusals of a namespace in both directions, write two entries that repeat the verdict, in place of the single entry of the hubble-audit.yaml file:

hubble:
export:
static:
enabled: true
filePath: /var/run/cilium/hubble/events.log
allowList:
- '{"verdict":["DROPPED"],"source_pod":["paiement/"]}'
- '{"verdict":["DROPPED"],"destination_pod":["paiement/"]}'

The first entry keeps the refusals sent by the Pods of the paiement namespace, the second those that target them. Other verdicts and the refusals of other namespaces no longer enter the file. The filter syntax is described in the Cilium documentation on Hubble export.

Each node writes its own file. Read the one on the API's node: the last two lines are enough.

Terminal window
kubectl -n kube-system exec <agent-of-net-w1> -c cilium-agent -- \
tail -2 /var/run/cilium/hubble/events.log

Each line is a JSON document. Here is the first one, abridged to the useful fields:

{"flow":{"time":"2026-11-15T16:47:11.445414992Z", [...] "verdict":"DROPPED","drop_reason":133, [...] "source":{"identity":6605,"namespace":"magasin","labels":["k8s:acces-api=en-attente", [...] "k8s:role=client"],"pod_name":"vitrine"},"destination":{"identity":1504,"namespace":"magasin", [...] "pod_name":"api"}, [...] "traffic_direction":"INGRESS","drop_reason_desc":"POLICY_DENIED","Summary":"TCP Flags: SYN"}, [...]

The log answers three audit questions: when (time), who is refused (source.pod_name and its labels) and why (drop_reason_desc). Here, vitrine carries the acces-api=en-attente label instead of the acces-api=autorise that the NetworkPolicy requires, which explains the refusal.

The two lines that tail -2 displays describe the same packet (a few microseconds apart, same source port) with a different event_type: they are the policy-verdict and DROPPED lines that hubble observe displayed.

The log contains Pod names, labels and addresses: treat it as sensitive data, and plan to collect it before it is rotated. With the chart's default values, the file is replaced by a new one at 10 MB and five backup files are kept (fileMaxSizeMb and fileMaxBackups): the oldest refusals end up disappearing from the node.

Policy refusal or network loss: how do you tell them apart?

A dropped packet is not always a policy refusal. The reason, read in drop_reason_desc or in the metric's reason label, indicates the cause, and the cause dictates where to look.

Observed reasonWhat it indicatesWhere to look
POLICY_DENIED, with a named source Pod and destination PodA NetworkPolicy or a Cilium policy refuses the flowThe policy that selects the called Pod, and the labels of the calling Pod; for an egress policy, the reverse
UNSUPPORTED_L3_PROTOCOL, protocol="ICMPv6", empty source and destinationA packet whose network-layer protocol is not handled by the agent, here IPv6, which this cluster does not enable: no policy is involvedThe traffic itself (here ICMPv6), not the NetworkPolicy

The two series of the lab's metric illustrate this table: 3 ICMPv6 packets lost with no link to a Pod, and 78 named refusals from vitrine to api. Other reasons exist, which this lesson does not show; the approach stays the same: read the reason first, then choose where to look.

Troubleshooting

Start by checking that you are querying the right agent and the right time window: these two causes are the first to rule out when facing an empty or misleading output.

SymptomLikely causeSolution
hubble observe --verdict DROPPED shows nothingWrong agent: an ingress policy is seen on the called Pod's node, an egress policy on the source Pod's nodeQuery the agent of the API's node for an ingress policy, or the agent of the source Pod's node for an egress policy (kubectl get pods -o wide)
The output shows refusals of another clientHubble's buffer also keeps older flowsAdd --since 1m to see only the current refusals
hubble_drop_total carries no filled source or destination for the PodsThe drop metric has no contextWrite drop:sourceContext=pod;destinationContext=pod in the list
After helm upgrade, some metrics have disappearedA file passed with -f replaces the hubble.metrics.enabled listRepeat the whole list in the values file
events.log is missing or emptyThe export is not enabled, the agents have not restarted yet, or you are reading another node's fileRe-read helm get values, wait for rollout status ds/cilium, read the API's node
helm upgrade warns that TLS is not enabled on the relayExpected behavior in this labEnable TLS on a real cluster

Put it into practice

The lab places you on net-cp, with the Cilium cluster and the api-entrant NetworkPolicy already in place. You find the refused client and the reason for the refusal that Hubble gives, you record these two pieces of information in a constat ConfigMap, then you enable the metric's Pod context and the refusal export, without lifting the policy. The validation checks three requirements: the ConfigMap names the right Pod and the right reason, hubble_drop_total names this Pod as the source and still increases, and the node's events.log file exists and contains only DROPPED flows.

The module's challenge, done alone and without hints, has its own page: Find the refused flows.

Key points

  • Each Cilium agent observes the flows of the Pods on its node; an ingress policy is read on the agent of the called Pod's node, an egress policy on the source Pod's.
  • hubble observe --verdict DROPPED --since 1m isolates the current refusals; the reason is read in drop_reason_desc, here POLICY_DENIED.
  • Without a context, hubble_drop_total does not name the Pod; drop:sourceContext=pod;destinationContext=pod adds source and destination.
  • A values file passed with -f replaces a Helm list: repeat the whole metrics list.
  • The static export with allowList and the {"verdict":["DROPPED"]} filter writes only the refusals to /var/run/cilium/hubble/events.log, one file per node.
  • To limit the log to the refusals of a namespace, add two entries to allowList: one with source_pod, the other with destination_pod, each in the "<namespace>/" format and with the verdict.
  • A POLICY_DENIED reason points to a policy; a reason such as UNSUPPORTED_L3_PROTOCOL has nothing to do with it.
  • The log and the metrics reveal who talks to whom: protect them, and encrypt the relay on a real cluster.

Knowledge check

These questions cover reading a refusal with Hubble, its metrics and the flow export.

Knowledge check

Check what you have learned with this interactive quiz

8 questions
6 min
80% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer