Alloy http monitor

From UVOO Tech Wiki
Revision as of 06:55, 2 July 2025 by Busk (talk | contribs) (Created page with "``` // config.alloy prometheus.exporter.blackbox "my_blackbox_exporter" { // Define modules directly within the Alloy config config = { modules = { http_2xx = {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
// config.alloy
prometheus.exporter.blackbox "my_blackbox_exporter" {
  // Define modules directly within the Alloy config
  config = {
    modules = {
      http_2xx = {
        prober = "http",
        timeout = "5s",
        http = {
          valid_http_versions = ["HTTP/1.1", "HTTP/2.0"],
          no_follow_redirects = false,
          preferred_ip_protocol = "ipv4",
          # Other http options can go here, e.g., headers, method, etc.
        }
      },
      tcp_connect = {
        prober = "tcp",
        timeout = "5s",
      },
      icmp_ping = {
        prober = "icmp",
        timeout = "5s",
      },
    }
  }

  // Define the targets to probe
  target {
    name    = "google_website"
    address = "https://google.com"
    module  = "http_2xx"
    labels = {
      instance = "google-website-probe",
      env      = "production",
      type     = "website"
    }
  }

  target {
    name    = "cloudflare_dns"
    address = "1.1.1.1:53"
    module  = "tcp_connect"
    labels = {
      instance = "cloudflare-dns-probe",
      env      = "production",
      type     = "dns"
    }
  }

  target {
    name    = "my_backend_api"
    address = "http://my-internal-api:80/healthz"
    module  = "http_2xx"
    labels = {
      instance = "backend-api-probe",
      env      = "development",
      type     = "api"
    }
  }
}

// Scrape metrics from the Blackbox Exporter
prometheus.scrape "blackbox_scrapes" {
  targets = prometheus.exporter.blackbox.my_blackbox_exporter.targets
  forward_to = [prometheus.remote_write.mimir_receiver.receiver]

  scrape_interval = "30s"
  scrape_timeout  = "15s"
}

// Send metrics to Mimir
prometheus.remote_write "mimir_receiver" {
  endpoint {
    url = "http://your-mimir-endpoint:9009/api/v1/push" // Replace with your Mimir push gateway URL
    // ... (basic_auth, tls as needed)
  }
}

logging {
  level  = "info"
  format = "logfmt"
}