Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add receiver name to route key #3823

Conversation

grobinson-grafana
Copy link
Contributor

This commit adds the receiver name to the route key to reduce the chances of having non unique group keys (#3817). Like the previous version, it does not guarantee the group key is unique, however it does make it collisions less likely to occur.

This commit adds the receiver name to the route key to reduce the
chances of having non unique group keys (prometheus#3817). Like the previous
version, it does not guarantee the group key is unique, however
it does make it collisions less likely to occur.

Signed-off-by: George Robinson <george.robinson@grafana.com>
@gotjosh
Copy link
Member

gotjosh commented Apr 29, 2024

I think this would invalidate the nflog upon a restart 😭 Perhaps we need a way to execute this change a bit more safely if we could migrate the nflog at the same time?

@grobinson-grafana
Copy link
Contributor Author

grobinson-grafana commented Apr 29, 2024

How would it be invalidated? I'm not sure I am following. The state key is currently derived as follows:

func receiverKey(r *pb.Receiver) string {
	return fmt.Sprintf("%s/%s/%d", r.GroupName, r.Integration, r.Idx)
}

// stateKey returns a string key for a log entry consisting of the group key
// and receiver.
func stateKey(k string, r *pb.Receiver) string {
	return fmt.Sprintf("%s:%s", k, receiverKey(r))
}

so adding the receiver name to the group key would only invalid the nflog if it was changed, much the same as if you changed the matchers.

Looking at the protobuf definition, the receiver name is actually already included:

type Receiver struct {
	// Configured name of the receiver group.
	GroupName string `protobuf:"bytes,1,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"`
	...
}
func receiverKey(r *pb.Receiver) string {
	return fmt.Sprintf("%s/%s/%d", r.GroupName, r.Integration, r.Idx)
}

@grobinson-grafana grobinson-grafana marked this pull request as draft April 29, 2024 10:54
@grobinson-grafana
Copy link
Contributor Author

I spoke to @gotjosh and realized that if we want to do this, we need to migrate existing nflogs so we don't break them on first boot. We will come back to this problem at a later date.

@grobinson-grafana grobinson-grafana deleted the grobinson/add-receiver-to-route-key branch June 25, 2024 15:59
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.

None yet

2 participants