-
Notifications
You must be signed in to change notification settings - Fork 327
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
kuma-cp: generate MonitoringAssignment for each Dataplane in a Mesh #532
Conversation
67ae68a
to
f66bcef
Compare
8a07bb1
to
4fd76c3
Compare
Name: "/meshes/demo/dataplanes/backend-02", | ||
Targets: []*observability_proto.MonitoringAssignment_Target{{ | ||
Labels: map[string]string{ | ||
"__address__": "192.168.0.2:1234", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case of multiple targets?
shouldn't metrics path be in target labels also? In proto definition the docs says
// Describes a single target that needs to be monitored.
message Target {
// Labels associated with that particular target.
//
// E.g.,
// `[
// "__address__" : "192.168.0.1:8080",
// "__metrics_path__" : "/metrics"]`,
// "instance" : "backend-01",
// ]`.
map<string, string> labels = 1;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done to meet constraints of Prometheus' file_sd
implementation and custom-sd adapter that is recommended for use by all file_sd
-based sd
s.
More detailed version:
Prometheus
model for allsd
s except forfile_sd
looks like this:// Group is a set of targets with a common label set(production , test, staging etc.). type Group struct { // Targets is a list of targets identified by a label set. Each target is // uniquely identifiable in the group by its address label. Targets []model.LabelSet // Labels is a set of labels that is common across all targets in the group. Labels model.LabelSet // Source is an identifier that describes a group of targets. Source string }
- that is why Kuma's
MonitoringAssignment
was designed to be close that model - however,
file_sd
uses different model for reading data from a fileNotice thatstruct { Targets []string `yaml:"targets"` Labels model.LabelSet `yaml:"labels"` }
Targets
is just a list of addresses rather than a list ofmodel.LabelSet
- because of that mismatch, some form of conversion is unavoidable inside
kuma-prometheus-sd
- the next component that imposes its constraints is custom-sd - adapter that is recommended for use by all
file_sd
-basedsd
s - this adapter is doing conversion from
Prometheus
model intofile_sd
model and it expects thatTargets
has only 1 label -__address__
and the rest of the labels come fromLabels
- so, we need to convert
MonitoringAssignment
into a model that custom-sd expects. It could happen on server side, it could happen on client side. Given that we're trying to minimize amount of logic on the client side, the choice was made in favour of server side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for in-depth explanation. Can you leave the comment in the code with shorter explanation that target should only contain address because it's converted to file_sd eventually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
4fd76c3
to
004597c
Compare
2a7c6b3
to
e36dc44
Compare
004597c
to
255159c
Compare
e36dc44
to
6812f5e
Compare
255159c
to
0514f86
Compare
pkg/mads/generator/assignments.go
Outdated
// MonitoringAssignmentsGenerator knows how to generate MonitoringAssignment | ||
// resources for a given set of Dataplanes. | ||
// | ||
// Beware of the following constrainsts when it comes to integration with Prometheus: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constrainsts
is a misspelling of constraints
(from misspell
)
// Beware of the following constrainsts when it comes to integration with Prometheus: |
0514f86
to
134a3b6
Compare
6812f5e
to
5ca8d69
Compare
134a3b6
to
c6cd4b2
Compare
Summary
MonitoringAssignment
for eachDataplane
in a Mesh