From 82b4283535883b3907016e054d5abb739f9de8c6 Mon Sep 17 00:00:00 2001
From: royalcat <k.adamovich20@gmail.com>
Date: Mon, 6 May 2024 12:34:03 +0300
Subject: [PATCH] replace prometheus with mimir

---
 docker-compose.yaml        | 23 ++++++++++-------------
 mimir/config.yaml          | 18 ++++++++++++++++++
 otel-collector/config.yaml |  6 +++---
 prometheus/config.yaml     |  7 -------
 4 files changed, 31 insertions(+), 23 deletions(-)
 create mode 100644 mimir/config.yaml
 delete mode 100644 prometheus/config.yaml

diff --git a/docker-compose.yaml b/docker-compose.yaml
index 0f90ff5..615b603 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -13,7 +13,7 @@ services:
     #   - 8888:8888 # Prometheus metrics exposed by the Collector
     links:
       - loki
-      - prometheus
+      - mimir
       - tempo
     networks:
       - www
@@ -33,7 +33,7 @@ services:
   loki:
     image: grafana/loki:3.0.0
     links:
-      - prometheus
+      - mimir
     expose:
       - "3100"
     command: -config.file=/etc/loki/config.yaml
@@ -41,23 +41,20 @@ services:
       - ./loki/config.yaml:/etc/loki/config.yaml
       - loki_data:/loki
 
-  prometheus:
-    image: prom/prometheus:v2.51.1
+  mimir:
+    image: grafana/mimir:2.12.0
     expose:
-      - "9090"
+      - "9009"
+    command: [-config.file=/etc/mimir/config.yaml]
     volumes:
-      - ./prometheus/config.yaml:/etc/prometheus/config.yaml
-      - prometheus_data:/prometheus
-    command:
-      - "--config.file=/etc/prometheus/config.yaml"
-      - "--storage.tsdb.path=/prometheus"
-      - "--web.enable-remote-write-receiver"
+      - ./mimir/config.yaml:/etc/mimir/config.yaml
+      - mimir_data:/mimir
 
   tempo:
     image: grafana/tempo:2.4.1
     command: ["-config.file=/etc/tempo/config.yaml"]
     depends_on:
-      - prometheus
+      - mimir
     volumes:
       - ./tempo/config.yaml:/etc/tempo/config.yaml
       - tempo_data:/tempo-data
@@ -99,7 +96,7 @@ networks:
 
 volumes:
   loki_data:
-  prometheus_data:
+  mimir_data:
   tempo_data:
   grafana_data:
   pyroscope_data:
diff --git a/mimir/config.yaml b/mimir/config.yaml
new file mode 100644
index 0000000..0ae347e
--- /dev/null
+++ b/mimir/config.yaml
@@ -0,0 +1,18 @@
+blocks_storage:
+  backend: filesystem
+  filesystem:
+    dir: /mimir/data
+  tsdb:
+    dir: /mimir/tsdb
+
+compactor:
+  data_dir: /mimir/compactor
+
+ruler_storage:
+  backend: filesystem
+  filesystem:
+    dir: /mimir/rules
+
+server:
+  http_listen_port: 9009
+  log_level: error
diff --git a/otel-collector/config.yaml b/otel-collector/config.yaml
index b9a52e8..117dc26 100644
--- a/otel-collector/config.yaml
+++ b/otel-collector/config.yaml
@@ -26,8 +26,8 @@ exporters:
     endpoint: tempo:4317
     tls:
       insecure: true
-  prometheusremotewrite:
-    endpoint: http://prometheus:7900/api/prom/push
+  otlphttp/mimir:
+    endpoint: http://mimir:9009/otlp
   otlphttp/loki:
     endpoint: http://loki:3100/otlp
 
@@ -46,7 +46,7 @@ service:
       receivers: [otlp, prometheus/self]
       processors: [batch]
       exporters:
-        - prometheusremotewrite
+        - otlphttp/mimir
     logs:
       receivers: [otlp]
       processors: [batch]
diff --git a/prometheus/config.yaml b/prometheus/config.yaml
deleted file mode 100644
index 650d102..0000000
--- a/prometheus/config.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-global:
-  scrape_interval: 15s
-
-scrape_configs:
-  - job_name: "prometheus"
-    static_configs:
-      - targets: ["localhost:9090"]
\ No newline at end of file