Skip to content

missing offset metrics in the kernel and prometheus node exporter #2202

Open

Description

@anarcat

We monitor our servers with the Prometheus node exporter which provides a node_timex_offset_seconds metric, itself derived from the kernel's timex.offset field (see timex.h).

As far as I can tell, ntpsec and timesyncd update that field, but neither does chrony or ntpd-rs. Or at least the node exporter systematically report this field as being zero. I'm not sure what value that should be since this is of course server-dependent (at least as far as I understand it), but i'm pretty sure the offset is never zero.

Here is, for example, the output of ntp-ctl on my home server:

anarcat@marcos:~$ ntp-ctl  status
Synchronization status:
Dispersion: 0.000947s, Delay: 0.029867s
Stratum: 5

Sources:
ntpd-rs.pool.ntp.org:123/51.161.47.242:123 (1): -0.000387±0.001606(±0.044428)s
    poll interval: 256s, missing polls: 0
    root dispersion: 0.000015s, root delay:0.000015s
ntpd-rs.pool.ntp.org:123/216.128.178.20:123 (2): +0.002955±0.002456(±0.030494)s
    poll interval: 1024s, missing polls: 0
    root dispersion: 0.008835s, root delay:0.019379s
ntpd-rs.pool.ntp.org:123/208.81.1.244:123 (3): +0.009297±0.001234(±0.050555)s
    poll interval: 1024s, missing polls: 0
    root dispersion: 0.023193s, root delay:0.033997s
ntpd-rs.pool.ntp.org:123/167.160.187.12:123 (4): +0.002160±0.001569(±0.028479)s
    poll interval: 1024s, missing polls: 0
    root dispersion: 0.000763s, root delay:0.001389s

Servers:

here, i think the "offset" should be 0.000947s, or about 947µs. But I don't actually know: this interface in the linux kernel is not well documented, to say the least...

Is it possible that ntpd-rs is not reporting those numbers correctly to the linux kernel?

In our case, we have the following alerts we use to monitor for clock errors on our servers (which currently never fire, when using ntpsec). we worry that one of those alert would stop working and fail to detect certain error conditions:

  - alert: HostClockSkew
    expr: ((node_timex_offset_seconds > 0.05 and deriv(node_timex_offset_seconds[5m]) >= 0) or (node_timex_offset_seconds < -0.05 and deriv(node_timex_offset_seconds[5m]) <= 0)) * on(instance) group_left (nodename) node_uname_info{nodename=~".+"}
    for: 15m
    labels:
      severity: warning
    annotations:
      summary: "Host clock skew on {{ $labels.alias }}"
      description: |
        The kernel's clock is skewed by more than 0.05s ({{ $value | humanizeDuration }})
        and continuing to drift. Ensure NTP is configured correctly on {{ $labels.alias }}.
      playbook: "https://gitlab.torproject.org/tpo/tpa/team/-/wikis/howto/incident-response#host-clock-desynchronized"

  - alert: HostClockNotSynchronizing
    expr: (min_over_time(node_timex_sync_status[1m]) == 0 and node_timex_maxerror_seconds >= 16) * on(instance) group_left (nodename) node_uname_info{nodename=~".+"}
    for: 15m
    labels:
      severity: warning
    annotations:
      summary: "NTP is failing to synchronize the host clock on {{ $labels.alias }}"
      description: |
        Clock not synchronising. Ensure NTP is configured and running properly on {{ $labels.alias }}.
      playbook: "https://gitlab.torproject.org/tpo/tpa/team/-/wikis/howto/incident-response#host-clock-desynchronized"

we've reviewed ntp-rs as a replacement for timesyncd and ntpsec (and also compared it with chrony), and it seems pretty darn good, by the way! see my comment in here : https://gitlab.torproject.org/tpo/tpa/team/-/issues/41936#note_3394545

Activity

  1. robbat2 commented on Apr 26, 2026

    @robbat2

    @anarcat

    1. Have you also reported this to Chrony?
    2. systemd-timesyncd seems to ALSO get the values wrong

    node_timex_status also stood out - with ntpsec, it's got a good value: 8193 == 0x2001 ==STA_NANO|STA_PLL map on a GPS+PPS system here; but other implementations report as 0.

    [systemd doesn't support the GPS/PPS - ignore how bad it's results are]

    node_exporter_chrony.txt:node_timex_estimated_error_seconds 2e-06
    node_exporter_chrony.txt:node_timex_frequency_adjustment_ratio 1.000000348098755
    node_exporter_chrony.txt:node_timex_maxerror_seconds 5e-06
    node_exporter_chrony.txt:node_timex_offset_seconds 0
    node_exporter_chrony.txt:node_timex_status 0
    node_exporter_chrony.txt:node_timex_sync_status 1
    node_exporter_ntpd-rs.txt:node_timex_estimated_error_seconds 7.1e-05
    node_exporter_ntpd-rs.txt:node_timex_frequency_adjustment_ratio 1.0000036436767579
    node_exporter_ntpd-rs.txt:node_timex_maxerror_seconds 0.0005
    node_exporter_ntpd-rs.txt:node_timex_offset_seconds 0
    node_exporter_ntpd-rs.txt:node_timex_status 0
    node_exporter_ntpd-rs.txt:node_timex_sync_status 1
    node_exporter_ntpsec.txt:node_timex_estimated_error_seconds 4.6e-05
    node_exporter_ntpsec.txt:node_timex_frequency_adjustment_ratio 0.9999985538482666
    node_exporter_ntpsec.txt:node_timex_maxerror_seconds 0.0015
    node_exporter_ntpsec.txt:node_timex_offset_seconds 2.5087e-05
    node_exporter_ntpsec.txt:node_timex_status 8193
    node_exporter_ntpsec.txt:node_timex_sync_status 1
    node_exporter_systemd-timesyncd.txt:node_timex_estimated_error_seconds 0.001955
    node_exporter_systemd-timesyncd.txt:node_timex_frequency_adjustment_ratio 1.000007434387207
    node_exporter_systemd-timesyncd.txt:node_timex_maxerror_seconds 0.075215
    node_exporter_systemd-timesyncd.txt:node_timex_offset_seconds 0
    node_exporter_systemd-timesyncd.txt:node_timex_status 0
    node_exporter_systemd-timesyncd.txt:node_timex_sync_status 1
    
    
  2. anarcat commented on Apr 26, 2026

    @anarcat
    Author
    1. Have you also reported this to Chrony?

    i have not. we're switching from timesyncd and ntpsec to ntpd-rs, chrony was only used in my personal lab and i already switched a couple of months ago, so i didn't intend to file it there (but i guess i could as well, not being a user anymore feels less legit).

    1. systemd-timesyncd seems to ALSO get the values wrong

    i am not surprised. in our experience, it gets a couple of things wrong, as i showed in the aforementioned issue: https://gitlab.torproject.org/tpo/tpa/team/-/work_items/41936#note_3394545 namely:

    • it doesn't report node_timex_estimated_error_seconds at all
    • it has huge jitter in the node_timex_maxerror_seconds metrics

    what that actually means in term of time accuracy is tricky to determine since those metrics are self-reported, i am not sure how one is supposed to actually measure that, but i leave that to your capable hands. :)

  3. removed their assignment
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions