sostituito promtail con alloy
This commit is contained in:
57
vm1/alloy-config.alloy
Normal file
57
vm1/alloy-config.alloy
Normal file
@@ -0,0 +1,57 @@
|
||||
// Grafana Alloy configuration for VM1
|
||||
// Replaces Promtail for log collection and forwarding to Loki
|
||||
|
||||
// Discover Docker containers with the logging=promtail label
|
||||
discovery.docker "containers" {
|
||||
host = "unix:///var/run/docker.sock"
|
||||
refresh_interval = "5s"
|
||||
|
||||
filter {
|
||||
name = "label"
|
||||
values = ["logging=alloy"]
|
||||
}
|
||||
}
|
||||
|
||||
// Scrape logs from discovered containers
|
||||
loki.source.docker "docker_logs" {
|
||||
host = "unix:///var/run/docker.sock"
|
||||
targets = discovery.docker.containers.targets
|
||||
|
||||
forward_to = [loki.write.loki.receiver]
|
||||
|
||||
relabel_rules = loki.relabel.docker.rules
|
||||
}
|
||||
|
||||
// Relabel configuration to extract useful labels from Docker metadata
|
||||
loki.relabel "docker" {
|
||||
forward_to = []
|
||||
|
||||
rule {
|
||||
source_labels = ["__meta_docker_container_name"]
|
||||
regex = "/(.*)"
|
||||
target_label = "container"
|
||||
}
|
||||
|
||||
rule {
|
||||
source_labels = ["__meta_docker_container_label_logging_jobname"]
|
||||
target_label = "job"
|
||||
}
|
||||
|
||||
// Add external labels
|
||||
rule {
|
||||
target_label = "environment"
|
||||
replacement = "production"
|
||||
}
|
||||
|
||||
rule {
|
||||
target_label = "cluster"
|
||||
replacement = "myapp-cluster"
|
||||
}
|
||||
}
|
||||
|
||||
// Write logs to Loki
|
||||
loki.write "loki" {
|
||||
endpoint {
|
||||
url = "http://192.168.1.200:3100/loki/api/v1/push"
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ services:
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
labels:
|
||||
logging: "promtail"
|
||||
logging: "alloy"
|
||||
logging_jobname: "mysql"
|
||||
orchestrator-1-load:
|
||||
build: .
|
||||
@@ -41,7 +41,7 @@ services:
|
||||
networks:
|
||||
- app-network
|
||||
labels:
|
||||
logging: "promtail"
|
||||
logging: "alloy"
|
||||
orchestrator-2-elab:
|
||||
build: .
|
||||
container_name: orchestrator-2-elab
|
||||
@@ -58,7 +58,7 @@ services:
|
||||
networks:
|
||||
- app-network
|
||||
labels:
|
||||
logging: "promtail"
|
||||
logging: "alloy"
|
||||
orchestrator-3-send:
|
||||
build: .
|
||||
container_name: orchestrator-3-send
|
||||
@@ -75,7 +75,7 @@ services:
|
||||
networks:
|
||||
- app-network
|
||||
labels:
|
||||
logging: "promtail"
|
||||
logging: "alloy"
|
||||
ftp-server-1:
|
||||
build: .
|
||||
container_name: ftp-server-1
|
||||
@@ -102,7 +102,7 @@ services:
|
||||
expose:
|
||||
- "21"
|
||||
labels:
|
||||
logging: "promtail"
|
||||
logging: "alloy"
|
||||
sftp-server-1:
|
||||
build: .
|
||||
container_name: sftp-server-1
|
||||
@@ -127,7 +127,7 @@ services:
|
||||
ports:
|
||||
- "22:22"
|
||||
labels:
|
||||
logging: "promtail"
|
||||
logging: "alloy"
|
||||
|
||||
haproxy:
|
||||
image: haproxy:2.8-alpine
|
||||
@@ -141,7 +141,7 @@ services:
|
||||
- "21:21"
|
||||
- "8404:8404"
|
||||
labels:
|
||||
logging: "promtail"
|
||||
logging: "alloy"
|
||||
keepalived:
|
||||
image: alpine:latest
|
||||
container_name: keepalived
|
||||
@@ -154,17 +154,24 @@ services:
|
||||
volumes:
|
||||
- ./keepalived-master.conf:/etc/keepalived/keepalived.conf:ro
|
||||
command: sh -c "apk add --no-cache keepalived && keepalived -n -l -f /etc/keepalived/keepalived.conf"
|
||||
promtail:
|
||||
image: grafana/promtail:2.9.3
|
||||
container_name: promtail
|
||||
alloy:
|
||||
image: grafana/alloy:latest
|
||||
container_name: alloy
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: Europe/Rome
|
||||
volumes:
|
||||
- ./promtail-config.yml:/etc/promtail/config.yml:ro
|
||||
- ./alloy-config.alloy:/etc/alloy/config.alloy:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
command:
|
||||
- run
|
||||
- --server.http.listen-addr=0.0.0.0:12345
|
||||
- --storage.path=/var/lib/alloy/data
|
||||
- /etc/alloy/config.alloy
|
||||
ports:
|
||||
- "12345:12345" # Alloy UI
|
||||
networks:
|
||||
- app-network
|
||||
networks:
|
||||
|
||||
Reference in New Issue
Block a user