monitoring-stack
by FZJ ICE-1
Stack of Monitoring tools: Grafana Grafana-Operator (optional) Prometheus (optional) Loki (optional) Grafana Alloy (optional) Node Exporter, Kube State Metrics, ... (optional)
About this chart
Monitoring Stack Helm Chart
[!WARNING]
This Chart is deprecated and not maintained anymore.
The Total Chart size increased too much through the dependant charts.
A separate Chart just for the grafana deployment will be available in the same Repository.
This Stack is intended to provide all components required for either a full Stack of Monitoring Tools and Applications or to fill the gaps of missing ones,
while trying to keep deployment and management simple.
Each of the following components can either be deployed together or combined in any desired configuration:
- Grafana Operator + grafana: Enables visualization of metrics, logs, and traces
- loki: Logging aggregation to store and query logs from all applications and infrastructure
- kube-prometheus-stack: Metric Collection and Monitoring of infrastructure, containing most importantly:
- k8s-monitoring: Alloy Operator + Grafana Alloy for collecting and pre-processing logs
Some components have overlapping features, like kube-prometheus-stack containing a deployment of Grafana (but without Operator) or k8s-monitoring also being able to collect metrics (less well integrated with Prometheus Operator).
This combination Chart aims to provide the best of each, mainly the Operators with their improved capability (CRDs) of configuring and managing their individual components.
[!note] :notebook: Note
When using Rancher, it is recommended to deploy themonitoring-stackin thecattle-monitoring-systemnamespace and setenableRancherDashboardServices: true.
Through this the connections between theMonitoringsection in the Rancher Dashboard and themonitoring-stackwill be added automatically.
For more details check therancher-monitoring-dashboard-links.yamltemplate.
Prerequisites
Create a namespace for the deployment:
kubectl create namespace cattle-monitoring-system
Create the following secrets in the same Namespace as the deployment:
# Authentication for Grafana
kind: Secret
apiVersion: v1
type: Opaque
metadata:
name: grafana-secrets
stringData:
GF_SECURITY_ADMIN_USER: ...
GF_SECURITY_ADMIN_PASSWORD: ...
Additionally persistentVolumeClaim for Grafana (10Gi) and Prometheus (20Gi) is automatically created.
When using a different storage type for Loki than "filesystem" (loki.loki.storage.type), add the following to the values.yaml depending on the type:
- S3:
loki: singleBinary: extraEnv: - name: S3_ACCESKEYID valueFrom: secretKeyRef: name: loki-s3-secrets key: s3-accessKeyId - name: S3_SECRETACCESSKEY valueFrom: secretKeyRef: name: loki-s3-secrets key: s3-secretAccessKey - GCS:
loki: singleBinary: extraEnv: - name: GCS_SERVICE_ACCOUNT valueFrom: secretKeyRef: name: loki-gcs-secrets key: gcs-service_account - Azure:
loki: singleBinary: extraEnv: - name: AZURE_ACCOUNT_NAME valueFrom: secretKeyRef: name: loki-azure-secrets key: azure-account_name - name: AZURE_ACCOUNT_KEY valueFrom: secretKeyRef: name: loki-azure-secrets key: azure-account_key - Swift:
loki:
singleBinary:
extraEnv:
- name: SWIFT_USERNAME
valueFrom:
secretKeyRef:
name: loki-swift-secrets
key: swift-username
- name: SWIFT_PASSWORD
valueFrom:
secretKeyRef:
name: loki-swift-secrets
key: swift-password
[!note] :notebook: Note
Raising theloki.singleBinary.replicasamount is only possible when using Object Storage.
Installing the Chart
Using Helm Install via Repository
Add the repository as described here.
# Install latest Version
helm repo update
kubectl create namespace cattle-monitoring-system
helm upgrade -i -n cattle-monitoring-system <cluster-name> ict-platform/monitoring-stack -f values.yaml
# List available versions
helm search repo ict-platform --versions
# Install specific version
helm install -n cattle-monitoring-system <cluster-name> ict-platform/monitoring-stack --version <x.x.x> -f values.yaml
Using Rancher
follow the steps described here.
The monitoring-stack can be installed through the Apps -> Charts (listed in the monitoring category) Option on each cluster.
Updating the Chart
Before updating to a new version it is important to ensure that the dependant CRDs are updated beforehand.
By default the grafana-operator CRDs are configured to be automatically updated when updating the Chart (grafana-operator.crds.immutable).
The kube-prometheus-stack doesn't provide that option and a manual update is required:
KUBE_PROM_STACK_VERSION=<kube-prometheus-stack-chart-version>
KUBE_PROM_STACK_CRDS=(
"alertmanagerconfigs"
"alertmanagers"
"podmonitors"
"probes"
"prometheusagents"
"prometheuses"
"prometheusrules"
"scrapeconfigs"
"servicemonitors"
"thanosrulers"
)
for CRD in ${KUBE_PROM_STACK_CRDS[@]}; do
kubectl apply --server-side --force-conflicts -f "https://raw.githubusercontent.com/prometheus-community/helm-charts/refs/tags/kube-prometheus-stack-${KUBE_PROM_STACK_VERSION}/charts/kube-prometheus-stack/charts/crds/crds/crd-${CRD}.yaml"
done
If the immutable option for the grafana-operator is enabled the CRDs can be updated with:
GRAFANA_OPERATOR_VERSION=<grafana-operator-chart-version>
kubectl apply --server-side --force-conflicts -f https://github.com/grafana/grafana-operator/releases/download/v${GRAFANA_OPERATOR_VERSION}$/crds.yaml
When switching from immutable to mutable it is required to use helm upgrade -i --take-ownership ... for the first time only.
Uninstalling the Chart and clean-up
To uninstall the Chart run:
helm uninstall -n <namespace> <deployment-name>
Afterwards there will be some CRDs and resources left which need their finalizes to be set empty to be removed:
NAMESPACE=<namespace>
# remove finalizers
for resource in $(kubectl get grafanaalertrulegroups -n $NAMESPACE -o name); do
kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done
for resource in $(kubectl get grafanacontactpoints -n $NAMESPACE -o name); do
kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done
for resource in $(kubectl get grafanadashboards -n $NAMESPACE -o name); do
kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done
for resource in $(kubectl get grafanadatasources -n $NAMESPACE -o name); do
kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done
for resource in $(kubectl get grafanafolders -n $NAMESPACE -o name); do
kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done
for resource in $(kubectl get grafananotificationpolicies -n $NAMESPACE -o name); do
kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done
for resource in $(kubectl get grafanaserviceaccount -n $NAMESPACE -o name); do
kubectl patch $resource -n $NAMESPACE --type='merge' -p '{"metadata":{"finalizers":[]}}'
done
# Grafana Alloy CRD
kubectl delete crd alloys.collectors.grafana.com
# Grafana CRDs
GRAFANA_CRDS=(
"grafanaalertrulegroups"
"grafanacontactpoints"
"grafanadashboards"
"grafanadatasources"
"grafanafolders"
"grafanalibrarypanels"
"grafanamutetimings"
"grafananotificationpolicies"
"grafananotificationpolicyroutes"
"grafananotificationtemplates"
"grafanas"
"grafanaserviceaccounts"
)
for CRD in ${GRAFANA_CRDS[@]}; do
kubectl delete crd ${CRD}.grafana.integreatly.org
done
# Monitoring CRDs
MONITORING_CRDS=(
"alertmanagerconfigs"
"alertmanagers"
"podmonitors"
"probes"
"prometheusagents"
"prometheuses"
"prometheusrules"
"scrapeconfigs"
"servicemonitors"
"thanosrulers"
)
for CRD in ${KUBE_PROM_STACK_CRDS[@]}; do
kubectl delete crd ${CRD}.monitoring.coreos.com
done
Remainders are:
- secrets:
- chart-generated:
- loki-cert
- monitoring-cert
- prometheus-admission
- prometheus-cert
- manually-generated:
- grafana-secrets
- loki-htpasswd
- loki-s3-secrets
- prometheus-htpasswd
- chart-generated:
- PersistentVolumeClaims (and PersistentVolumes ):
- prometheus-prometheus-prometheus-db-prometheus-prometheus-prometheus-0
Known issues
Some Grafana resources (or Grafana itself) are not created but the deployment succeeds
Sometimes it can happen that while adding resources like Grafana, Dashboards, Alerts, etc. to the API works just fine, they are not actually deployed.
This usually happens, when some resources have a configuration issue.
To fix this, inspect the grafana-operator logs and check the status defined in the missing API resource.
They should have detailed information about what happened, like missing dependencies or wrong configuration.
Service/Pod Monitors of application deployments are not re-added
When removing the CRDs for Service/Pod Monitors and re-adding them it can happen that the corresponding monitors of an application are not added again,
even if an application is redeployed.
This can happen if the application deployment is not properly updating the monitor and is unrelated to the monitoring-stack.
A simple workaround is to deploy the application first with the monitor disabled and than again with it enabled.
Deploy monitoring-stack with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has monitoring-stack on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartmonitoring-stack is pinned at v0.4.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply