Prometheus Adapter configuration for kubernetes metrics

10/13/2019

I installed prometheus-adapter with helm. Now I don't know how to configure prometheus-adapter so that my kubernetes cluster can communicate with a extern server where prometheus is installed. Where and how can i connect the prometheus-adapter to prometheus. I want to use data from prometheus for my external metrics in kubernetes.

-- Java
kubernetes
prometheus

1 Answer

10/14/2019

First, you'll need to deploy the Prometheus Operator.

This walkthrough assumes that Prometheus is deployed in the prom namespace. Most of the sample commands and files are namespace-agnostic, but there are a few commands or pieces of configuration that rely on that namespace. If you're using a different namespace, simply substitute that in for prom when it appears.

Note that if you are deploying on a non-x86_64 (amd64) platform, you'll need to change the image field in the Deployment to be the appropriate image for your platform.

Make sure that you have default adapter which configuration should work with standard Prometheus Operator configuration, but if you've got custom relabelling rules, or your labels above weren't exactly namespace and pod, you may need to edit the configuration in the ConfigMap. The configuration walkthrough provides an overview of how configuration works.

Make sure that you have registered the API with the API aggregator (part of the main Kubernetes API server).

Try fetching the discovery information for it:

$ kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1

Since you've set up Prometheus to collect your app's metrics, you should see a pods/http_request resource show up. This represents the http_requests_total metric, converted into a rate, aggregated to have one datapoint per pod. Notice that this translates to the same API that our HorizontalPodAutoscaler was trying to use above.

The API is registered as custom.metrics.k8s.io/v1beta1, and you can find more information about aggregation at Concepts: Aggregation.

More information you can find in this instruction.

Let me know if it helps.

-- MaggieO
Source: StackOverflow