Loki is an open platform for collecting, indexing, and storing logs. It enables debugging and problem detection in the system based on log data analysis and monitoring.
Beforehand, install the monitoring tools.
The installation of Loki consists of five steps:
- Download the Helm chart and the configuration file.
- Create buckets and set lifecycle rules in MinIO.
- Fill in the configuration file.
- Install the Loki chart using Helm in the Kubernetes cluster.
- Configure the connection to Loki in Grafana data sources.
Начало внимание
When installing Loki + Tempo, start with the Loki addon. This allows preserving cross-linking settings, as they are initially configured in the Datasource settings.
Конец внимание
Step 1: Download the Helm chart and the configuration file
To install over the internet, obtain the configuration file values- loki.yaml
by executing the command:
helm repo add elma365 https://charts.elma365.tech
helm repo update
helm show values elma365/loki > values-loki.yaml
Getting configuration file for installation in a closed environment without internet access,
- On a computer with internet access, download the archive of the latest version of the Loki chart from the ELMA365 repository using the command:
helm repo add elma365 https://charts.elma365.tech
helm repo update
helm pull elma365/loki
- Copy the obtained
loki-X.Y.Z.tgz chart archive to the server where the installation will take place. - Unpack the chart and copy the default configuration file
values.yaml to values- loki.yaml .
tar -xf loki-X.Y.Z.tgz
cp loki/values.yaml values-loki.yaml
|
Step 2: Create buckets and set lifecycle rules in MinIO
1. Create alias
for MinIO:
mc alias set my_alias http://minio.local accessKey secretKey
2. Create buckets with the names admins
, chunks
and rules
:
mc mb -p my_alias/admin --region=ru-central-1
mc mb -p my_alias/chunks --region=ru-central-1
mc mb -p my_alias/rules --region=ru-central-1
3. Set lifecyle for chunks
, deleting objects older than 60 days:
mc ilm import my_alias/chunks <<EOF
{
"Rules": [
{
"Expiration": {
"Days": 60
},
"ID": "Delete objects from the Loki bucket older than 60 days",
"Status": "Enabled"
}
]
}
EOF
Step 3: Fill in the configuration file
Fill in the values-loki.yaml configuration file to install Loki
loki:
loki:
storage:
bucketNames:
chunks: chunks
ruler: ruler
admin: admin
type: s3
s3:
s3: null
endpoint: minio.local:9000
region: ru-central-1
secretAccessKey: secretAccessKey
accessKeyId: accessKeyId
signatureVersion: null
s3ForcePathStyle: true
insecure: true
http_config: {}
# -- Optional compactor configuration
compactor:
shared_store: s3
compaction_interval: 10m
retention_enabled: true
retention_delete_delay: 2h
retention_delete_worker_count: 150
working_directory: /var/loki/chunks
# -- Optional ingester configuration
ingester: {}
# -- Check https://grafana.com/docs/loki/latest/configuration/#schema_config for more info on how to configure schemas
schemaConfig: {}
# -- Limits config
limits_config: {}
promtail:
deployment:
# -- Deploys Promtail as a Deployment
enabled: false
replicaCount: 1
autoscaling:
# -- Creates a HorizontalPodAutoscaler for the deployment
enabled: false
minReplicas: 1
maxReplicas: 10
# -- Readiness probe
# @default -- See `values.yaml`
readinessProbe:
failureThreshold: 5
httpGet:
path: "{{ printf `%s/ready` .Values.httpPathPrefix }}"
port: http-metrics
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
config:
# -- Enable Promtail config from Helm chart
# Set `configmap.enabled: true` and this to `false` to manage your own Promtail config
# See default config in `values.yaml`
enabled: true
# -- The port of the Promtail server
# Must be reference in `config.file` to configure `server.http_listen_port`
# See default config in `values.yaml`
serverPort: 3101
# -- The config of clients of the Promtail server
# Must be reference in `config.file` to configure `clients`
# @default -- See `values.yaml`
clients:
- url: http://loki-gateway/loki/api/v1/push
|
Filling in connection parameters to a private registry for installation in a closed environment without internet access
To connect to a private registry, follow these steps:
- Download the ELMA365 images and load them into the local image registry. Read more about this in Download ELMA365 images.
- Set the address and path for the parameter
image.repository .
- Specify the name of the secret with access rights to the private registry in the parameter
image.pullSecrets . The secret must be created manually and encoded in Base64.
loki:
## connection parameters for the private registry
image:
## address and path for the private registry
registry: registry.example.com
repository: loki
# tag: 2.9.2
# pullPolicy: IfNotPresent
imagePullSecrets:
- myRegistryKeySecretName
backend:
## connection parameters for the private registry
image:
## address and path for the private registry
registry: registry.example.com
repository: k8s-sidecar
# tag: 1.24.3
# pullPolicy: IfNotPresent
gateway:
## connection parameters for the private registry
image:
## address and path for the private registry
registry: registry.example.com
repository: nginx-unprivileged
# tag: 1.24-alpine
# pullPolicy: IfNotPresent
promtail:
## connection parameters for the private registry
image:
## address and path for the private registry
registry: registry.example.com
repository: promtail
# tag: 2.9.2
# pullPolicy: IfNotPresent
imagePullSecrets:
- myRegistryKeySecretName
Where the repository format is: address — registry.example.com .
|
Step 4: Install the Loki chart using Helm in the Kubernetes cluster
Execute the installation of the Loki chart in namespace monitoring
.
For online installation via the internet:
helm upgrade --install -n monitoring loki elma365/loki -f values-loki.yaml
For offline installation without internet access, navigate to the directory with the downloaded chart and execute the command:
helm upgrade --install loki ./loki -f values-loki.yaml -n monitoring
Step 5: Configure the connection to Loki in Grafana data sources
The Loki data source is added during installation. You can check it using the path: Home > Administration > Data source > Loki.
URL: http://loki-gateway
Example of viewing logs for mongodb ({app="mongodb"} |= "error" != "timeout")
:
Found a typo? Highlight the text, press ctrl + enter and notify us