Aller au contenu

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#

  1. Check if the module is not already implemented in pkg/blackboxExporter.

  2. 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.

  3. Adapt the definition #MonitoringStackBBECustomModules in zones/ngot_zones/models.cue.

  4. 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.

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 :

zones/ngot_zones/models.cue
#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 :

zones/ngot_zones/client-${CLIENT}.cue
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]
                      }
                  }
               }
            }   
         }   
      }
}
Configuration explanations :

  • http-basic-auth-1 (mandatory) : module name. Without any specification from client, any string fits. http-basic-auth-1 is prefered. For any additional modules, increment the suffix ;
  • type (mandatory) : type of module, here http-basic-auth ;
  • parameters.* (optional) : for this example we configure valid_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 :

  • username
  • password

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>"'