From 1c7ecec6abe2c8cd36c8e79f85d1f71e43a58516 Mon Sep 17 00:00:00 2001 From: Schneider Roland Date: Sun, 27 Oct 2024 10:50:14 +0100 Subject: [PATCH] loki: add --- loki/docker-compose/loki/docker-compose.yaml | 22 ++++++++ loki/docker-compose/loki/loki-config.yaml | 50 +++++++++++++++++++ loki/docker-compose/loki/promtail-config.yaml | 18 +++++++ loki/jenkins/Jenkinsfile | 26 ++++++++++ 4 files changed, 116 insertions(+) create mode 100644 loki/docker-compose/loki/docker-compose.yaml create mode 100644 loki/docker-compose/loki/loki-config.yaml create mode 100644 loki/docker-compose/loki/promtail-config.yaml create mode 100644 loki/jenkins/Jenkinsfile diff --git a/loki/docker-compose/loki/docker-compose.yaml b/loki/docker-compose/loki/docker-compose.yaml new file mode 100644 index 0000000..85b5bab --- /dev/null +++ b/loki/docker-compose/loki/docker-compose.yaml @@ -0,0 +1,22 @@ +version: '3.8' + +services: + loki: + image: grafana/loki:3.0.0 # Specifies the Loki Docker image and version. + container_name: loki # Names the container for easier management. + volumes: + - ./loki-config.yaml:/mnt/config/loki-config.yaml # Mounts the Loki configuration file. + - ./data:/tmp + ports: + - "3100:3100" # Maps port 3100 on the host to port 3100 in the container. + command: -config.file=/mnt/config/loki-config.yaml # Runs Loki with the specified configuration file. + + promtail: + image: grafana/promtail:3.0.0 # Specifies the Promtail Docker image and version. + container_name: promtail # Names the container for easier management. + volumes: + - ./promtail-config.yaml:/mnt/config/promtail-config.yaml # Mounts the Promtail configuration file. + - /var/log:/var/log # Mounts the host's log directory. + depends_on: + - loki # Ensures Promtail starts after Loki. + command: -config.file=/mnt/config/promtail-config.yaml # Runs Promtail with the specified configuration file. diff --git a/loki/docker-compose/loki/loki-config.yaml b/loki/docker-compose/loki/loki-config.yaml new file mode 100644 index 0000000..694f303 --- /dev/null +++ b/loki/docker-compose/loki/loki-config.yaml @@ -0,0 +1,50 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + grpc_listen_port: 9096 + +common: + instance_addr: 127.0.0.1 + path_prefix: /tmp/loki + storage: + filesystem: + chunks_directory: /tmp/loki/chunks + rules_directory: /tmp/loki/rules + replication_factor: 1 + ring: + kvstore: + store: inmemory + +query_range: + results_cache: + cache: + embedded_cache: + enabled: true + max_size_mb: 100 + +schema_config: + configs: + - from: 2020-10-24 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +ruler: + alertmanager_url: http://localhost:9093 + +# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration +# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/ +# +# Statistics help us better understand how Loki is used, and they show us performance +# levels for most users. This helps us prioritize features and documentation. +# For more information on what's sent, look at +# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go +# Refer to the buildReport method to see what goes into a report. +# +# If you would like to disable reporting, uncomment the following lines: +analytics: + reporting_enabled: false diff --git a/loki/docker-compose/loki/promtail-config.yaml b/loki/docker-compose/loki/promtail-config.yaml new file mode 100644 index 0000000..ed06e8c --- /dev/null +++ b/loki/docker-compose/loki/promtail-config.yaml @@ -0,0 +1,18 @@ +server: + http_listen_port: 9080 + grpc_listen_port: 0 + +positions: + filename: /tmp/positions.yaml + +clients: + - url: http://loki:3100/loki/api/v1/push + +scrape_configs: +- job_name: system + static_configs: + - targets: + - localhost + labels: + job: varlogs + __path__: /var/log/*log diff --git a/loki/jenkins/Jenkinsfile b/loki/jenkins/Jenkinsfile new file mode 100644 index 0000000..474139d --- /dev/null +++ b/loki/jenkins/Jenkinsfile @@ -0,0 +1,26 @@ +pipeline { + agent any + + stages { + stage('Git pull && docker compose restart') { + steps { + sshPublisher(publishers: [sshPublisherDesc(configName: 'infra.1', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '''cd /home/rschneider/infra + git pull + cd /home/rschneider/infra/loki/docker-compose/loki + docker compose down + docker compose up -d + ''', execTimeout: 120000, + flatten: false, + makeEmptyDirs: false, + noDefaultExcludes: false, + patternSeparator: '[, ]+', + remoteDirectory: '', + remoteDirectorySDF: false, + removePrefix: '', sourceFiles: '')], + usePromotionTimestamp: false, + useWorkspaceInPromotion: false, + verbose: true)]) + } + } + } +}