Registering More than one Custom Metric API in Kubernetes


TL;DR Can I register multiple APIs to provide custom metrics in k8s?

We have a multi-tenanted cluster - with different deployments in different namespaces, and they each have their own monitoring solution (using Prometheus)

We want each namespace to be able to use the HPA to scale off of custom metrics from the Prometheus instance in their own namespace.

We have custom metrics configured using the Prometheus adapter ( in our dev environment and that works with the following deployed:

  • Roles + Bindings
  • Prometheus Adapter + Config + Service (in namespace)
  • A that is named and points to the service in the namespace

The APIService doesn't get put in a namespace and is global - and the naming has to be which means we can only use a single prometheus for custom metrics - which breaks our usecase.

Any idea how to register more than one service as an API for custom_metrics? or another way to do this?

-- DJOodle

1 Answer


So I'm not sure this is the best answer - waiting for the community to respond before I say that - but it is definitely an answer.

You can't seem to register multiple services for a single API - so the answer is to aggregate the data into a single API.

Options for this include:

  1. Federated Prometheus = scraping the /federated endpoint of each Prometheus and using that to server the custom scaling metrics. (

  2. Thanos - ( Bit early days for production use maybe - so the squeamish may want to go for options one -but Thanos is giving me a unified querying layer over the top of every Prometheus, that I can attach the Adapter to. Pretty neat - nice project - worth checking out;

-- DJOodle
Source: StackOverflow