Aller au contenu

Installation de loki/alloy

Introduction

Grafana Alloy est un aspirateur à informations : il récupère les journaux d'activité (logs) et les données de santé de vos applications dans vos serveurs ou votre cluster Kubernetes.
Il envoie ensuite tout ce qu'il a récolté vers Loki, qui sert de grand coffre-fort pour stocker et organiser ces journaux afin que vous puissiez les consulter facilement dans Grafana.

Fichier de configuration

cd /tmp
curl https://gitforge.dyndns.org/downloads/loki-alloy/loki-alloy-1.0.0.tar.gz -o loki-alloy-1.0.0.tar.gz
tar zxvf loki-alloy-1.0.0.tar.gz
cd loki-alloy-1.0.0 

Installation

Loki

helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm upgrade loki grafana/loki \
--install \
--atomic \
--cleanup-on-fail \
--values=./loki-values.yaml \
--namespace kube-prometheus \
--create-namespace

Agents alloy

helm upgrade alloy grafana/alloy \
--install \
--atomic \
--cleanup-on-fail \
--values=./alloy-agent-values.yaml \
--namespace kube-prometheus \
--create-namespace

Ajout de la datasource loki dans grafana

Modifiez ces deux variables afin qu’elles correspondent à votre configuration.

adminPassword=pa55w0rd
public_host_grafana=grafana-k3s.gmolab.net
curl -ks -X POST \
  -H "Content-Type: application/json" \
  -u "admin:$adminPassword" \
  "https://$public_host_grafana/api/datasources" \
  -d '{
    "name": "Loki",
    "type": "loki",
    "url": "http://loki.kube-prometheus.svc.cluster.local:3100",
    "access": "proxy",
    "isDefault": false
  }' | jq

Le résultat attendu doit ressembler à ceci

{
  "datasource": {
    "id": 6,
... 
    "apiVersion": ""
  },
  "id": 6,
  "message": "Datasource added",
  "name": "Loki"
}

Configuration de la gateway alloy

Avant de procéder à l'installation, éditez le fichier alloy-gateway-values.yaml afin d'adapter les variables à votre environnement.

helm upgrade alloy-gateway . \
--install \
--atomic \
--cleanup-on-fail \
--values=./alloy-gateway-values.yaml \
--namespace kube-prometheus \
--create-namespace

Accès au tableau de bord alloy

https://<PUBLIC_HOST_ALLOY>

Nettoyage

cd
rm -rf /tmp/loki-alloy-1.0.0*

Version Date Change Auteur
1.0 19.09.2026 Création GMo