This repository contains a step-by-step guide and configuration files to set up a highly available monitoring solution using Thanos, Prometheus, and Grafana. The setup includes multiple Kubernetes clusters, remote write and read capabilities, and long-term storage with object stores like AWS S3 or Minio.
kubectl
, helm
, docker
, minio
(optional for local object store).Start by setting up a Kubernetes environment using Minikube on Windows or Mac. This repository contains scripts and configurations for both local environmets.
choco install minikube -y
Clone this repository:
git clone https://github.com/rifaterdemsahin/prometheusremotewrite.git
cd prometheusremotewrite
Create the monitoring namespace:
kubectl create namespace monitoring
kubectl apply -f ./prometheus-operator-crds/
Apply the custom resource definitions and deploy the Prometheus Operator RECURSIVE -R:
kubectl apply -R -f prometheus-operator/
Deploy Prometheus and Thanos components: (10:07)
kubectl apply -f prometheus
Check Pods Going Online
kubectl get pods -n monitoring
Check Logs
kubectl logs -l app.kubernetes.io/name=prometheus -n monitoring -f
Port Forward
kubectl get svc -n monitoring
kubectl port-forward svc/prometheus-operated 9090 -n monitoring
For local storage, use Minio as an S3-compatible object store. Modify object-store.yaml
with your S3 or Minio credentials.
kubectl apply -f minio/
Deploy Grafana:
kubectl apply -f grafana/
Access Grafana UI using port-forwarding:
kubectl port-forward svc/grafana 3000:3000 -n monitoring
Default credentials are:
admin
grafana
Add Thanos as a data source in Grafana.
For secure communication between Thanos components, mutual TLS is implemented. Follow the TLS configuration steps provided in the mutual-tls/
folder.
Thanos can scale horizontally for high availability. Update the thanos-receiver
, querier
, and store-gateway
configurations to scale the deployment.
To clean up the environment, delete the deployed resources:
kubectl delete -f prometheus-thanos/
kubectl delete -f grafana/
kubectl delete namespace monitoring
This project is licensed under the MIT License.