PTP Metrics Exporter¶
Overview
The PTP Metrics Exporter is packaged as a system application and is managed using the system application and system helm-override commands.
The application runs as a Kubernetes DaemonSet, deploying one pod per labelled
node. Each pod collects PTP synchronization statistics from ptp4l (via
the read-only UDS socket), and from phc2sys and ts2phc (via their
monitoring sockets), and exposes them in OpenMetrics format for consumption by
monitoring tools such as Prometheus.
For in-cluster access, for example from Prometheus or other monitoring pods, use the Kubernetes service DNS name:
ptp-metrics-exporter.ptp-metrics-exporter.svc.cluster.local:9110
This headless service (clusterIP: None) resolves directly to the pod IPs
of the exporter DaemonSet on each node. Individual pods can also be reached
via their host IP or pod IP on port 9110.
Prerequisites
Before applying the application, PTP instance configuration files must exist
at /etc/linuxptp/ptpinstance/ in the following format:
ptp4l-<instance>.conf— containsuds_ro_addressin[global]phc2sys-<instance>.conf— containsmon_socket_pathin[global]ts2phc-<instance>.conf— containsmon_socket_pathin[global]
For examples of configuring PTP instances, see Example PTP Instance Configurations.
Procedure
Apply the node label to each target node so that the DaemonSet schedules a pod on the node.
~(keystone_admin)]$ system host-label-assign <hostname> ptp-metrics-exporter=enabled
Upload and apply the application.
~(keystone_admin)]$ system application-upload ptp-metrics-exporter-<version>.tgz ~(keystone_admin)]$ system application-apply ptp-metrics-exporter
Configuration Parameters¶
The exporter is configured through Helm chart values. Overrides can be applied using the system helm-override-update command.
Parameter |
Default |
Description |
|---|---|---|
|
|
The frequency, in seconds, for polling |
|
|
The frequency, in seconds, for polling the |
|
|
The frequency, in seconds, for polling the |
|
|
Frequency at which disabled data sources (for example,
|
|
|
Comma-separated clock classes considered “locked” for |
|
|
Log verbosity ( |
|
|
TCP port for the metrics HTTP endpoint. |
|
|
Node label selector for DaemonSet scheduling. |
|
|
CPU request. |
|
|
CPU limit. |
|
|
Memory request. |
|
|
Memory limit. |
The following example overrides the ptp4l collection interval.
~(keystone_admin)]$ system helm-override-update ptp-metrics-exporter \
ptp-metrics-exporter ptp-metrics-exporter \
--set exporter.collectionIntervalPtp4lSeconds=2
Re-apply the application for the override to take effect.
~(keystone_admin)]$ system application-apply ptp-metrics-exporter
Architecture Overview¶
The exporter runs as a DaemonSet with one pod per labelled node. Each pod:
Watches
/host/etc/linuxptp/ptpinstance/for configuration file changes (inotify).For each discovered
ptp4linstance, polls viaSOCK_DGRAMUDS at the configured interval.For each
phc2sysorts2phcinstance, connects to the monitoring socket (SOCK_STREAM, JSON protocol).Stores collected data in an in-memory snapshot, rather than collecting on-demand per HTTP request.
Serves
/metricsfrom the snapshot, so HTTP serving never blocks on collection.
The pod uses the following volume mounts.
Container Path |
Host Path |
Mode |
Purpose |
|---|---|---|---|
|
|
RW |
UDS sockets (the exporter creates a reply socket for |
|
|
RO |
|
|
|
RO |
Configuration watcher (inotify). |
|
emptyDir (memory-backed, 32Mi) |
RW |
Python temporary files. |
The exporter runs with the following security context:
Runs as non-root (UID 65534 /
nobody).Read-only root filesystem.
All Linux capabilities dropped.
No privilege escalation.
Results
The application is applied and the exporter pods are running on the labelled
nodes. For the API reference describing the /metrics, /healthz, and
/readyz endpoints and the full set of exported metrics, see the
PTP Metrics Exporter API reference.
Troubleshooting Exporter Pods¶
Exporter Pods Fail to Schedule
Verify that the node label is present.
~(keystone_admin)]$ system host-label-list <hostname> | grep ptp-metrics-exporter
Add the label to the node if it is missing.
~(keystone_admin)]$ system host-label-assign <hostname> ptp-metrics-exporter=enabled
Metrics returning NaN
ptp4lnot running or UDS socket missing: verify that/var/run/ptp4l-<instance>-roexists on the host.phc2sysorts2phcnot patched: verify thatmon_socket_pathis present in the daemon configuration and that the socket file exists.summary_intervalnot configured or set to0: stability metrics (ptp_offset_rms_ns,ptp_offset_mean_ns,ptp_offset_stddev_ns) report NaN because no meaningful aggregation occurs with a single sample.
Collection errors increasing
Check the ptp_exporter_source_state metric:
0(unknown) — probe pending; it is attempted at the nextnpProbeIntervalSecondsboundary.1(enabled) — source healthy and being collected.2(disabled) — source returned an error on probe. It is re-probed periodically. Verify that the daemon is running and that the socket exists.
Pod CrashLoopBackOff
Check the pod logs.
~(keystone_admin)]$ kubectl -n ptp-metrics-exporter logs -l app=ptp-metrics-exporter
Verifying the metrics endpoint manually
From the host, query the endpoints directly.
~(keystone_admin)]$ curl http://<pod-ip>:9110/metrics
~(keystone_admin)]$ curl http://<pod-ip>:9110/healthz
~(keystone_admin)]$ curl http://<pod-ip>:9110/readyz