prom-label-proxy
prom-label-proxy copied to clipboard
feat: enable multiple label values
Signed-off-by: Kirchen99 [email protected]
Solves the issue: https://github.com/prometheus-community/prom-label-proxy/issues/27
Example:
Run prom-label-proxy with following args:
"--insecure-listen-address=127.0.0.1:8080",
"--upstream=http://demo.do.prometheus.io:9090",
"--label=job"
Try to get something with curl
:
curl http://127.0.0.1:8080/api/v1/query\?query\="up"\&job\="grafana"\&job\="random"\&job\="caddy"
See the result:
{
"status":"success",
"data":{
"resultType":"vector",
"result":[
{
"metric":{
"__name__":"up",
"instance":"demo.do.prometheus.io:3000",
"job":"grafana"
},
"value":[
1655460956.224,
"1"
]
},
{
"metric":{
"__name__":"up",
"instance":"demo.do.prometheus.io:8996",
"job":"random"
},
"value":[
1655460956.224,
"1"
]
},
{
"metric":{
"__name__":"up",
"instance":"demo.do.prometheus.io:8997",
"job":"random"
},
"value":[
1655460956.224,
"1"
]
},
{
"metric":{
"__name__":"up",
"instance":"demo.do.prometheus.io:8998",
"job":"random"
},
"value":[
1655460956.224,
"1"
]
},
{
"metric":{
"__name__":"up",
"instance":"demo.do.prometheus.io:8999",
"job":"random"
},
"value":[
1655460956.224,
"1"
]
},
{
"metric":{
"__name__":"up",
"instance":"localhost:2019",
"job":"caddy"
},
"value":[
1655460956.224,
"1"
]
}
]
}
}
I resolved some conversations to make this thread(pull request) easier to read and follow. Please tell me if I'd better not to resolve them. @simonpasquier
Wow, it would be great to have this merged soon!
Nice useful feature, is there any plan to merge this soon?
@simonpasquier can we expect that this gets merged anytime soon or are there any open issues you see?
+1
@simonpasquier doesn't seem to have had time to review this PR further. Would maybe someone else from the maintainers have time to take a look here? @squat @brancz
hey! Sorry for the lag on this PR. I'm putting it at the top of my review list as I'm aware that there's high demand.
@Kirchen99 now that #118 is merged, you'd have to rebase and resolve conflicts. Sorry about that but once it's done, I'll review the PR :)
@Kirchen99 now that #118 is merged, you'd have to rebase and resolve conflicts. Sorry about that but once it's done, I'll review the PR :)
@simonpasquier I have rebased :) Please review.
Hey, we would need this to be merged for multi-tenancy support :)
We are looking to use this feature. Any progress?
Can you give us an update to the progress? We also want to use this feature.
If I understand correctly, the question is how do we deal with the Alertmanager part. In particular, how we deal with Silence. I'm flexible to accept any idea or requirements to change.
@simonpasquier Could you review the latest changes please so we could maybe merge that soon? 🙏
Besides the errors thing, this looks good to merge.
:wave: I'm taking a look at it right now. Since the silences API is problematic with multiple label values, I'd be in favor of declaring that the proxy doesn't support silences in this mode of operations. The main use case of multi-labels is for the Prometheus API anyway so not supporting the Alertmanager API isn't a blocker IMHO.
I'm going to push some commits on top of your PR to implement this.
@Kirchen99 I've added a couple of commits on top of your work. The main changes are
- Any call to the Alertmanager Silences endpoints with multi label values configured returns
422 Unprocessable Entity
(https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422). - When multi label values are configured, the proxy won't replace the existing matchers. E.g. when you query
up{namespace="bar"}
, the proxy should translate toup{namespace="bar",namespace=~"bar|foo"}
and notup{namespace=~"bar|foo"}
. - The same applies to the Alertmanager's Alerts and Alert groups API.
Regarding the last 2 points, I don't remember if we already discussed it in this PR but IMHO this is what makes most sense compared to dropping the existing matcher unilaterally.
My changes are https://github.com/prometheus-community/prom-label-proxy/pull/115/files/8472eba307611d1f2cf9181e70e3319ecbb90976..4882a18523e612324514b1f5ff8c7f8c465e71cc. Happy to hear your feedback.
@simonpasquier Thank you for your commits and the detailed explanation of the changes. I like your Idea on the last 2 points and really appreciate your work and the improvements you've made. The changes look good to me, and I'm excited to see them being merged.
Thanks again @Kirchen99 for your tenacity :tada: and sorry it took so long to review... I'll cut a new release either today or tomorrow.