complete observability stak alloy
This commit is contained in:
169
docker-compose-alloy/alloy-config.alloy
Normal file
169
docker-compose-alloy/alloy-config.alloy
Normal file
@@ -0,0 +1,169 @@
|
||||
// Grafana Alloy Configuration
|
||||
// Sostituisce: Promtail + Node Exporter + OTEL Collector
|
||||
|
||||
// ============================================================================
|
||||
// LOGGING - Raccolta log dai container Docker (sostituisce Promtail)
|
||||
// ============================================================================
|
||||
|
||||
// Scopri container Docker con label logging=promtail
|
||||
discovery.docker "containers" {
|
||||
host = "unix:///var/run/docker.sock"
|
||||
|
||||
filter {
|
||||
name = "label"
|
||||
values = ["logging=promtail"]
|
||||
}
|
||||
|
||||
refresh_interval = "5s"
|
||||
}
|
||||
|
||||
// Scrape log dai container scoperti
|
||||
loki.source.docker "containers" {
|
||||
host = "unix:///var/run/docker.sock"
|
||||
targets = discovery.docker.containers.targets
|
||||
forward_to = [loki.relabel.docker.receiver]
|
||||
}
|
||||
|
||||
// Relabeling per aggiungere label ai log
|
||||
loki.relabel "docker" {
|
||||
forward_to = [loki.write.default.receiver]
|
||||
|
||||
rule {
|
||||
source_labels = ["__meta_docker_container_name"]
|
||||
regex = "/(.*)"
|
||||
target_label = "container"
|
||||
}
|
||||
|
||||
rule {
|
||||
source_labels = ["__meta_docker_container_label_logging_jobname"]
|
||||
target_label = "job"
|
||||
}
|
||||
}
|
||||
|
||||
// Scrivi i log a Loki
|
||||
loki.write "default" {
|
||||
endpoint {
|
||||
url = "http://loki:3100/loki/api/v1/push"
|
||||
}
|
||||
|
||||
external_labels = {
|
||||
environment = "production",
|
||||
cluster = "myapp-cluster",
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// METRICS - Metriche sistema host (sostituisce Node Exporter)
|
||||
// ============================================================================
|
||||
|
||||
// Scraping metriche locali dell'host
|
||||
prometheus.exporter.unix "host" {
|
||||
// Raccoglie metriche del sistema operativo
|
||||
set_collectors = [
|
||||
"cpu",
|
||||
"loadavg",
|
||||
"meminfo",
|
||||
"netdev",
|
||||
"diskstats",
|
||||
"filesystem",
|
||||
"uname",
|
||||
"time",
|
||||
]
|
||||
}
|
||||
|
||||
// Scrape delle metriche raccolte
|
||||
prometheus.scrape "host_metrics" {
|
||||
targets = prometheus.exporter.unix.host.targets
|
||||
forward_to = [prometheus.remote_write.default.receiver]
|
||||
|
||||
scrape_interval = "10s"
|
||||
|
||||
clustering {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
// Scraping self-monitoring di Alloy
|
||||
prometheus.scrape "alloy_metrics" {
|
||||
targets = [{
|
||||
__address__ = "localhost:12345",
|
||||
}]
|
||||
forward_to = [prometheus.remote_write.default.receiver]
|
||||
|
||||
scrape_interval = "10s"
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// TRACES - Ricezione traces OTLP (sostituisce OTEL Collector)
|
||||
// ============================================================================
|
||||
|
||||
// Ricevi traces via OTLP gRPC
|
||||
otelcol.receiver.otlp "default" {
|
||||
grpc {
|
||||
endpoint = "0.0.0.0:4317"
|
||||
}
|
||||
|
||||
http {
|
||||
endpoint = "0.0.0.0:4318"
|
||||
}
|
||||
|
||||
output {
|
||||
metrics = [otelcol.processor.batch.default.input]
|
||||
logs = [otelcol.processor.batch.default.input]
|
||||
traces = [otelcol.processor.batch.default.input]
|
||||
}
|
||||
}
|
||||
|
||||
// Batch processor per ottimizzare l'invio
|
||||
otelcol.processor.batch "default" {
|
||||
timeout = "10s"
|
||||
send_batch_size = 10000
|
||||
send_batch_max_size = 11000
|
||||
|
||||
output {
|
||||
metrics = [otelcol.exporter.prometheus.default.input]
|
||||
traces = [otelcol.exporter.otlp.tempo.input]
|
||||
logs = [otelcol.exporter.loki.default.input]
|
||||
}
|
||||
}
|
||||
|
||||
// Esporta metriche OTLP a Prometheus
|
||||
otelcol.exporter.prometheus "default" {
|
||||
forward_to = [prometheus.remote_write.default.receiver]
|
||||
}
|
||||
|
||||
// Esporta traces a Tempo
|
||||
otelcol.exporter.otlp "tempo" {
|
||||
client {
|
||||
endpoint = "tempo:4317"
|
||||
tls {
|
||||
insecure = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Esporta log OTLP a Loki
|
||||
otelcol.exporter.loki "default" {
|
||||
forward_to = [loki.write.default.receiver]
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// REMOTE WRITE - Invia metriche a Prometheus
|
||||
// ============================================================================
|
||||
|
||||
prometheus.remote_write "default" {
|
||||
endpoint {
|
||||
url = "http://prometheus:9090/api/v1/write"
|
||||
|
||||
metadata_config {
|
||||
send_interval = "1m"
|
||||
}
|
||||
|
||||
queue_config {
|
||||
capacity = 10000
|
||||
max_shards = 10
|
||||
min_shards = 1
|
||||
max_samples_per_send = 5000
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user