tmp
Some checks failed
/ Ansible Lint (push) Failing after 2m17s

This commit is contained in:
lilly 2026-02-26 21:13:07 +01:00
commit 4a7df9969d
Signed by: lilly
SSH key fingerprint: SHA256:y9T5GFw2A20WVklhetIxG1+kcg/Ce0shnQmbu1LQ37g
23 changed files with 746 additions and 0 deletions

View file

@ -0,0 +1,24 @@
# {{ ansible_managed }}
modules:
https4_2xx:
prober: http
http:
valid_status_codes: [ ] # Defaults to 2xx
method: GET
follow_redirects: true
fail_if_ssl: false
fail_if_not_ssl: true
preferred_ip_protocol: "ip4"
ip_protocol_fallback: false
tcp4_connect:
prober: tcp
tcp:
preferred_ip_protocol: "ip4"
ip_protocol_fallback: false
icmp4:
prober: icmp
icmp:
preferred_ip_protocol: "ip4"
ip_protocol_fallback: false

View file

@ -0,0 +1,102 @@
// {{ ansible_managed }}
// For a full configuration reference, see https://grafana.com/docs/alloy
discovery.http "netbox_devices" {
url = "{{ alloy_netbox_uri | mandatory }}/api/plugins/prometheus-sd/devices/"
http_headers = {
"Authorization" = [ "Token {{ alloy_netbox_api_key | mandatory }}" ],
}
}
// ICMP probe definitions
discovery.relabel "icmp_probes_netbox" {
targets = discovery.http.netbox_devices.targets
// drop devices which don't have an IP address
rule {
source_labels = [ "__meta_netbox_primary_ip4" ]
regex = ".+"
action = "keep"
}
// configure target metadata from discovery
rule {
source_labels = [ "__meta_netbox_primary_ip4" ]
target_label = "address"
}
rule {
source_labels = [ "__meta_netbox_name" ]
target_label = "name"
}
rule {
source_labels = [ "__meta_netbox_location" ]
target_label = "location"
}
rule {
source_labels = [ "__meta_netbox_role" ]
target_label = "netbox_role"
}
rule {
source_labels = [ "__meta_netbox_status" ]
target_label = "netbox_status"
}
// set probe module to icmp4 to execute pings via ipv4
rule {
target_label = "module"
replacement = "icmp4"
}
}
discovery.file "icmp_probes" {
files = [ "/etc/alloy/icmp_probes.json" ]
}
prometheus.exporter.blackbox "icmp" {
config_file = "/etc/alloy/blackbox-exporter-config.yaml"
targets = discovery.file.icmp_probes.targets
}
// HTTPS probe definitions
prometheus.exporter.blackbox "web" {
config_file = "/etc/alloy/blackbox-exporter-config.yaml"
target {
name = "eurofurence.org"
address = "https://www.eurofurence.org/EF29/"
module = "https4_2xx"
labels = { probed_instance = "eurofurence.org" }
}
}
// scraping config
discovery.relabel "blackbox_probes" {
targets = array.concat(
prometheus.exporter.blackbox.icmp.targets,
prometheus.exporter.blackbox.web.targets,
)
// add "probe_module" label based on which probe module was used
rule {
source_labels = [ "__param_module" ]
target_label = "probe_module"
}
// add "probe_target" label based on what was probed
rule {
source_labels = [ "__param_target" ]
target_label = "probe_target"
}
}
prometheus.scrape "blackbox_probes" {
targets = discovery.relabel.blackbox_probes.output
forward_to = [ prometheus.remote_write.ef_mimir.receiver ]
scrape_interval = "30s"
scrape_timeout = "30s"
}

View file

@ -0,0 +1,34 @@
[
{% for i in query("netbox.netbox.nb_lookup", "devices", api_endpoint="https://netbox.ef.scientress.de/") -%}
{% if i.value.role.slug not in ["patchpanel", "accesspoint"] -%}
{
"targets": [ "" ],
"labels": {
"name": "{{ i.value.name }}",
"probed_instance": "{{ i.value.name }}",
"location": "{{ i.value.location.name | default("unknown") }}",
"netbox_type": "device",
"netbox_role": "{{ i.value.role.slug | default("undefined") }}",
"netbox_status": "{{ i.value.status.value }}",
"module": "icmp4",
"address": "{{ (i.value.primary_ip4.address | default("192.0.2.0/24")).rsplit("/", maxsplit=1) | first }}"
}
},
{% endif %}
{% endfor %}
{% for i in query("netbox.netbox.nb_lookup", "virtual-machines", api_endpoint="https://netbox.ef.scientress.de/") -%}
{
"targets": [ "" ],
"labels": {
"name": "{{ i.value.name }}",
"probed_instance": "{{ i.value.name }}",
"netbox_type": "virtual-machine",
"netbox_role": "{{ i.value.role.slug | default("undefined") }}",
"netbox_status": "{{ i.value.status.value }}",
"module": "icmp4",
"address": "{{ (i.value.primary_ip4.address | default("192.0.2.0/24")).rsplit("/", maxsplit=1) | first }}"
}
}{% if not loop.last %},{% endif %}
{% endfor %}
]

View file

@ -0,0 +1,19 @@
// {{ ansible_managed }}
// For a full configuration reference, see https://grafana.com/docs/alloy
otelcol.receiver.syslog "ef_syslog" {
location = "Europe/Berlin"
tcp {
listen_address = "{{ primary_ip4 }}:514"
}
udp {
listen_address = "{{ primary_ip4 }}:514"
}
output {
logs = [ otelcol.processor.batch.default.input ]
metrics = [ otelcol.processor.batch.default.input ]
traces = [ otelcol.processor.batch.default.input ]
}
}