9966851e75
- Create .gitignore to exclude Python-generated files and virtual environments - Add .python-version for Python version management - Initialize README.md with project description and usage instructions - Implement alloy.river configuration for Grafana Alloy observability - Set up grafana.ini for Grafana configuration - Configure dashboards.yml for automatic dashboard loading in Grafana - Define datasources.yml for connecting Grafana to Prometheus, Loki, and Tempo - Establish loki.yaml configuration for Loki logging - Set up prometheus.yml for Prometheus metrics collection - Configure tempo.yaml for Tempo tracing - Create docker-compose.yml for orchestrating services - Develop init.sh script for initializing project directories and services - Implement main.py as the entry point for the application - Define pyproject.toml for project metadata and dependencies - Update uv.lock for dependency management
208 lines
4.8 KiB
Plaintext
208 lines
4.8 KiB
Plaintext
//=============================================================================
|
|
// GRAFANA ALLOY - PUERTA DE ENTRADA ÚNICA DE OBSERVABILIDAD
|
|
//=============================================================================
|
|
|
|
//=============================================================================
|
|
// PROMETHEUS - MÉTRICAS
|
|
//=============================================================================
|
|
|
|
// Scraping del propio Alloy
|
|
prometheus.scrape "alloy" {
|
|
targets = [{"__address__" = "localhost:12345"}]
|
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
|
scrape_interval = "15s"
|
|
metrics_path = "/metrics"
|
|
job_name = "alloy"
|
|
}
|
|
|
|
// Scraping de Prometheus
|
|
prometheus.scrape "prometheus" {
|
|
targets = [{"__address__" = "prometheus:9090"}]
|
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
|
scrape_interval = "15s"
|
|
metrics_path = "/metrics"
|
|
job_name = "prometheus"
|
|
}
|
|
|
|
// Scraping de Grafana
|
|
prometheus.scrape "grafana" {
|
|
targets = [{"__address__" = "grafana:3000"}]
|
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
|
scrape_interval = "30s"
|
|
metrics_path = "/metrics"
|
|
job_name = "grafana"
|
|
}
|
|
|
|
// Scraping de Loki
|
|
prometheus.scrape "loki" {
|
|
targets = [{"__address__" = "loki:3100"}]
|
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
|
scrape_interval = "15s"
|
|
metrics_path = "/metrics"
|
|
job_name = "loki"
|
|
}
|
|
|
|
// Scraping de Tempo
|
|
prometheus.scrape "tempo" {
|
|
targets = [{"__address__" = "tempo:3200"}]
|
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
|
scrape_interval = "15s"
|
|
metrics_path = "/metrics"
|
|
job_name = "tempo"
|
|
}
|
|
|
|
// Receptor para métricas externas (aplicaciones que envían métricas)
|
|
prometheus.receive_http "external_metrics" {
|
|
http {
|
|
listen_address = "0.0.0.0"
|
|
listen_port = 9999
|
|
}
|
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
|
}
|
|
|
|
// Remote write a Prometheus
|
|
prometheus.remote_write "prometheus" {
|
|
endpoint {
|
|
url = "http://prometheus:9090/api/v1/write"
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
// LOKI - LOGS
|
|
//=============================================================================
|
|
|
|
// Descubrimiento de contenedores Docker
|
|
discovery.docker "docker_logs" {
|
|
host = "unix:///var/run/docker.sock"
|
|
refresh_interval = "5s"
|
|
}
|
|
|
|
// Fuente de logs de contenedores Docker
|
|
loki.source.docker "containers" {
|
|
host = "unix:///var/run/docker.sock"
|
|
targets = discovery.docker.docker_logs.targets
|
|
refresh_interval = "5s"
|
|
forward_to = [loki.relabel.docker.receiver]
|
|
}
|
|
|
|
// Relabel para contenedores Docker
|
|
loki.relabel "docker" {
|
|
forward_to = [loki.write.loki.receiver]
|
|
|
|
rule {
|
|
source_labels = ["__meta_docker_container_name"]
|
|
target_label = "container"
|
|
}
|
|
|
|
rule {
|
|
source_labels = ["__meta_docker_container_image"]
|
|
target_label = "image"
|
|
}
|
|
}
|
|
|
|
// Receptor HTTP para logs externos
|
|
loki.source.api "external_logs" {
|
|
http {
|
|
listen_address = "0.0.0.0"
|
|
listen_port = 3101
|
|
}
|
|
forward_to = [loki.write.loki.receiver]
|
|
}
|
|
|
|
// Receptor Syslog para logs del sistema
|
|
loki.source.syslog "system_logs" {
|
|
listener {
|
|
address = "0.0.0.0:1514"
|
|
protocol = "tcp"
|
|
}
|
|
forward_to = [loki.relabel.syslog.receiver]
|
|
}
|
|
|
|
// Relabel para logs del sistema
|
|
loki.relabel "syslog" {
|
|
forward_to = [loki.write.loki.receiver]
|
|
|
|
rule {
|
|
source_labels = ["__syslog_message_hostname"]
|
|
target_label = "hostname"
|
|
}
|
|
}
|
|
|
|
// Cliente Loki - destino final
|
|
loki.write "loki" {
|
|
endpoint {
|
|
url = "http://loki:3100/loki/api/v1/push"
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
// TEMPO - TRAZAS
|
|
//=============================================================================
|
|
|
|
// Receptor OTLP
|
|
otelcol.receiver.otlp "tempo" {
|
|
grpc {
|
|
endpoint = "0.0.0.0:4317"
|
|
}
|
|
http {
|
|
endpoint = "0.0.0.0:4318"
|
|
}
|
|
output {
|
|
traces = [otelcol.processor.batch.tempo.input]
|
|
}
|
|
}
|
|
|
|
// Receptor Jaeger
|
|
otelcol.receiver.jaeger "jaeger_traces" {
|
|
protocols {
|
|
grpc {
|
|
endpoint = "0.0.0.0:14250"
|
|
}
|
|
thrift_http {
|
|
endpoint = "0.0.0.0:14268"
|
|
}
|
|
thrift_compact {
|
|
endpoint = "0.0.0.0:6831"
|
|
}
|
|
}
|
|
output {
|
|
traces = [otelcol.processor.batch.tempo.input]
|
|
}
|
|
}
|
|
|
|
// Receptor Zipkin
|
|
otelcol.receiver.zipkin "zipkin_traces" {
|
|
endpoint = "0.0.0.0:9411"
|
|
output {
|
|
traces = [otelcol.processor.batch.tempo.input]
|
|
}
|
|
}
|
|
|
|
// Procesador batch
|
|
otelcol.processor.batch "tempo" {
|
|
send_batch_size = 1024
|
|
timeout = "1s"
|
|
output {
|
|
traces = [otelcol.exporter.otlp.tempo.input]
|
|
}
|
|
}
|
|
|
|
// Exportador a Tempo
|
|
otelcol.exporter.otlp "tempo" {
|
|
client {
|
|
endpoint = "http://tempo:4317"
|
|
tls {
|
|
insecure = true
|
|
}
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
// CONFIGURACIÓN GENERAL
|
|
//=============================================================================
|
|
|
|
logging {
|
|
level = "info"
|
|
format = "logfmt"
|
|
}
|