Skip to content

Inconsistent choice for "resource" value: service name / service display name

Description

Value used by connector for the resource attribute is not consistent across those run phases:

  1. During connector startup, when it sends events with states of all hosts and services:
    resource = service's display_name

  2. Then at runtime, following Icinga2 events stream:
    resource = service name

Current result

/* ALL EVENTS BELOW ARE RELATED TO THE SAME ICINGA2 SERVICE ON THE SAME HOST */

/* Event sent during startup phase */

{"event_type":"check","output":"OK - load average: 0.25, 0.36, 0.43","timestamp":1711615450,"connector":"icinga","connector_name":"localhost:5665","component":"icinga2","author":"icinga.localhost:5665","resource":"SYS_LUNIX_LOAD","source_type":"resource","state":0}



/* Events sent by forced checks and normal checks after startup phase */

{"event_type":"check","output":"Hot","timestamp":1711615558,"connector":"icinga","connector_name":"localhost:5665","component":"icinga2","author":"icinga.localhost:5665","resource":"load","source_type":"resource","state":1}                                          

{"event_type":"check","output":"OK - load average: 0.45, 0.47, 0.46","timestamp":1711615618,"connector":"icinga","connector_name":"localhost:5665","component":"icinga2","author":"icinga.localhost:5665","resource":"load","source_type":"resource","state":0}

Expected behaviour

For the sake of consistency in events and alarms, resource should by either one or the other at all times.

IMO it should even be configurable:

  • some users could configure their connector to always set resource as the service's technical name
  • other users expect the display_name (when available), with fallback to service's technical name if service has no display_name

In any case, please refer back to the connector specification – don't know where it is – (and discuss or have spec fixed if this part was missing).

Context

  • Originally reported by customer
  • Reproduced on a minimal lab environment at Capensis
  • Target Canopsis instance: Canopsis 22.10.13
  • Icinga2 2.7.0 from our own Icinga2 mock env

How to reproduce

  1. Get Icinga2 mock env

  2. Edit icinga2 service in docker-compose.yml as follows (uncomment lines to enable local dir volume of /etc/icinga2)

    diff --git a/pro/mock/external-services/icinga2/docker/docker-compose.yml b/pro/mock/external-services/icinga2/docker/docker-compose.yml
    index 6becd6a2f2..ac507f5fe7 100644
    --- a/pro/mock/external-services/icinga2/docker/docker-compose.yml
    +++ b/pro/mock/external-services/icinga2/docker/docker-compose.yml
    @@ -18,10 +18,10 @@ services:
           #- ICINGAWEB2_ADMIN_USER=icingaadmin
           #- ICINGAWEB2_ADMIN_PASS=icinga
           #- ICINGA2_USER_FULLNAME=Icinga2 Docker Monitoring Instance
    -#    volumes:
    +    volumes:
     #      - ./icinga/cache:/var/cache/icinga2
     #      - ./icinga/certs:/etc/apache2/ssl:ro
    -#      - ./icinga/etc/icinga2:/etc/icinga2
    +      - ./icinga/etc/icinga2:/etc/icinga2
     #      - ./icinga/etc/icingaweb2:/etc/icingaweb2
     #      - ./icinga/lib/icinga:/var/lib/icinga2
     #      - ./icinga/lib/mysql:/var/lib/mysql
  3. docker compose up -d the Icinga2 mock env, wait for its complete startup and readiness

  4. Once the /etc/icinga2 dir is fully populated, edit icinga/etc/icinga2/conf.d/services.conf

    Edit block apply Service "load" to add a display_name as follows:

    apply Service "load" {
      import "generic-service"
    
      display_name = "SYS_LUNIX_LOAD"
    
      check_command = "load"
    
      /* Used by the ScheduledDowntime apply rule in `downtimes.conf`. */
      vars.backup_downtime = "02:00-03:00"
    
      assign where host.name == NodeName
    }
  5. docker compose restart icinga2

  6. In Icingaweb2, ensure the service shows the display_name, it should read:

    Service: SYS_LUNIX_LOAD (load)

  1. Install, configure and launch connector-icinga2 while amqp2tty runs against your target Canopsis instance and watch out for events containing "load" (case-insensitive)

    $ docker run --rm -e CPS_AMQP_URL=amqp://cpsrabbit:canopsis@rabbitmq/canopsis \
        --network=canopsis-pro_default docker.canopsis.net/docker/community/amqp2tty:22.10.13 | grep -i load
  2. Notice the first event sent (while connector sends startup states of all hosts + services) has the display_name as resource: "SYS_LUNIX_LOAD"

  3. In Icingaweb2, use the manual "Process check result" action 4-5 times in a row to get a hard state, for example "WARNING" (if previously "OK")

  4. Notice the runtime event sent by connector now sets the resource value with service name (not display name): "load"

Edited by Mathias Védrines