# How To Install/Upgrade Prometheus Stack Using Helm Chart.

## Problem

Since the customisation of promethues alert rules are not possible in prometheus stack deployed via clusteraddon, we are recommending promethues stack installation using Helm chart where user level customisations are possible.

## Environment

* Platform9 Managed Kubernetes - v5.5 and Higher
* Prometheus stack without ClusterAddons

## Pre-requisites

1. Downloaded helm repo for the new kube-prometheus-stack from: [https://platform9.github.io/pf9-kube-prometheus-helm-chart/](https://github.com/platform9/pf9-kube-prometheus-helm-chart/tree/main/charts/kube-prometheus-stack/templates/prometheus)
2. Ensure monitoring clusteraddon is disabled from the UI.

## Procedure

## **INSTALLATION**

1. Follow the instructions to [install HELM3](https://platform9.com/kb/kubernetes/how-to-use-helm-3-to-deploy-applications-in-platform9-managed-k) and Add Prometheus Helm repo and update using:

{% tabs %}
{% tab title="Add helm repo" %}

```javascript
❯ helm repo add pf9-plus https://platform9.github.io/pf9-kube-prometheus-helm-chart/
❯ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "pf9-plus" chart repository
Update Complete. ⎈Happy Helming!⎈
```

{% endtab %}
{% endtabs %}

2. Verify the repo list for new repo chart 38.0.4 or above is reflected in the helm search:

{% tabs %}
{% tab title="Verify repo - Sample pf9-plus" %}

```javascript
❯ helm search repo pf9-plus/kube-prometheus-stack --versions
NAME                          	CHART VERSION	APP VERSION	DESCRIPTION
pf9-plus/kube-prometheus-stack	38.0.4       	0.57.0     	kube-prometheus-stack collects Kubernetes manif...

❯ helm ls
NAME   	NAMESPACE	REVISION	UPDATED                             	STATUS  	CHART                       	APP VERSION
testmon	default  	1       	2023-06-20 15:36:45.971628 +0530 IST	deployed	kube-prometheus-stack-38.0.2	0.57.0
```

{% endtab %}
{% endtabs %}

3. Install the latest chart(version 38.0.4 or above):

{% tabs %}
{% tab title="Install helm - Sample chart testmon" %}

```javascript
❯ helm install testmon pf9-plus/kube-prometheus-stack
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /Users/nehat/Downloads/testhelmupgrade001-kubeconfig.yaml
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /Users/nehat/Downloads/testhelmupgrade001-kubeconfig.yaml
Release "testmon" has been upgraded. Happy Helming!
NAME: testmon
LAST DEPLOYED: Tue Jun 20 15:51:54 2023
NAMESPACE: default
STATUS: deployed
REVISION: 2
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
  kubectl --namespace pf9-monitoring get pods -l "release=testmon"

Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
```

{% endtab %}
{% endtabs %}

4. Verify the stack installed, make sure the components are deployed/running.

{% tabs %}
{% tab title="Verify prometheus stack- Sample testmon" %}

```javascript
❯ kubectl --namespace pf9-monitoring get pods -l "release=testmon"
NAME                                         READY   STATUS    RESTARTS   AGE
monhelper-b58f65449-7rgvc                    1/1     Running   0          16m
pf9-prom-operator-96f4ffdb5-vg76f            1/1     Running   0          59s
testmon-kube-state-metrics-6ddf7cbdc-b6qnc   1/1     Running   0          16m
testmon-prometheus-node-exporter-7ddmb       1/1     Running   0          16m
testmon-prometheus-node-exporter-mtbbf       1/1     Running   0          16m

❯ helm ls
NAME   	NAMESPACE	REVISION	UPDATED                             	STATUS  	CHART                       	APP VERSION
testmon	default  	2       	2023-06-20 15:51:54.167553 +0530 IST	deployed	kube-prometheus-stack-38.0.4	0.57.0
```

{% endtab %}
{% endtabs %}

## **UPGRADE**

**If the Prometheus stack is already installed using helm, upgrade with the chart version using below steps:**

1. Download the new repo from:[ ](https://github.com/platform9/pf9-kube-prometheus-helm-chart/tree/main/charts/kube-prometheus-stack/templates/prometheus)[https://platform9.github.io/pf9-kube-prometheus-helm-chart/](https://github.com/platform9/pf9-kube-prometheus-helm-chart/tree/main/charts/kube-prometheus-stack/templates/prometheus)
2. Add the repo and Update the repo using:

{% tabs %}
{% tab title="Sample-Update repo" %}

```javascript
❯ helm repo add pf9-plus https://platform9.github.io/pf9-kube-prometheus-helm-chart/

❯ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "pf9-plus" chart repository
Update Complete. ⎈Happy Helming!⎈
```

{% endtab %}
{% endtabs %}

3. Verify the new chart version is reflected in the helm search and list:

{% tabs %}
{% tab title="Verify and list repo - Sample pf9-plus" %}

```javascript
❯ helm search repo pf9-plus/kube-prometheus-stack --versions
NAME                          	CHART VERSION	APP VERSION	DESCRIPTION
pf9-plus/kube-prometheus-stack	38.0.4       	0.57.0     	kube-prometheus-stack collects Kubernetes manif...
pf9-plus/kube-prometheus-stack	38.0.2       	0.57.0     	kube-prometheus-stack collects Kubernetes manif...

❯ helm ls
NAME   	NAMESPACE	REVISION	UPDATED                             	STATUS  	CHART                       	APP VERSION
testmon	default  	1       	2023-06-20 15:36:45.971628 +0530 IST	deployed	kube-prometheus-stack-38.0.2	0.57.0
```

{% endtab %}
{% endtabs %}

4. Upgrade helm chart:

{% tabs %}
{% tab title="Upgrade helm - Sample chart testmon" %}

```javascript
❯ helm upgrade testmon pf9-plus/kube-prometheus-stack
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /Users/nehat/Downloads/testhelmupgrade001-kubeconfig.yaml
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /Users/nehat/Downloads/testhelmupgrade001-kubeconfig.yaml
Release "testmon" has been upgraded. Happy Helming!
NAME: testmon
LAST DEPLOYED: Tue Jun 20 15:51:54 2023
NAMESPACE: default
STATUS: deployed
REVISION: 2
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
  kubectl --namespace pf9-monitoring get pods -l "release=testmon"

Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
```

{% endtab %}
{% endtabs %}

5. Verify the stack installed and pods are deployed/running.

{% tabs %}
{% tab title="Verify prometheus stack- Sample testmon" %}

```javascript
❯ kubectl --namespace pf9-monitoring get pods -l "release=testmon"
NAME                                         READY   STATUS    RESTARTS   AGE
monhelper-b58f65449-7rgvc                    1/1     Running   0          16m
pf9-prom-operator-96f4ffdb5-vg76f            1/1     Running   0          59s
testmon-kube-state-metrics-6ddf7cbdc-b6qnc   1/1     Running   0          16m
testmon-prometheus-node-exporter-7ddmb       1/1     Running   0          16m
testmon-prometheus-node-exporter-mtbbf       1/1     Running   0          16m

❯ helm ls
NAME   	NAMESPACE	REVISION	UPDATED                             	STATUS  	CHART                       	APP VERSION
testmon	default  	2       	2023-06-20 15:51:54.167553 +0530 IST	deployed	kube-prometheus-stack-38.0.4	0.57.0
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmk/how-to/how-to-install-upgrade-prometheus-stack-using-helm-chart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
