prom-label-proxy icon indicating copy to clipboard operation
prom-label-proxy copied to clipboard

feat: enable multiple label values

Open Kirchen99 opened this issue 2 years ago • 4 comments

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"
            ]
         }
      ]
   }
}

Kirchen99 avatar Jun 17 '22 10:06 Kirchen99

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

Kirchen99 avatar Sep 09 '22 15:09 Kirchen99

Wow, it would be great to have this merged soon!

gasmick avatar Sep 29 '22 09:09 gasmick

Nice useful feature, is there any plan to merge this soon?

bt909 avatar Oct 04 '22 09:10 bt909

@simonpasquier can we expect that this gets merged anytime soon or are there any open issues you see?

kekscode avatar Oct 06 '22 08:10 kekscode

+1

lud97x avatar Oct 17 '22 13:10 lud97x

@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

dbluxo avatar Nov 09 '22 16:11 dbluxo

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.

simonpasquier avatar Dec 02 '22 15:12 simonpasquier

@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 avatar Jan 04 '23 13:01 simonpasquier

@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.

Kirchen99 avatar Jan 05 '23 14:01 Kirchen99

Hey, we would need this to be merged for multi-tenancy support :)

Lucostus avatar Jan 30 '23 12:01 Lucostus

We are looking to use this feature. Any progress?

dzabel avatar Mar 14 '23 10:03 dzabel

Can you give us an update to the progress? We also want to use this feature.

daskanu avatar Mar 28 '23 11:03 daskanu

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.

Kirchen99 avatar Mar 28 '23 11:03 Kirchen99

@simonpasquier Could you review the latest changes please so we could maybe merge that soon? 🙏

dbluxo avatar May 11 '23 08:05 dbluxo

Besides the errors thing, this looks good to merge.

SuperQ avatar Jun 06 '23 08:06 SuperQ

: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.

simonpasquier avatar Jun 12 '23 13:06 simonpasquier

@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 to up{namespace="bar",namespace=~"bar|foo"} and not up{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 avatar Jun 13 '23 09:06 simonpasquier

@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.

Kirchen99 avatar Jun 13 '23 10:06 Kirchen99

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.

simonpasquier avatar Jun 15 '23 07:06 simonpasquier