Werk #18322: HW/SW inventory: Integrate label picker
| Component | HW/SW inventory | ||
| Title | HW/SW inventory: Integrate label picker | ||
| Date | Aug 29, 2025 | ||
| Level | Trivial Change | ||
| Class | New Feature | ||
| Compatibility | Compatible - no manual interaction needed | ||
| Checkmk versions & editions |
|
The new rule HW/SW inventory label picker offers a configuration for
picking host labels from HW/SW inventory trees. The labels are picked by the
Check_MK HW/SW Inventory service, so a host needs this service for the picked
labels to be created and kept up to date.
For this you need to know the path and the keys or columns to data fields which
you want to use for labels. These can be looked up on the HW/SW inventory page of
a host by enabling Modify display options > Show internal tree paths.
How it works
- On each successful run the
Check_MK HW/SW Inventoryservice evaluates the rule on the new inventory tree and records the resulting host labels (prefixed with the configured label name prefix, e.g.cmk/inventory/product). A failed run keeps the previously picked labels. - The
Check_MK HW/SW Inventoryservice compares the picked labels with the accepted ones and reports new, vanished and changed labels - each at a state configurable in the rule setDo HW/SW inventory(defaults: newWARN, vanishedOK, changedWARN, as for the labels of discovery plug-ins) - until the service discovery accepts them. TheCheck_MK Discoveryservice only reports the labels of discovery plug-ins. - The service discovery page offers to accept the picked labels. If the
periodic service discovery of the host updates host labels, the
Check_MK HW/SW Inventoryservice schedules it, so the labels are accepted automatically - and activated, if the periodic service discovery activates changes. From then on you can use them in rule conditions, views and searches like any other host label. - Removing the rule, or a value that no longer matches, makes the picked label vanish with the next inventory run. It is reported as vanished until the service discovery removes it.
- A host label of a discovery plug-in takes precedence over a picked label of
the same name, e.g.
cmk/os_familypicked with an empty label name prefix: the service discovery keeps the plug-in label, and theCheck_MK HW/SW Inventoryservice keeps reporting the picked label as new. Choose a prefix or label name that no discovery plug-in uses.
Configuration options
Each rule entry groups its options into Inventory source (what to pick) and
Label naming (how to name the labels).
Inventory source:
-
Inventory categories: The internal tree path to the node to read from (e.g.software.os). -
Labels from single values: Pick a label from a single attribute value (Key of the value), named viaLabel name. -
Labels from table columns: Pick labels from a table.Column of the valueselects the column whose value is used for the label.Rowslets you restrict the considered rows to those whose column matches a regular expression - so you can match on one column and emit the value of another. A host label has a single value: if several rows yield a value for the same label, the first row in table order determines it.
If several configurations or entries yield the same label name, the first one wins; within a configuration, single values come before table columns.
For both, the Label value controls how the selected value is turned into a
label value: use it verbatim, use it only if it matches a regular expression, or
replace it via an ordered list of Replacement rules. The replacement rules are
evaluated in order and the first matching rule is applied: the value is replaced
by the rule's Replacement, in which \1, \2, ... refer to the groups of the
regular expression; the rule is rejected if it refers to a group the regular
expression does not have. The value is dropped if no rule matches.
How values are matched
-
Inventory categories,Key of the value,Column of the valueandColumn to matchmust name the internal tree path, keys and columns exactly - they are case-sensitive and are not regular expressions. -
Matching always works on the raw value stored in the inventory tree, not on the value as displayed. Before matching, the raw value is converted to a string, and this string is also what the label value is made from: a size is matched as
1073741824, not as1 GiB, a boolean asTrueorFalse, not asYesorNo, and a number as1.5, not as1.50. WithShow internal tree pathsenabled, the HW/SW inventory page shows the raw value in brackets behind each displayed value. -
A regular expression matches if it is found anywhere in the value, e.g.
ServermatchesMicrosoft Windows Server 2019. Anchor it with^and$to match the whole value. Matching is case-sensitive; prefix the expression with(?i)to ignore the case. -
A
Replacementreplaces the whole value, not only the matched part: withMicrosoft Windows Server (.*)andWin Server \1, the valueMicrosoft Windows Server 2019 StandardbecomesWin Server 2019 Standard. -
Letter caseis applied afterwards, to the resulting label value, so the regular expressions always see the value in its original case. -
A missing key or column, an empty value, and a value that does not match or is replaced by an empty text all pick no label.
Label naming:
-
Label name prefix (empty for none): The prefix the picked labels are stored under (defaultcmk/inventory). -
Letter case: Optionally normalize the case of the label name and/or the label value (Keep,Lowercase,Uppercase) for consistent labels. The prefix is kept as entered.
Examples:
Labels from single values
Labels from products
Enter the following internal tree path to the Inventory categories input field:
hardware.system
Then add an entry of Labels from single values and enter
-
productto theLabel nameinput field -
productto theKey of the valueinput field -
choose
The valuein the dropdownLabel value
Labels from operation system names
-
Inventory categories: Addsoftware.os -
Label name: Addos_name -
Key of the value: Addname -
Label value: ChooseA replacement (first matching rule wins), enterMicrosoft Windows Server (.*)in theRegular expressioninput field andWin Server \1in theReplacementinput field.
Labels from table columns
Labels as webservers
Enter the internal tree path to the Inventory categories input field:
software.packages
Then add an entry of Labels from table columns and enter
-
Label name: Addwebserver -
Column of the value: Addname -
Rows: ChooseRows where a column matches, addnameto theColumn to matchinput field and(apache|nginx|httpd)to theRegular expressioninput field. -
Label value: ChooseThe value.
This adds the host label cmk/inventory/webserver with the name of the first
installed package whose name matches the expression as its value.
Webserver version (matching one column, emitting another)
Because Column of the value and Rows are independent, you can match on one
column and use the value of a different column. To label hosts with the version
of their installed webserver package:
-
Inventory categories: Addsoftware.packages -
Label name: Addwebserver_version -
Column of the value: Addversion -
Rows: ChooseRows where a column matches, addnameto theColumn to matchinput field and(apache|nginx|httpd)to theRegular expressioninput field. -
Label value: ChooseThe value.