Dynamic check based on labels

Hi,

I want to create a dynamic check base on labels but i thinks is not possible.

Can you confirm ? :slight_smile:

Entity label :

  labels:
    check_disk:
      name: "root"
        mount: "/"
        warning: "80"
        critical: "90"
      name: "srv"
        mount: "/srv"
        warning: "50"
        critical: "70"
type: CheckConfig
api_version: core/v2
metadata:
  created_by: me
  name: check-disk-{{.labels.check_disk.name}}
  namespace: default
spec:
  check_hooks:
  - non-zero:
    - disk_details
  command: check-disk-usage.rb -w {{.labels.check_disk.name.warning}}
    -c {{.labels.check_disk.name.critical}} -I {{.labels.check_disk.name.mount}}
  env_vars: null
  handlers: []
  high_flap_threshold: 0
  interval: 60
  low_flap_threshold: 0
  output_metric_format: ""
  output_metric_handlers: null
  pipelines: []
  proxy_entity_name: ""
  publish: true
  round_robin: false
  runtime_assets:
  - disk-checks-plugins
  - sensu-ruby-runtime
  secrets: null
  stdin: false
  subdue: null
  subscriptions:
  - system
  timeout: 30
  ttl: 300

Thanks.

The model of sensu-go is that checks are registered with the server, each check needs to be unique, and labels are a client side construct. You can use labels to pass client side information to the check but the check must be mapped to clients (via subscriptions) before being sent to the client, its not possible to know the values of the labels ahead of time.

I know it may not be the popular solution but every time I try to imagine monitoring at scale, I always end up reaching for configuration management at some point. I template the checks themselves and rely on client side labels purely for inputs.

An alternate idea would be to create a wrapper check that knows how to parse the passed labels and pass it down to the plugin checks. In this case you get one check that checks n disks rather than a check per disk but maybe that is OK?