How to list all assigned labels

Did a bit of investigation and the best workaround I found so far was to use the inspect tool inside the browser (using Firefox 91 ESR) to get Host label JSON response visible.

  • Go to any host view you want the labels visible as JSON

  • Filter results, add filter Host labels

  • Inspect the empty field Host labels
    image

  • Developer tools, tab Network, clear results if needed

  • In Host labels field, type a character and directly backspace to remove it. This will search for all labels, instead of a wildcard search of text you typed.

  • In Developer tools click the latest entry of ajax_autocomplete_labels.py?_ajaxid=

  • In Response tab, you get your list of unique host labels, copy all JSON data

{
	"result_code": 0,
	"result": [
		{
			"value": "cmk/os_family:linux"
		},
		{
			"value": "cmk/device_type:switch"
		},
		{
			"value": "user/username1:yes"
		},
		{
			"value": "user/username2:yes"
		},
		{
			"value": "user/username3:true"
		},
		{
			"value": "user/username4:yes"
		},
		{
			"value": "cmk/check_mk_server:yes"
		}
	],
	"severity": "success"
}
  • Process JSON to get your overview, find typos or syntax goof ups.
    Example user/username3:true doesn’t follow the syntax of the other user labels.
  • Use previous host view with filter on Host labels to find the hosts with the messed up labels by editing them in the host configuration.

Similar process can be done for Service labels too. And Chrome will probably work too to inspect it.

3 Likes