prometheus-community / PushProx

Proxy to allow Prometheus to scrape through NAT etc.
Apache License 2.0
719 stars 133 forks source link

Add flag to send request to another endpoint instead of the FQDN #102

Closed pcallewaert closed 3 years ago

pcallewaert commented 3 years ago

Hi,

I'll first explain my use case so you better understand why I'm creating this PR.

We are running several edge devices, which have k3s installed and the kube-prometheus-stack. But we have also a prometheus server in the cloud that we want to have a global view of our edge devices, so we want to call the federate call of those prometheus-operators. These devices are not reachable from the internet, that's why we want to use PushProx. (We already use it for other use cases, with great succes)

Currently we can define our fqdn, which we want to use the kubernetes cluster name. However, the client will use this FQDN also to forward the scrape calls to. In our kubernetes cluster this should be the service name/ip of the operator. eg.

$ kubectl get svc -n prometheus
NAME                                    TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)            AGE
prometheus-kube-prometheus-prometheus   ClusterIP   10.43.107.104   <none>        9090/TCP           3h49m
prometheus-prometheus-node-exporter     ClusterIP   10.43.181.180   <none>        9100/TCP           3h49m
prometheus-kube-prometheus-operator     ClusterIP   10.43.162.81    <none>        8080/TCP,443/TCP   3h49m
prometheus-operated                     ClusterIP   None            <none>        9090/TCP           3h49m

Currently we have 2 options, set the fqdn flag to prometheus-kube-prometheus-prometheus which would not be unique for multiple edge devices. Or create a second Kubernetes svc that matches the fqdn you set and has the same selector as the one with the default install.

However, it would be nice that we can set the fqdn and the actual endpoint as different values for pushprox. For this reason I open this PR. Now you can configure fqdn to my-cool-fqdn and forward the requests to my-kubernetes-svc by setting the internal-endpoint flag.

I'm not sure if the name is good, i'm open for name changes. Naming things is hard.

hansmi commented 3 years ago

@pcallewaert Maybe I misunderstand, but isn't this similar or equal to #80?

pcallewaert commented 3 years ago

Lol, it is, my bad. Closing this!