sensu / sensu-go

Simple. Scalable. Multi-cloud monitoring.
https://sensu.io
MIT License
1.03k stars 175 forks source link

labels does not support nested key #3778

Closed trombik closed 4 years ago

trombik commented 4 years ago

Expected Behavior

when sensu-go agent is configured with nested labels, you can replace tokens with the nested key and value.

Current Behavior

an agent has nested key in labels (nginx).

backend-url: ws://172.16.100.254:8081
cache-dir: /var/cache/sensu/sensu-agent
keepalive-critical-timeout: 300
keepalive-warning-timeout: 120
labels:
    nagios_plugin_dir: /usr/local/libexec/nagios
    nginx:
        hostname: target1
    sensu_plugin_dir: /home/sensu/.gem/ruby/2.6/bin
subscriptions:
- system
- web_server

but the nested key does not exist in the entity.

type: Entity
api_version: core/v2
metadata:
  labels:
    nagios_plugin_dir: /usr/local/libexec/nagios
    nginx: ""
    sensu_plugin_dir: /home/sensu/.gem/ruby/2.6/bin
  name: target1.i.trombik.org
  namespace: default
...

Possible Solution

support nested keys as same as other entity's attibutes.

Steps to Reproduce (for bugs)

  1. configure an agent with nested keys in labels
  2. show entity info by sensuctl entity info

Context

the doc states that:

{{ index .labels "cpu.threshold" }} would be replaced with a custom label called cpu.threshold

but it does not work (using index .labels "nginx.hostname") because the entity does not have it.

Your Environment

echlebek commented 4 years ago

The example does work, the label key would be "nginx.hostname". Nested labels and annotations are currently a non-goal, as we would like to keep things simple and efficient.

There was previously discussion here: https://github.com/sensu/sensu-go/issues/2674