Skip to content

feat(cluster): persistant peer names#4636

Merged
SuperQ merged 1 commit intoprometheus:mainfrom
siavashs:feat/peer-config-improvements
Oct 28, 2025
Merged

feat(cluster): persistant peer names#4636
SuperQ merged 1 commit intoprometheus:mainfrom
siavashs:feat/peer-config-improvements

Conversation

@siavashs
Copy link
Contributor

@siavashs siavashs commented Oct 28, 2025

Currently the default behaviour is to generate a new, random peer name on every startup.
It might be desired to have a persistent peer name in consistent setups like running the cluster on bare-metal nodes.

This change adds an optional cli arg that allows specifying a custom peer name.
If no peer name is specified a random name is generated.

Duplicated peer names are detected, logged and increment the new metric alertmanager_cluster_peer_name_conflicts_total.

@TheMeier
Copy link
Contributor

Maybe add at least one testcase in cluster/cluster_test.go that does pass something else then "" as name arg into Create() ?

@siavashs siavashs force-pushed the feat/peer-config-improvements branch from 016908b to 3c8cc0a Compare October 28, 2025 13:59
@siavashs siavashs changed the title Some peer config improvements feat(cluster): readable/persistant peer names Oct 28, 2025
@siavashs siavashs force-pushed the feat/peer-config-improvements branch from 3c8cc0a to c69793b Compare October 28, 2025 14:01
@siavashs
Copy link
Contributor Author

siavashs commented Oct 28, 2025

Maybe add at least one testcase in cluster/cluster_test.go that does pass something else then "" as name arg into Create() ?

Updated, also implemented readable random names 🙂
Removed the peer host resolution for now, will do it in a separate PR.

@siavashs siavashs force-pushed the feat/peer-config-improvements branch from c69793b to 6b4f5b0 Compare October 28, 2025 14:04
@siavashs siavashs force-pushed the feat/peer-config-improvements branch from 6b4f5b0 to 4c50924 Compare October 28, 2025 15:16
@siavashs siavashs requested a review from SuperQ October 28, 2025 15:16
@siavashs siavashs force-pushed the feat/peer-config-improvements branch 2 times, most recently from 648aed4 to 714f25d Compare October 28, 2025 16:14
@siavashs siavashs changed the title feat(cluster): readable/persistant peer names feat(cluster): persistant peer names Oct 28, 2025
Currently the default behaviour is to generate a new, random peer name
on every startup.
It might be desired to have a persistent peer name in consistent setups
like running the cluster on bare-metal nodes.

This change adds an optional cli arg that allows specifying a custom
peer name.
If no peer name is specified a random name is generated.

Duplicated peer names are detected, logged and increment the new metric
`alertmanager_cluster_peer_name_conflicts_total`.

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
Signed-off-by: Siavash Safi <siavash@cloudflare.com>
@siavashs siavashs force-pushed the feat/peer-config-improvements branch from 714f25d to d741d29 Compare October 28, 2025 16:15
Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This is also very useful for deployments like Kubernetes StatefulSet where we can pass the pod name in as an argument.

@SuperQ SuperQ merged commit 8279d01 into prometheus:main Oct 28, 2025
7 checks passed
@siavashs siavashs deleted the feat/peer-config-improvements branch October 29, 2025 11:12
holger-waschke pushed a commit to holger-waschke/alertmanager that referenced this pull request Nov 1, 2025
Currently the default behaviour is to generate a new, random peer name
on every startup.
It might be desired to have a persistent peer name in consistent setups
like running the cluster on bare-metal nodes.

This change adds an optional cli arg that allows specifying a custom
peer name.
If no peer name is specified a random name is generated.

Duplicated peer names are detected, logged and increment the new metric
`alertmanager_cluster_peer_name_conflicts_total`.

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
Signed-off-by: Siavash Safi <siavash@cloudflare.com>
Co-authored-by: sinkingpoint <colin@quirl.co.nz>
Signed-off-by: Holger Waschke <holger.waschke@dvag.com>
@SoloJacobs SoloJacobs mentioned this pull request Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants