[Feature] Add optional feature to persist IsOnline field to database #1163

Closed
opened 2025-12-29 02:28:40 +01:00 by adam · 1 comment
Owner

Originally created by @nadongjun on GitHub (Dec 1, 2025).

Use case

When operating Headscale, there are many situations where we need to understand when a node became online or offline.

Examples include analyzing unstable connections, reproducing intermittent issues, validating availability over time, or verifying the state at a specific moment.
Without state transition history, these tasks become difficult.

Description

Headscale currently only exposes node state as a single snapshot, and does not provide any history of state transitions.

  • isOnline is memory-based (gorm:"-") and is not persisted.
  • LastSeen only represents the most recent contact time and does not reflect online/offline transitions.

As a result, it is impossible to know:

  • when a node went online or offline,
  • how long a node stayed offline,
  • whether a node repeatedly flapped between states.

This feature does not need to be enabled by default.
It would be very helpful if node status transitions could be recorded and queried as an optional feature.

If needed, I’m willing to contribute to the implementation.

Contribution

  • I can write the design doc for this feature
  • I can contribute this feature

How can it be implemented?

Add an option to persist the isOnline field in the database, and allow users who need history to add their own triggers or a separate history table. In other words, Headscale only stores whether the node is online, and operators can optionally enable history tracking if they want it.

Originally created by @nadongjun on GitHub (Dec 1, 2025). ### Use case When operating Headscale, there are many situations where we need to understand when a node became online or offline. Examples include analyzing unstable connections, reproducing intermittent issues, validating availability over time, or verifying the state at a specific moment. Without state transition history, these tasks become difficult. ### Description Headscale currently only exposes node state as a single snapshot, and does not provide any history of state transitions. - `isOnline` is memory-based (gorm:"-") and is not persisted. - `LastSeen` only represents the most recent contact time and does not reflect online/offline transitions. As a result, it is impossible to know: - when a node went online or offline, - how long a node stayed offline, - whether a node repeatedly flapped between states. This feature does not need to be enabled by default. It would be very helpful if node status transitions could be recorded and queried as an optional feature. If needed, I’m willing to contribute to the implementation. ### Contribution - [ ] I can write the design doc for this feature - [x] I can contribute this feature ### How can it be implemented? Add an option to persist the `isOnline` field in the database, and allow users who need history to add their own triggers or a separate history table. In other words, Headscale only stores whether the node is online, and operators can optionally enable history tracking if they want it.
adam added the enhancement label 2025-12-29 02:28:40 +01:00
adam closed this issue 2025-12-29 02:28:40 +01:00
Author
Owner

@kradalby commented on GitHub (Dec 1, 2025):

No, we removed this due to added complexity, and we are not interested in bringing it back.

@kradalby commented on GitHub (Dec 1, 2025): No, we removed this due to added complexity, and we are not interested in bringing it back.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1163