Werk #6972 · Jun 7, 19
Support SQL-style quoting for filtering dict-valued columns
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:
Filter: COLUMN OPERATOR KEY VALUE
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.
Details
- Class:
- New Features
- Level:
- Trivial
- Component:
- Livestatus
- Versions:
- 2.0.0i1CommunityProUltimate + MT
- 1.6.0b2CommunityProUltimate + MT