Files
Alloy/OpenWRT/openwrt.alloy

52 lines
1.1 KiB
Plaintext

import.http "libstd" {
url = "https://git.kkarolis.lt/karolis/Alloy/raw/branch/main/lib/std.alloy"
}
declare "openwrt" {
argument "forward_to" {
optional = false
comment = "Where to forward the scraped metrics"
}
argument "host" {
optional = true
comment = "The host OpenWRT collector is running on"
default = sys.env("GCLOUD_FM_COLLECTOR_ID")
}
libstd.load_host_config "load_config" {
host = argument.host.value
config_file = "OpenWRT/config.yaml"
}
discovery.relabel "openwrt_node_exporter" {
targets = libstd.load_host_config.load_config.config.targets
rule {
source_labels = ["hostname"]
target_label = "__address__"
replacement = "$1:9100"
}
rule {
action = "labelmap"
regex = "hostname"
replacement = "instance"
}
rule {
action = "labeldrop"
regex = "hostname"
}
}
prometheus.scrape "openwrt_node_exporter" {
targets = discovery.relabel.openwrt_node_exporter.output
forward_to = argument.forward_to.value
}
export "targets" {
value = discovery.relabel.openwrt_node_exporter.output
}
}