Skip to content
Securely manage Docker, Swarm, Kubernetes and Podman clusters in the cloud, on-premise, and in the data center.
Secure app deployment and device management for your Industrial IoT, IoT and Edge devices.
Let Portainer's Managed Platform Services accelerate your containerization journey.
Manage all your Docker, Swarm, Kubernetes and Podman clusters from a single secure interface.
Portainer empowers Platform Engineering teams to deliver efficient, user-centric services.
Empower your business by adopting containerization the easy way with Portainer.
Deploy to and manage your fleet of remote devices centrally and securely.
Onboard, manage and deploy workloads across hundreds of devices securely with Portainer.
Deployment scenarios
Partner Solutions
blog-banner
Neil Cresswell, CEOMarch 6, 20222 min read

Deploy Prometheus Monitoring Stack with Portainer

Out of the box, Portainer supports monitoring Kubernetes clusters via the metrics server/API, which gives you basic CPU and Memory stats for Pods and Nodes. But what if you want more bells and whistles?

Most people are familiar with Prometheus and Grafana, but how do you go about deploying them into Portainer managed Kubernetes Clusters? Let me show you.

First up, login to a Portainer instance that is managing one or more Kubernetes cluster.

Select the Cluster you wish to install Prometheus on,,then click on "Namespaces" and create a simple namespace.

Portainer Create a Namespace Screenshot

Now click on 'HELM'.

in the "Additional Respostories" field, type in https://prometheus-community.github.io/helm-charts, then click "Add Repository"

Choose "Kube-Prometheus-stack".

Note, for this to deploy, my nodes needed >4GB RAM, else OOM errors will be generated (the cluster was empty except this stack)

Portainer Helm Screenshot

Select the namespace, give the deployment a name, then click "Install".

Note that this "default" deployment does not persist the Prometheus data, so if you want to do that, you need to edit the custom values.

Alert Manager:

Alert Manager

Grafana:

Prometheus:

Prometheus

Once the deployment has finished, navigate to "Applications" and check that all is good.

Portainer Application List Screenshot

If your cluster does NOT have the metrics server installed ,and you would like to use Prometheus as your metrics server, go back into HELM, and deploy the chart "prometheus-adapter", which will configure Prometheus as a pseudo "metrics-server".

Edit the custom values,

1) In Line 31, Add the URL of the Prometheus instance deployed above.. in this case it is: http://prometheus-stack-kube-prom-prometheus.prometheus

2) Starting line 102 and going through to line 126, uncomment all of the "resources:" section (note, make sure to remove the {} brackets after resources:). Click "Install"

Portainer Helm Charts Screenshot

Once that is installed and running, go into "Cluster" and then "Setup" and enable features that use the metrics API. It should succeed if the HELM chart above deployed OK.

To check, click on "Cluster" and then view the stats for a node..

Portainer Node Stats Screenshot

OK, so now Prometheus is installed, the adapter is installed to provide metrics services via the metrics API, but how do you actually access Grafana and Prometheus UI?

Go back to applications, expand the "prometheus-stack" and then click on "prometheus-stack-grafana"

Note it is only presenting itself inside the cluster, as a clusterIP

If you want to access it externally, you can just click "edit application" and add a service that suits your needs, in my case I have selected "LoadBalancer" and exposed Port 3000.

After updating the service presentation, you should now get the default admin password for Grafana. Scroll down to "config" and click on the config for admin-password

Here are the default credentials:

OK, so let's open Grafana.

And open a default dashboard, Node (Pods)

Success.

If you choose to expose the Prometheus UI, you'll not it has no authentication in front of it, so I would be hesitant mapping it to a load balancer.

So this is how you can deploy Prometheus and Grafana with Portainer, and use it as a substitute for metrics server.

For optional Part 2 of this blog, adding additional Prometheus instances to this Grafana deployment, click here ->. https://www.portainer.io/blog/deploy-prometheus-monitoring-stack-with-portainer-part-2

 

avatar

Neil Cresswell, CEO

Neil brings more than twenty years’ experience in advanced technology including virtualization, storage and containerization.

COMMENTS

Related articles