Skip to content

Commit

Permalink
[Documentation] Update prometheus and grafana related doc (#543)
Browse files Browse the repository at this point in the history
Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao authored Jun 13, 2024
1 parent dd2895c commit 783cd78
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 103 deletions.
101 changes: 101 additions & 0 deletions doc/integration/deploy-prometheus-grafana.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Deploy Prometheus and Grafana

There are two ways to deploy Prometheus and Grafana service in the Kubernetes environment.

1. Deploy Prometheus and Grafana Service Directly.
2. Deploy Prometheus and Grafana Service by Operator.

Inorder to scrape the metrics by ServiceMonitor CRD, you must install the Prometheus Operator in the Kubernetes.
That is to say, you must choose the second way to deploy Prometheus and Grafana Service.

## 1. Deploy Prometheus and Grafana Service Directly

### 1.1 Deploy Prometheus Service

> SKIP this step if the Prometheus service is already available in the Kubernetes environment.
Follow the instructions
from [Prometheus Helm Chart](https://artifacthub.io/packages/helm/prometheus-community/prometheus) to deploy the
Prometheus service into the Kubernetes environment.

```shell
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update prometheus-community
helm install prometheus prometheus-community/prometheus
```

### 1.2 Deploy Grafana Service

> SKIP this step if the Grafana service is already available in the Kubernetes environment.
Follow the instructions from [Grafana Helm Chart](https://artifacthub.io/packages/helm/grafana/grafana) to deploy the
Grafana service into the Kubernetes environment.

Need override the default value of the grafana service, change the Grafana service type from default `ClusterIP`
to `LoadBalancer` in order to access the Grafana service from the outside Kubernetes network.

An example `grafana-values.yaml` may look like as the following snippet.

```yaml
service:
enabled: true
type: "LoadBalancer"
```
Install the Grafana service with the following commands.
```shell
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update grafana
helm install grafana -f grafana-values.yaml grafana/grafana
```

## 2. Deploy Prometheus and Grafana Service by Operator

you can also install `kube-prometheus-stack` chart which will install Prometheus operator, Prometheus service
and Grafana service.

```shell
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update prometheus-community
helm install prometheus prometheus-community/kube-prometheus-stack
```

## 4. Login And Configure Grafana Service

> SKIP this section if the prometheus data source is already configured in Grafana.
### 4.1 Get Grafana Service External Address

Run the following command to get the external ip address

```shell
kubectl get svc grafana
```

A possible result may look like the follows

```text
$ kubectl get svc grafana
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
grafana LoadBalancer 10.40.6.237 35.239.53.124 80:31362/TCP 4m25s
```

### 4.2 Get Grafana Admin Password

Run the following command to get the login password for admin user.

```shell
kubectl get secrets grafana -o yaml | grep admin-password | awk '{print $2}' | base64 -d
```

### 4.3 Login Grafana and Configure Prometheus Data Source

Access Grafana web GUI with `http://<external_ip>/`, login with `admin:<password>`.

From the navigation path, `"Administration" -> "Configuration" -> "Add Data Source"`, set the HTTP.URL
to `http://prometheus-server.default`. Change `default` to the correct namespace if the prometheus service is not
deployed in the default namespace. Refer to Grafana
doc [here](https://grafana.com/docs/grafana/latest/datasources/prometheus/configure-prometheus-data-source/) for
detailed instructions.

112 changes: 9 additions & 103 deletions doc/integration/integration-prometheus-grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,113 +13,16 @@ environment. From this document, you will learn,
+ Grafana helm chart: latest available version
+ StarRocks operator and helm chart: v1.7.1+

There are two ways to deploy Prometheus and Grafana service in the Kubernetes environment.
> see [deploy-prometheus-grafana.md](./deploy-prometheus-grafana.md) for how to deploy Prometheus and Grafana.
1. Deploy Prometheus and Grafana Service Directly.
2. Deploy Prometheus and Grafana Service by Operator.

Inorder to scrape the metrics by ServiceMonitor CRD, you must install the Prometheus Operator in the Kubernetes. That is
to say, you must choose the second way to deploy Prometheus and Grafana Service.

## 2. Deploy Prometheus and Grafana Service Directly

### 2.1 Deploy Prometheus Service

> SKIP this step if the Prometheus service is already available in the Kubernetes environment.
Follow the instructions
from [Prometheus Helm Chart](https://artifacthub.io/packages/helm/prometheus-community/prometheus) to deploy the
Prometheus service into the Kubernetes environment.

```shell
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update prometheus-community
helm install prometheus prometheus-community/prometheus
```

### 2.2 Deploy Grafana Service

> SKIP this step if the Grafana service is already available in the Kubernetes environment.
Follow the instructions from [Grafana Helm Chart](https://artifacthub.io/packages/helm/grafana/grafana) to deploy the
Grafana service into the Kubernetes environment.

Need override the default value of the grafana service, change the Grafana service type from default `ClusterIP`
to `LoadBalancer` in order to access the Grafana service from the outside Kubernetes network.

An example `grafana-values.yaml` may look like as the following snippet.

```yaml
service:
enabled: true
type: "LoadBalancer"
```
Install the Grafana service with the following commands.
```shell
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update grafana
helm install grafana -f grafana-values.yaml grafana/grafana
```

## 3. Deploy Prometheus and Grafana Service by Operator

you can also install `kube-prometheus-stack` chart which will install both Prometheus Operator, Prometheus service
and Grafana service.

```shell
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update prometheus-community
helm install prometheus prometheus-community/kube-prometheus-stack
```

## 4. Login And Configure Grafana Service

> SKIP this section if the prometheus data source is already configured in Grafana.
### 4.1 Get Grafana Service External Address

Run the following command to get the external ip address

```shell
kubectl get svc grafana
```

A possible result may look like the follows

```text
$ kubectl get svc grafana
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
grafana LoadBalancer 10.40.6.237 35.239.53.124 80:31362/TCP 4m25s
```

### 4.2 Get Grafana Admin Password

Run the following command to get the login password for admin user.

```shell
kubectl get secrets grafana -o yaml | grep admin-password | awk '{print $2}' | base64 -d
```

### 4.3 Login Grafana and Configure Prometheus Data Source

Access Grafana web GUI with `http://<external_ip>/`, login with `admin:<password>`.

From the navigation path, `"Administration" -> "Configuration" -> "Add Data Source"`, set the HTTP.URL
to `http://prometheus-server.default`. Change `default` to the correct namespace if the prometheus service is not
deployed in the default namespace. Refer to Grafana
doc [here](https://grafana.com/docs/grafana/latest/datasources/prometheus/configure-prometheus-data-source/) for
detailed instructions.

## 5. Deploy StarRocks Cluster
## 2. Deploy StarRocks Cluster

There are two ways to turn on the prometheus metrics scrape for the StarRocks cluster.

1. Turn on the prometheus metrics scrape by adding annotations
2. Turn on the prometheus metrics scrape by using ServiceMonitor CRD

### 5.1 Turn on the prometheus metrics scrape by adding annotations
### 2.1 Turn on the prometheus metrics scrape by adding annotations

Follow the instructions from [StarRocks Helm Chart](https://artifacthub.io/packages/helm/kube-starrocks/kube-starrocks)
with some customized values.
Expand All @@ -129,6 +32,7 @@ Following is an example of the content of the `sr-values.yaml`.
* For chart v1.7.1 and below,

```yaml
# sr-values.yaml
starrocksFESpec:
service:
annotations:
Expand Down Expand Up @@ -160,6 +64,7 @@ starrocksBESpec:
* For chart v1.8.0 and above,
```yaml
# sr-values.yaml
starrocks:
starrocksFESpec:
service:
Expand Down Expand Up @@ -246,11 +151,12 @@ helm repo update starrocks-community
helm install starrocks -f sr-values.yaml starrocks-community/kube-starrocks
```

### 5.2 Turn on the prometheus metrics scrape by using ServiceMonitor CRD
### 2.2 Turn on the prometheus metrics scrape by using ServiceMonitor CRD

Compared to the annotation approach, ServiceMonitor allows for more flexible definition of selector and relabeling rules
in the future.
> Make sure the prometheus operator is installed in the Kubernetes environment.
> Make
> sure [Deploy Prometheus and Grafana Service by Operator](./deploy-prometheus-grafana.md#2-deploy-prometheus-and-grafana-service-by-operator)
Follow the instructions from [StarRocks Helm Chart](https://artifacthub.io/packages/helm/kube-starrocks/kube-starrocks)
with some customized values.
Expand All @@ -264,7 +170,7 @@ starrocks:

Note: This only works for chart v1.8.4 and above.

## 6. Import StarRocks Grafana Dashboard
## 3. Import StarRocks Grafana Dashboard

StarRocks grafana dashboard configuration for kubernetes environment is available
at https://github.com/StarRocks/starrocks/blob/main/extra/grafana/kubernetes/StarRocks-Overview-kubernetes-3.0.json
Expand Down

0 comments on commit 783cd78

Please sign in to comment.