Modules for clients#
Note
This document applies only to NGOT.
Generic configuration#
The generic definition of a module needs to be done in pkg/blackboxExporter/modules_schemas.cue.
Note
The generic schemas were made to fit the needs at a specific moment. Feel free to update a generic schema if it was not generic enough.
Define module for client#
-
Check if the module is not already implemented in pkg/blackboxExporter.
-
If the module is not already implemented, create a new module in a new file based on the generic definitions in pkg/blackboxExporter/modules_schemas.cue.
-
Adapt the definition
#MonitoringStackBBECustomModulesin zones/ngot_zones/models.cue. -
Adapt the code contexts/ngot/blackbox-exporter-core.cue.
Add a condition with the type of the new module for:
- the
pre_tasks; - the list of modules of the helm chart.
- the
Activate module for client#
Some modules can be customised with client parameters. These modules are identified with a type.
At this date of the 06/12/2023 the only available is http-basic-auth.
The activation and the customisation must be done directly in the client definitions in NGOT zones, in svc-monitoring-stack-client-${CLIENT}.parameters.monitoring-stack.blackbox-exporter.custom_modules section.
Common format#
A module has this parameters format :
#MonitoringStackBBECustomModules: {
type: or(["http-basic-auth", "<future_modules_tbd>"])
parameters?: { // Optional
headers?: {...} // Optional
valid_status_codes?: [...int] // Optional
method?: string // Optional
}
}
Each module type has its own code in context/ngot/blackbox-exporter-core.cue to map parameters to the module format.
Module type http-basic-auth#
The module for http-basic-auth is defined in module_http_basic_auth.cue file :
#BlackboxExporterConfigModuleGenericHTTPBasicAuth: #BlackboxExporterConfigModuleGenericHTTP & {
http: {
method: *"POST" | "GET"
basic_auth: {
username: string
password: string
}
}
}
Configuration example for http-basic-auth module type :
svc-monitoring-stack-client-<id>: {
....
parameters: {
"monitoring-stack": {
"blackbox-exporter": {
custom_modules: {
"http-basic-auth-1": {
type: "http-basic-auth"
parameters: {
valid_status_codes: [200]
}
}
}
}
}
}
}
http-basic-auth-1(mandatory) : module name. Without any specification from client, any string fits.http-basic-auth-1is prefered. For any additional modules, increment the suffix ;type(mandatory) : type of module, herehttp-basic-auth;parameters.*(optional) : for this example we configurevalid_status_codes. The available parameters are defined in#BlackboxExporterConfigModuleGenericHTTP. They should map<http_probe>.
Mandatory Vault configuration
Blackbox-Exporter module credentials must be specified in a manually created Vault secret.
Secret location : secrets/zones/fe/svc-monitoring-stack-client-${CLIENT}/blackbox-modules/http-basic-auth-x where http-basic-auth-x is the module name.
Secret contents :
usernamepassword
Check Blackbox-Exporter configuration#
In order to visualise the Blackbox-Exporter configuration of the module module_name, you can do it directly on the Blackbox-Exporter pod :
kswitch svc-monitoring-stack-client-${CLIENT}
kubectl exec -it -n monitoring-stack-client-obs-${CLIENT} deploy/blackbox-exporter-obs-${CLIENT} -- cat config/blackbox.yaml | yq '.modules."<module_name>"'