From 753fb48b20ec3877e09bc306800576b4f7696473 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 18 Mar 2025 14:06:29 +0000 Subject: [PATCH] add alloy --- config/prometheus.yml | 16 ++++++------- docker-compose.yml | 39 ++++++++---------------------- loki/docker-compose.yaml | 52 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 loki/docker-compose.yaml diff --git a/config/prometheus.yml b/config/prometheus.yml index b5edd6c..6cf032d 100644 --- a/config/prometheus.yml +++ b/config/prometheus.yml @@ -47,10 +47,10 @@ scrape_configs: - targets: ['10.249.84.41:9060'] # Loki metrics - # - job_name: 'loki' - # sample_limit: 50000 - # static_configs: - # - targets: ['loki:3100'] + - job_name: 'loki' + sample_limit: 50000 + static_configs: + - targets: ['loki:3100'] # Grafana metrics - job_name: 'grafana' @@ -59,7 +59,7 @@ scrape_configs: - targets: ['grafana:3000'] # Alloy metrics - # - job_name: 'alloy' - # sample_limit: 50000 - # static_configs: - # - targets: ['alloy:12345'] + - job_name: 'alloy' + sample_limit: 50000 + static_configs: + - targets: ['10.249.84.41:9030'] diff --git a/docker-compose.yml b/docker-compose.yml index 07b1a95..0415fb3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,4 @@ services: - # Grafana for visualization grafana: image: grafana/grafana:latest container_name: grafana @@ -29,34 +28,15 @@ services: networks: - monitoring - # loki: - # image: grafana/loki:latest - # container_name: loki - # ports: - # - "9020:3100" - # volumes: - # - ./config/loki.yml:/etc/loki/local-config.yaml - # - loki-data:/var/loki - # restart: unless-stopped - # networks: - # - monitoring - - # alloy: - # image: grafana/alloy:latest - # container_name: grafana-alloy - # ports: - # - "9030:12345" - # volumes: - # - ./config/alloy.conf:/etc/alloy/config.alloy - # - alloy-data:/var/lib/alloy/data - # command: - # - run - # - --server.http.listen-addr=0.0.0.0:12345 - # - --storage.path=/var/lib/alloy/data - # - /etc/alloy/config.alloy - # restart: unless-stopped - # networks: - # - monitoring + loki: + image: grafana/loki:latest + container_name: loki + ports: + - "9020:3100" + command: -config.file=/etc/loki/local-config.yaml + restart: unless-stopped + networks: + - monitoring # AlertManager for handling alerts alertmanager: @@ -88,6 +68,7 @@ services: - '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.templates=/etc/prometheus/consoles' - '--web.enable-lifecycle' + - "--web.enable-remote-write-receiver" restart: unless-stopped networks: - monitoring diff --git a/loki/docker-compose.yaml b/loki/docker-compose.yaml new file mode 100644 index 0000000..c36314c --- /dev/null +++ b/loki/docker-compose.yaml @@ -0,0 +1,52 @@ +version: "3.3" + +networks: + loki: + +services: + loki: + image: grafana/loki:latest + ports: + - "3100:3100" + command: -config.file=/etc/loki/local-config.yaml + networks: + - loki + + promtail: + image: grafana/promtail:latest + volumes: + - /var/log:/var/log + command: -config.file=/etc/promtail/config.yml + networks: + - loki + + grafana: + environment: + - GF_PATHS_PROVISIONING=/etc/grafana/provisioning + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + - GF_FEATURE_TOGGLES_ENABLE=alertingSimplifiedRouting,alertingQueryAndExpressionsStepMode + entrypoint: + - sh + - -euc + - | + mkdir -p /etc/grafana/provisioning/datasources + cat < /etc/grafana/provisioning/datasources/ds.yaml + apiVersion: 1 + datasources: + - name: Loki + type: loki + access: proxy + orgId: 1 + url: http://loki:3100 + basicAuth: false + isDefault: true + version: 1 + editable: false + EOF + /run.sh + image: grafana/grafana:latest + ports: + - "3000:3000" + networks: + - loki