This charm operates the Prometheus Blackbox Exporter on bare metal, VMs, machines, LXD, etc. It complements the Blackbox Exporter Operator K8s charm. Prometheus Blackbox Exporter is a monitoring tool that probes external endpoints over protocols like HTTP, HTTPS, DNS, TCP, ICMP, and gRPC to assess their availability, performance, and health from an external perspective.
As an operator for Blackbox Exporter on Juju, this charm automates the lifecycle and provides some functionalities out of the box. This charm is a subordinate charm - that means, it needs to be related to a principal charm and it will scale up and down along with that principal charm. Also, for the purpose of scraping probe_success metrics, it's required that there is an Opentelemetry Collector machine charm on every machine with a Blackbox Exporter unit and the BE and Opentelemetry Collector units are related.
Note that instead of Opentelemetry Collector, you may also use Grafana Agent or any other charm that implements the
CosAgentConsumerclass.
This charm offers:
- Automatic cross-unit connectivity checks between all machines hosting a Blackbox Exporter unit. Each unit of Blackbox Exporter attempts to test its connectivity to all of its peers over all networks. For this reason, each unit creates Prometheus-compatible scrape jobs where the targets are the addresses of all of the other BE units across different network interfaces. This option relies on the
ICMPmodule to perform these checks. - A
probes_fileconfig option which allows an admin to provide their own Prometheus-compatible scrape jobs. The charm will then forward these scrape jobs over thecos_agentinterface to the charm scraping it e.g. Opentelemetry Collector. - A
config_fileconfig option which allows an admin to specify their desired probing modules and parameters in YAML format. By default, this charm uses the following modules which should meet most probing needs. If at any point more complex probes are needed, they can be supplied through this option. Upon providing a value, basic validation will be performed and the charm will be set toBlockedif the config is deemed invalid.
modules:
http_2xx:
prober: http
timeout: 10s
tcp_connect:
prober: tcp
timeout: 10s
icmp:
prober: icmp
timeout: 10s
icmp:
preferred_ip_protocol: "ip4"
ip_protocol_fallback: trueThe exercise below walks you through what a typical set up for this charm looks like. Ensure you have installed Juju and bootstrap a LXD cloud. The goal of the exercise is to see how Blackbox Exporter can perform automatic cross-unit connectivity checks, accept custom probe scrape jobs, integrate with the rest of the COS/COS Lite solution, provide dashboards, etc. To start, deploy the following bundle.
default-base: ubuntu@24.04/stable
applications:
be:
charm: local:blackbox-exporter-operator-0
otel:
charm: opentelemetry-collector
channel: 2/edge
revision: 148
ubuntu:
charm: ubuntu
channel: latest/stable
revision: 26
num_units: 2
to:
- "0"
- "1"
constraints: arch=amd64
storage:
block: loop,100M
files: rootfs,100M
machines:
"0":
constraints: arch=amd64
"1":
constraints: arch=amd64
relations:
- - ubuntu:juju-info
- be:juju-info
- - ubuntu:juju-info
- otel:juju-info
- - otel:cos-agent
- be:cos-agent
Now, you can use the probes_file config option to provide some custom targets you are interested in probing.
Do
juju config be probes_file=@probes.yamlwhere probes.yaml is:
scrape_configs:
- job_name: blackbox-http
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- charmhub.io
- ubuntu.com
Note: when providing custom scrape jobs, you do not need to specify the
relabel_configssection. The charm automatically enhances the custom jobs with this information.
Assuming you have Prometheus deployed in a K8s model, you will need to create an offer. For example, do
juju offer prometheus:receive-remote-writeIn your LXD model containing the deployment above, do
juju consume <k8s-controller-name>:admin/<cos-lite-model-name>.prometheusand
juju integrate otel prometheusNow Opentelemetry Collector will remote write the time-series containing the probe results into Prometheus.
This charm comes with a dashboard which provides a comprehensive view and summary of probe results, among other metrics. For this to work, you need to ensure you have the Grafana K8s charms deployed inside your K8s model. Create an offer for Grafana to receive dashboards from Opentelemetry Collector.
juju offer graf:grafana-dashboardNow, relate Opentelemetry Collector to Grafana.
juju integrate otel grafanaFor dashboards to display all necessary data, ensure both Prometheus and Loki are datasources for Grafana. For this purpose, do
juju integrate loki grafana:grafana-source
juju integrate prometheus grafana:grafana-sourceOpentelemetry Collector is capable of gathering logs by the prometheus-blackbox-exporter snap (managed by this snap), and forwarding them to Loki.
Create an offer for Loki to receive logs from Opentelemetry Collector.
juju offer loki:loggingNow, relate Opentelemetry Collector to Grafana.
juju integrate otel lokiThe end deployment should look something like:
graph LR
subgraph VM model
BE ---|juju-info| Ubuntu
Ubuntu ---|juju-info| Otelcol
BE ---|cos-agent| Otelcol
end
subgraph K8s model
Prometheus
Grafana
Loki
end
Otelcol --->|remote-write| Prometheus
Otelcol --->|grafana-dashboard| Grafana
Otelcol --->|loki-push-api| Loki
Grafana --->|grafana-source| Prometheus
Grafana --->|grafana-source| Loki