commit 4b499a1767385b47c0f93e8eb0ec3e3d52cbd9fb
Author: royalcat <k.adamovich20@gmail.com>
Date:   Mon Feb 26 14:11:49 2024 +0300

    init

diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 0000000..8a1c0b4
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,126 @@
+version: "3"
+
+services:
+  otel-collector:
+    image: otel/opentelemetry-collector-contrib:0.95.0
+    restart: always
+    command: "--config=/etc/otel-collector-config.yaml"
+    volumes:
+      - ./otel-collector/config.yaml:/etc/otel-collector-config.yaml
+    ports:
+      - 4317:4317   # OTLP gRPC receiver
+      - 4318:4318 # OTLP http receiver
+    expose:
+      - 13133:13133 # health_check extension
+      - 8889:8889   # Prometheus exporter metrics
+      - 8888:8888 # Prometheus metrics exposed by the Collector
+    depends_on:
+      - loki
+      - prometheus
+      - tempo
+
+  loki:
+    image: grafana/loki:2.9.2
+    expose:
+      - "3100"
+    command: -config.file=/etc/loki/config.yaml
+    volumes:
+      - ./loki/config.yaml:/etc/loki/config.yaml
+      - loki_data:/loki
+
+  prometheus:
+    image: prom/prometheus:v2.36.2
+    restart: always
+    expose:
+      - "9090"
+    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"
+  
+  tempo:
+    image: grafana/tempo:2.3.1
+    command: [ "-config.file=/etc/tempo/config.yaml" ]
+    depends_on:
+      - prometheus
+    volumes:
+      - ./tempo/config.yaml:/etc/tempo/config.yaml
+      - tempo_data:/tempo-data
+    expose:
+      - "3200"  # tempo
+      - "4317"  # otlp grpc
+      - "4318"  # otlp http
+
+  grafana:
+    image: grafana/grafana:10.0.10
+    depends_on:
+      - loki
+      - prometheus
+      - tempo
+    environment:
+      GF_SERVER_ROOT_URL: ${GRAFANA_URL}
+      GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD}
+      GF_AUTH_GENERIC_OAUTH_ENABLED: "true"
+      GF_AUTH_GENERIC_OAUTH_NAME: KonfachSSO
+      GF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP: "true"
+      GF_AUTH_GENERIC_OAUTH_CLIENT_ID: grafana
+      GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET: oraMLSBuIaSPqZElSNRZ6gntM2xizjXL
+      GF_AUTH_GENERIC_OAUTH_SCOPES: openid email profile offline_access roles
+      GF_AUTH_GENERIC_OAUTH_EMAIL_ATTRIBUTE_PATH: email
+      GF_AUTH_GENERIC_OAUTH_LOGIN_ATTRIBUTE_PATH: username
+      GF_AUTH_GENERIC_OAUTH_NAME_ATTRIBUTE_PATH: full_name
+      GF_AUTH_GENERIC_OAUTH_AUTH_URL: https://sso.konfach.ru/realms/myavo/protocol/openid-connect/auth
+      GF_AUTH_GENERIC_OAUTH_TOKEN_URL: https://sso.konfach.ru/realms/myavo/protocol/openid-connect/token
+      GF_AUTH_GENERIC_OAUTH_API_URL: https://sso.konfach.ru/realms/myavo/protocol/openid-connect/userinfo
+      GF_AUTH_GENERIC_OAUTH_ROLE_ATTRIBUTE_PATH: "contains(realm_access.roles[*], 'developer') && 'Editor'"
+      GF_AUTH_GENERIC_OAUTH_ROLE_ATTRIBUTE_STRICT: "true"
+    volumes:
+      - grafana_data:/var/lib/grafana
+    entrypoint:
+      - sh
+      - -euc
+      - |
+        mkdir -p /etc/grafana/provisioning/datasources
+        cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml
+        apiVersion: 1
+        datasources:
+        - name: Loki
+          type: loki
+          access: proxy 
+          orgId: 1
+          url: http://loki:3100
+          basicAuth: false
+          isDefault: false
+          version: 1
+          editable: false
+        - name: Prometheus
+          type: prometheus
+          access: proxy
+          orgId: 1
+          url: http://prometheus:9090
+          basicAuth: false
+          isDefault: false
+          version: 1
+          editable: false
+        - name: Tempo
+          type: tempo
+          access: proxy
+          orgId: 1
+          url: http://tempo:3200
+          basicAuth: false
+          isDefault: false
+          version: 1
+          editable: false
+          jsonData:
+            httpMethod: GET
+        EOF
+        /run.sh
+
+volumes:
+  loki_data:
+  prometheus_data:
+  tempo_data:
+  grafana_data:
\ No newline at end of file
diff --git a/loki/config.yaml b/loki/config.yaml
new file mode 100644
index 0000000..67e6a8e
--- /dev/null
+++ b/loki/config.yaml
@@ -0,0 +1,47 @@
+auth_enabled: false
+
+server:
+  http_listen_port: 3100
+
+common:
+  instance_addr: 127.0.0.1
+  path_prefix: /loki
+  storage:
+    filesystem:
+      chunks_directory: /loki/chunks
+      rules_directory: /loki/rules
+  replication_factor: 1
+  ring:
+    kvstore:
+      store: inmemory
+
+limits_config:
+  allow_structured_metadata: true
+  retention_period: 90d
+
+query_range:
+  results_cache:
+    cache:
+      embedded_cache:
+        enabled: true
+        max_size_mb: 100
+
+compactor:
+  working_directory: /loki/compactor
+  compaction_interval: 10m
+  retention_enabled: true
+  retention_delete_delay: 2h
+  retention_delete_worker_count: 150
+
+schema_config:
+  configs:
+    - from: 2020-10-24
+      store: boltdb-shipper
+      object_store: filesystem
+      schema: v13
+      index:
+        prefix: index_
+        period: 24h
+
+ruler:
+  alertmanager_url: http://localhost:9093
diff --git a/otel-collector/config.yaml b/otel-collector/config.yaml
new file mode 100644
index 0000000..9acb8d5
--- /dev/null
+++ b/otel-collector/config.yaml
@@ -0,0 +1,45 @@
+receivers:
+  otlp:
+    protocols:
+      grpc:
+        endpoint: 0.0.0.0:4317
+      http:
+        endpoint: 0.0.0.0:4318
+processors:
+  batch:
+
+exporters:
+  tempo:
+    endpoint: tempo:4317
+  prometheus:
+    endpoint: http://prometheus:9411/api/prom/push
+    tls:
+      insecure: true
+  loki:
+    endpoint: http://loki:3100/loki/api/v1/push
+    tls:
+      insecure: true
+    default_labels_enabled:
+      exporter: false
+      job: true
+
+# extensions:
+#   health_check:
+#   pprof:
+#   zpages:
+
+service:
+  extensions: [health_check, pprof, zpages]
+  pipelines:
+    traces:
+      receivers: [otlp]
+      processors: [batch]
+      exporters: [tempo]
+    metrics:
+      receivers: [otlp]
+      processors: [batch]
+      exporters: [prometheus]
+    logs:
+      receivers: [otlp]
+      processors: [batch]
+      exporters: [loki]
diff --git a/prometheus/config.yaml b/prometheus/config.yaml
new file mode 100644
index 0000000..650d102
--- /dev/null
+++ b/prometheus/config.yaml
@@ -0,0 +1,7 @@
+global:
+  scrape_interval: 15s
+
+scrape_configs:
+  - job_name: "prometheus"
+    static_configs:
+      - targets: ["localhost:9090"]
\ No newline at end of file
diff --git a/tempo/config.yaml b/tempo/config.yaml
new file mode 100644
index 0000000..e3d8110
--- /dev/null
+++ b/tempo/config.yaml
@@ -0,0 +1,34 @@
+stream_over_http_enabled: true
+server:
+  http_listen_port: 3200
+  log_level: info
+
+distributor:
+  receivers:
+    otlp:
+      protocols:
+        http:
+        grpc:
+
+metrics_generator:
+  registry:
+    external_labels:
+      source: trace
+  storage:
+    path: /tempo-data/generator/wal
+    remote_write:
+      - url: http://prometheus:9090/api/v1/write
+        send_exemplars: true
+
+storage:
+  trace:
+    backend: local # backend configuration to use
+    wal:
+      path: /tempo-data/wal # where to store the the wal locally
+    local:
+      path: /tempo-data/blocks
+
+overrides:
+  defaults:
+    metrics_generator:
+      processors: [service-graphs, span-metrics] # enables metrics generator