Synthetic Probes and API Metrics
These examples cover synthetic probes and API-backed exporters. They are great for checking uptime and collecting third-party stats.
Example: Blackbox Probes (Synthetic Monitoring)
06-blackbox.alloy
prometheus.exporter.blackbox "local" {
config = "{ modules: { http_2xx: { prober: http, timeout: 5s } } }"
target {
name = "techbloomeracademy"
address = "https://techbloomeracademy.com"
module = "http_2xx"
}
target {
name = "gobotify"
address = "https://gobotify.com"
module = "http_2xx"
}
}
// Configure a prometheus.scrape component to collect blackbox metrics.
prometheus.scrape "demo" {
targets = prometheus.exporter.blackbox.local.targets
forward_to = [prometheus.relabel.common_labels.receiver]
}
Example: GitHub Repository Metrics
11-github.alloy
// 11-github.alloy
prometheus.exporter.github "my_github_stats" {
api_token = sys.env("GITHUB_TOKEN")
repositories = ["learnwithvikasjha/tba-docs","learnwithvikasjha/gobotify"]
}
discovery.relabel "github_relabel" {
targets = prometheus.exporter.github.my_github_stats.targets
rule {
target_label = "job"
replacement = "integrations/github"
}
}
prometheus.scrape "github_scrape" {
targets = discovery.relabel.github_relabel.output
forward_to = [prometheus.relabel.common_labels.receiver]
}
tip
Store your GITHUB_TOKEN as an environment variable so it is not committed into config files.