Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add blackbox probes library #43

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7f0fddb
wip - add library and use it in blackbox
giusebar Sep 10, 2024
976981b
pass full configuration in the relation
giusebar Sep 16, 2024
f6dcd4e
add library documentation, add monitor targets_changed in the charm
giusebar Sep 16, 2024
786db08
add provider and consumer tests
giusebar Sep 17, 2024
5519d53
update config file with relation modules correctly
giusebar Sep 18, 2024
c267fcc
add pydantic validation for probes and modules
giusebar Sep 25, 2024
b08a263
add pydantic check on the requirer side, small fixes
giusebar Sep 30, 2024
ce8e4df
update README
giusebar Oct 8, 2024
eff4d9a
remove unnecessary patch network get
giusebar Oct 8, 2024
ae10472
address comments
giusebar Nov 12, 2024
c2c11d3
Merge branch 'main' into feat/add-blackbox-probes-library
giusebar Nov 12, 2024
e6b28c7
fix docstring and lint
giusebar Nov 12, 2024
001fc6a
add lib unique id
giusebar Nov 20, 2024
bdfdd8d
Merge branch 'main' into feat/add-blackbox-probes-library
giusebar Dec 5, 2024
9bcc2a9
extract blackbox probes configuration build from charm code into a se…
giusebar Dec 11, 2024
6601b60
fix lint
giusebar Dec 11, 2024
3fbdb94
remove invalid_probe custom event and use stored state for modules as…
giusebar Dec 11, 2024
be3701e
add hash for ensure probes uniqueness, add test
giusebar Dec 12, 2024
693ce7d
remove outdated comment
giusebar Dec 12, 2024
8eaaac8
Merge remote-tracking branch 'origin/main' into feat/add-blackbox-pro…
giusebar Jan 20, 2025
df72ead
add BDD inline test, improve config description, diff in module confi…
giusebar Jan 21, 2025
ed999e7
test
lucabello Jan 27, 2025
863571b
Merge branch 'main' into feat/add-blackbox-probes-library
lucabello Jan 27, 2025
734f467
add can_connect and comment
giusebar Jan 27, 2025
a8d2c65
generate config from default every time
lucabello Jan 28, 2025
a9a2410
Merge branch 'main' into feat/add-blackbox-probes-library
lucabello Jan 28, 2025
0ab4ae6
Merge branch 'main' into feat/add-blackbox-probes-library
lucabello Jan 30, 2025
f12c9a6
fix: use yaml.dump() before saving the config
lucabello Jan 31, 2025
39c8e03
replace module with prefixed module instead of appending
giusebar Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,30 @@ juju config blackbox-exporter-k8s \
probes_file='@path/to/probes.yml'
```

Note that the `relabel_configs` of each scrape job doesn't need to be specified, and will be
Note that the `relabel_configs` of each scrape job doesn't need to be specified, and will be
overridden by the charm with the needed labels and the correct Blackbox Exporter url.

#### Dynamic Configuration

The list of probes and the list of modules for probing can also be changed dynamically from other charms.
This charm offers a relation to allow charms to forward custom probes spec to Blackbox Exporter. Those are exported over the probes relation using the blackbox_exporter_probes interface:

```shell
requires:
probes:
interface: blackbox_exporter_probes
```

The custom probes provided via relation data are merged with the probes defined in the juju config `probes_file` parameter.
The modules custom defined modules are instead integrated with the modules defined in the juju config `blackbox-config` parameter.
In order for the charm defined probes to be probed via this charm all that is required is to relate the two charms with:

```shell
juju relate <charm> blackbox:probes
```

Charms that seek to provide probes for Blackbox Exporter, can do so using the provided blackbox_exporter_probes charm library. This library ensures that probes and modules defined by a charm are forwarded correctly to Prometheus, and the metrics displayed in the associated Grafana Dashboard.

## OCI Images
This charm is published on Charmhub with blackbox exporter images from
the official [quay.io/prometheus/blackbox-exporter].
Expand Down
5 changes: 5 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ options:
Blackbox Exporter configuration file (yaml).
Refer to https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md for
full details.
The modules provided via blackbox_exporter_probes interface are merged with the modules defined here.
probes_file:
type: string
default: ""
description: >
Scrape config for Prometheus in a file (yaml).
Refer to https://github.com/prometheus/blackbox_exporter#prometheus-configuration for full
details.
The probes provided via blackbox_exporter_probes interface are merged with the probes defined here.
The relation probes are hashed to ensure uniquess in the blackbox_probes.py library.
However, in case of same `job_name` the relation probe takes precedence,
overriding the corresponding file probe.
cpu:
description: |
K8s cpu resource limit, e.g. "1" or "500m". Default is unset (no limit). This value is used
Expand Down
Loading
Loading