﻿# Install monitoring tools

> [HTML Version](install-monitoring-tools.html)

The following services are used as monitoring tools:

- Prometheus tool for storing time series.

- Grafana service for monitoring key system performance indicators.

Let’s look at how to deploy them to a Kubernetes cluster in a few steps:

1. [Clear CRDs before installation (optional)](#clean-cdr).

2. [Download the Helm chart and the configuration file](#download-helm-chart-and-config-file).

3. [Fill out the configuration file](#fill-config-file).

4. [Install the Monitoring chart using helm in the Kubernetes cluster](#install-monitoring-chart).

## Step 1: Clear CRDs before installation (optional)

Perform CRD cleanup if you have previously installed monitoring tools by executing the following command:

````
kubectl delete crd alertmanagerconfigs.monitoring.coreos.com  
kubectl delete crd alertmanagers.monitoring.coreos.com  
kubectl delete crd podmonitors.monitoring.coreos.com  
kubectl delete crd probes.monitoring.coreos.com  
kubectl delete crd prometheusagents.monitoring.coreos.com  
kubectl delete crd prometheuses.monitoring.coreos.com  
kubectl delete crd prometheusrules.monitoring.coreos.com  
kubectl delete crd scrapeconfigs.monitoring.coreos.com  
kubectl delete crd servicemonitors.monitoring.coreos.com  
kubectl delete crd thanosrulers.monitoring.coreos.com

## ````
Step 2: Download the Helm chart and the configuration file

For installation via the internet, obtain the configuration file \[OBJECT\] by executing the command:

````
helm repo add brix365 https://charts.brix365.com  
helm repo update  
helm show values brix365/monitoring> values-monitoring.yaml

## ````
Step 3: Fill out the configuration file

Fill out the configuration file \[OBJECT\] for the installation of monitoring tools. 

To do this, specify the desired \[OBJECT\] for the monitoring service in the parameters \[OBJECT\] and \[OBJECT\], for example, \[OBJECT\]. The namespace will be created during the installation if it has not been created beforehand.

For Grafana:

1. Ensure that the interface is enabled and \[OBJECT\] is set to \[OBJECT\].

2. Specify the address at which Grafana will be accessible in the parameter \[OBJECT\].

3. Set the administrator’s password in the parameter \[OBJECT\]. 

Filling out the values-monitoring.yaml configuration file for monitoring installation

````
\# -- monitoring settings  
kube-prometheus-stack:  
  # -- grafana settings  
  grafana:  
    assertNoLeakedSecrets: false  
    # -- address at which grafana will be available  
    ingress:  
      enabled: true  
      ingressClassName: nginx  
      hosts:  
        - grafana.mycompany.com  
      # -- tls settings  
      # tls:  
      #   - secretName: "mycompany-cert"  
      #     hosts:  
      #       - grafana.mycompany.com  
      annotations: \{\}  
    # -- administrator's credentials  
    adminUser: admin  
    adminPassword: admin  
    # -- list of used plugins  
    plugins:  
    - camptocamp-prometheus-alertmanager-datasource  
    - flant-statusmap-panel  
    - vonage-status-panel  
    sidecar:  
      dashboards:  
        enabled: true  
        label: "grafana\_dashboard"  
        labelValue: ""  
        annotations:  
        folderAnnotation: grafana-dashboard-folder  
        provider:  
          allowUiUpdates: true  
          foldersFromFilesStructure: true  
  # -- prometheus settings  
  prometheus:  
    prometheusSpec:  
      replicas: 1  
      serviceMonitorSelectorNilUsesHelmValues: false  
      ## -- metrics retention period  
      retention: 1d  
      ## -- metric max size  
      retentionSize: ""
````

````
Filling out parameters for connecting to the Mimir remote storage

````
kube-prometheus-stack:  
  grafana:  
    sidecar:  
      # -- enable mimir as data source  
      datasources:  
        enabled: true  
        defaultDatasourceEnabled: true  
        isDefaultDatasource: true  
        uid: prometheus  
        url: http://mimir-nginx:80/prometheus  
       
  prometheus:  
    prometheusSpec:  
      # -- enable mimir as long term storage  
      remoteWrite:  
      - url: http://mimir-nginx:80/api/v1/push
````

## ````
Step 4: Install the Monitoring chart using helm in the Kubernetes cluster

Install the Monitoring chart in the \[OBJECT\] specified in the configuration file \[OBJECT\] in step 2. The namespace will be created during the installation if it has not been created beforehand.

To install via the internet, execute the command:

````
helm upgrade --install brix365-monitoring brix365/monitoring -f values-monitoring.yaml -n monitoring --create-namespace 

Начало внимание

````
After installing the monitoring tools, you need to [configure their use on the BRIX application side](enable-monitoring-enterprise.md).

````
Конец внимание

## ````
Delete the Monitoring chart using helm in the Kubernetes cluster

````
Начало внимание

````
Before removing the Monitoring add-on component, disable monitoring on the BRIX application side.

````
Конец внимание

1. ````
To delete the **brix365-monitoring** chart in \[OBJECT\], execute the command:

````
helm uninstall brix365-monitoring -n monitoring

2. ````
CRDs created by the **brix365-monitoring** chart are not removed by default and must be manually cleared by a user with **cluster-admin** rights:

````
kubectl delete crd alertmanagerconfigs.monitoring.coreos.com  
kubectl delete crd alertmanagers.monitoring.coreos.com  
kubectl delete crd podmonitors.monitoring.coreos.com  
kubectl delete crd probes.monitoring.coreos.com  
kubectl delete crd prometheusagents.monitoring.coreos.com  
kubectl delete crd prometheuses.monitoring.coreos.com  
kubectl delete crd prometheusrules.monitoring.coreos.com  
kubectl delete crd scrapeconfigs.monitoring.coreos.com  
kubectl delete crd servicemonitors.monitoring.coreos.com  
kubectl delete crd thanosrulers.monitoring.coreos.com

3. ````
If the CRD remains in the **Terminating** status for more than 5 minutes during deletion, patch the CRD with the command:

````
kubectl patch crd/MY\_CRD\_NAME -p '\{"metadata":\{"finalizers":\[\]\}\}' --type=merge
````