Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 184 additions & 0 deletions docker/alloy-config.river
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// Grafana Alloy configuration for Linera validator observability
// Collects metrics, logs, and traces and forwards to central stack

// ==================== Prometheus Metrics Scraping ====================

// Scrape metrics from proxy service
prometheus.scrape "proxy_metrics" {
targets = [{
__address__ = "proxy:21100",
job = "linera-proxy",
instance = env("HOSTNAME"),
}]

// Forward to OTLP converter for remote push if configured
forward_to = [otelcol.receiver.prometheus.default.receiver]

scrape_interval = "15s"
scrape_timeout = "10s"
}

// Scrape metrics from shard services (all 4 replicas)
prometheus.scrape "shard_metrics" {
targets = [
{
__address__ = "shard:21100",
job = "linera-shard",
instance = env("HOSTNAME"),
},
]

// Forward to OTLP converter for remote push if configured
forward_to = [otelcol.receiver.prometheus.default.receiver]

scrape_interval = "15s"
scrape_timeout = "10s"
}

// Expose Alloy's own metrics
prometheus.exporter.self "alloy" {}

prometheus.scrape "alloy_metrics" {
targets = prometheus.exporter.self.alloy.targets
// Forward to OTLP converter for remote push if configured
forward_to = [otelcol.receiver.prometheus.default.receiver]
}

// ==================== Prometheus Metrics Export (Optional) ====================

// Convert Prometheus metrics to OTLP and send to central (Prometheus 3.x uses OTLP)
// To enable, set these environment variables:
// PROMETHEUS_OTLP_URL: https://your-prometheus-endpoint/otlp
// PROMETHEUS_OTLP_USER: your-username
// PROMETHEUS_OTLP_PASS: your-password

// Export Prometheus metrics as OTLP
otelcol.exporter.otlphttp "prometheus" {
client {
endpoint = env("PROMETHEUS_OTLP_URL")

auth = otelcol.auth.basic.prometheus_credentials.handler

tls {
insecure_skip_verify = false
}
}
}

// Basic auth for Prometheus OTLP
otelcol.auth.basic "prometheus_credentials" {
username = env("PROMETHEUS_OTLP_USER")
password = env("PROMETHEUS_OTLP_PASS")
}

// Convert Prometheus metrics to OTLP format
otelcol.receiver.prometheus "default" {
output {
metrics = [otelcol.exporter.otlphttp.prometheus.input]
}
}

// ==================== Loki Logs Collection ====================

// Discover docker containers
discovery.docker "containers" {
host = "unix:///var/run/docker.sock"
}

// Relabel discovered containers
discovery.relabel "docker_logs" {
targets = discovery.docker.containers.targets

rule {
source_labels = ["__meta_docker_container_name"]
target_label = "container"
}

rule {
source_labels = ["__meta_docker_container_label_com_docker_compose_service"]
target_label = "service"
}

rule {
source_labels = ["__meta_docker_container_label_com_docker_compose_project"]
target_label = "project"
}
}

// Read docker logs
loki.source.docker "containers" {
host = "unix:///var/run/docker.sock"
targets = discovery.relabel.docker_logs.output
forward_to = [loki.write.central.receiver]
}

// Write logs to central Loki (optional - only if env vars are set)
// To enable, set these environment variables:
// LOKI_PUSH_URL: https://your-loki-endpoint/loki/api/v1/push
// LOKI_PUSH_USER: your-username
// LOKI_PUSH_PASS: your-password
loki.write "central" {
endpoint {
url = env("LOKI_PUSH_URL")

basic_auth {
username = env("LOKI_PUSH_USER")
password = env("LOKI_PUSH_PASS")
}

tls_config {
insecure_skip_verify = false
}
}

external_labels = {
cluster = "validator-docker-compose",
validator = env("HOSTNAME"),
}
}

// ==================== Tempo Traces Collection ====================

// OTLP receiver for traces
otelcol.receiver.otlp "default" {
grpc {
endpoint = "0.0.0.0:4317"
}

http {
endpoint = "0.0.0.0:4318"
}

output {
traces = [otelcol.exporter.otlphttp.central.input]
}
}

// Export traces to central Tempo (optional - only if env vars are set)
// To enable, set these environment variables:
// TEMPO_OTLP_URL: https://your-tempo-endpoint/tempo/otlp
// TEMPO_OTLP_USER: your-username
// TEMPO_OTLP_PASS: your-password
otelcol.exporter.otlphttp "central" {
client {
endpoint = env("TEMPO_OTLP_URL")

auth = otelcol.auth.basic.credentials.handler

tls {
insecure_skip_verify = false
}
}
}

// Basic auth for OTLP
otelcol.auth.basic "credentials" {
username = env("TEMPO_OTLP_USER")
password = env("TEMPO_OTLP_PASS")
}

// ==================== Metrics Exposition ====================

// Expose Prometheus-compatible metrics endpoint for central Prometheus to scrape
// This runs on port 12345 and exposes all collected metrics
// Note: Alloy's own metrics are already exposed via prometheus.exporter.self
49 changes: 49 additions & 0 deletions docker/docker-compose.alloy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Docker Compose override file to enable Grafana Alloy for central observability
#
# Usage:
# docker-compose -f docker-compose.yml -f docker-compose.alloy.yml up -d
#
# Documentation: See MONITORING.md for complete setup and configuration guide
#
# Required environment variables for remote push:
# PROMETHEUS_OTLP_URL: https://your-prometheus-endpoint/otlp
# PROMETHEUS_OTLP_USER: your-username
# PROMETHEUS_OTLP_PASS: your-password
# LOKI_PUSH_URL: https://your-loki-endpoint/loki/api/v1/push
# LOKI_PUSH_USER: your-username
# LOKI_PUSH_PASS: your-password
# TEMPO_OTLP_URL: https://your-tempo-endpoint/tempo/otlp
# TEMPO_OTLP_USER: your-username
# TEMPO_OTLP_PASS: your-password

services:
alloy:
image: grafana/alloy:latest
container_name: alloy
ports:
- "12345:12345" # Prometheus metrics exposition
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP HTTP receiver
volumes:
- ./alloy-config.river:/etc/alloy/config.river:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
command:
- "run"
- "--server.http.listen-addr=0.0.0.0:12345"
- "/etc/alloy/config.river"
environment:
- HOSTNAME=${HOSTNAME:-validator}
- PROMETHEUS_OTLP_URL=${PROMETHEUS_OTLP_URL:-}
- PROMETHEUS_OTLP_USER=${PROMETHEUS_OTLP_USER:-}
- PROMETHEUS_OTLP_PASS=${PROMETHEUS_OTLP_PASS:-}
- LOKI_PUSH_URL=${LOKI_PUSH_URL:-}
- LOKI_PUSH_USER=${LOKI_PUSH_USER:-}
- LOKI_PUSH_PASS=${LOKI_PUSH_PASS:-}
- TEMPO_OTLP_URL=${TEMPO_OTLP_URL:-}
- TEMPO_OTLP_USER=${TEMPO_OTLP_USER:-}
- TEMPO_OTLP_PASS=${TEMPO_OTLP_PASS:-}
labels:
com.centurylinklabs.watchtower.enable: "true"
depends_on:
- proxy
- shard
7 changes: 5 additions & 2 deletions kubernetes/linera-validator/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ dependencies:
- name: pyroscope
repository: https://grafana.github.io/helm-charts
version: 1.14.2
digest: sha256:7fe611b57ddb6d72aa31bac87568fdb8e531e988e2ce4067b931d3026332f027
generated: "2025-09-01T16:56:59.19795-03:00"
- name: alloy
repository: https://grafana.github.io/helm-charts
version: 1.3.1
digest: sha256:46f1afae774e69e535e8465ad9de59485fbd63c070ca431aeab1f1563752a838
generated: "2025-10-16T01:37:54.113778741+02:00"
13 changes: 9 additions & 4 deletions kubernetes/linera-validator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,29 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "1.16.1"

# Dependencies of the application being deployed.
dependencies:
- name: kube-prometheus-stack
version: "51.0.3"
repository: "https://prometheus-community.github.io/helm-charts"

condition: kube-prometheus-stack.enabled
- name: loki-stack
version: "2.8.9"
repository: "https://grafana.github.io/helm-charts"

condition: loki-stack.enabled
- name: pyroscope
version: "1.14.2"
repository: "https://grafana.github.io/helm-charts"
condition: pyroscope.enabled
- name: alloy
version: "1.3.1"
repository: "https://grafana.github.io/helm-charts"
condition: alloy.enabled
Loading
Loading