Werk #6972: Support SQL-style quoting for filtering dict-valued columns

Component Livestatus
Title Support SQL-style quoting for filtering dict-valued columns
Date Jun 7, 2019
Checkmk Edition Checkmk Raw (CRE)
Checkmk Version 1.6.0b2 2.0.0i1
Level Trivial Change
Class New Feature
Compatibility Compatible - no manual interaction needed

Some Livestatus columns do not contain a simple value or a list of such values, they contain a dictionary of key/value pairs. More concretely, the

  • custom_variables
  • label_sources
  • labels
  • tags

columns in the

  • contacts
  • hosts
  • hostsbygroup
  • services
  • servicesbygroup
  • servicesbyhostgroup

tables contain dictionary values. Livestatus filter for such columns have a special syntax:


As an example, the query:

GET hosts
Filter: tag = agent cmk-agent

returns all hosts where the tag "agent" has the value "cmk-agent". Note that the key and the value are separated by whitespace. But this makes it impossible to query for a tag name with spaces. To support more general keys and values in such filters, Livestatus now additionally supports SQL-style quoting for such column filters:

Filter: labels = 'It''s so' 'cool, man!'

This filter matches a label with key "It's so" and value "cool, man!". Note the use of 2 consecutive single quotes to represent 1 single quote. The previous syntax still works, the new syntax is triggered by a leading single quote in the key and/or value.

To the list of all Werks