Skip to content

Documentation

Groups

This guide explains how groups decide which host runs which rule, and shows you how to create groups with fixed members, with members chosen automatically, and with nested groups.

Before you start

  • You need the Engineer or Administrator role to create or change groups. Anyone can view them, unless their access is limited to some groups (see Limit access to some groups).
  • Words used here: a host runs the LEA agent; a rule is one check; membership is which hosts belong to a group. See the glossary.

How groups work

A group connects hosts with rules:

  • A host runs every active rule of every active group it belongs to.
  • A rule that is in no active group runs nowhere.
  • A host that is in no active group runs nothing and shows NO RESULTS.

A host can be in many groups. A rule can be in many groups. If a rule reaches a host through two groups, the host still runs it once.

A host joins a group in one of these ways:

WayHow it works
Static listYou pick the hosts by hand.
All hostsEvery host is a member, except hosts in groups marked Exclude these hosts from "All hosts" groups.
JSONPathHosts whose collected data matches an expression are members. Membership updates by itself as data arrives.
NestingThe group includes the hosts (or the rules) of another group.
Deployment tokenA token with a Group adds newly enrolled hosts to that group's static list. See Add and manage hosts.

A new installation has one group, All Hosts, with membership All hosts and no rules.

Create a group

  1. Open Groups and click New group at the top right (or go to /groups/new).
  2. In General:
    • Name (required), for example Web servers.
    • Active: on. An inactive group assigns nothing.
    • Description: what the group is for.
  3. In Hosts, choose the Membership (see the next sections).
  4. In Rules, click Add rules..., type part of a rule name and pick rules. They appear in the table below; remove one with its remove icon.
  5. Optional: in Nested groups, include other groups. See Nest groups.
  6. Click Save at the top right.

You should see the group page with the number of hosts and rules. Results appear after each host's next run of each rule.

Tip: Try new rules on a small test group first. Add them to production groups when the results look right.

Choose hosts by hand

  1. In Hosts, click Static list.
  2. Click Add hosts..., type part of a host name and pick hosts. Picked hosts appear under Selected hosts.
  3. Remove a host with the remove icon in its row.

You can also add a host from its host page: Groups tab → + Add to group.... To add many hosts, or create a new group for them, select them on the Compliance page → Edit configuration → Groups (see Edit many hosts at once).

Include all hosts

  1. In Hosts, click All hosts.

Every host is a member, now and in the future, except hosts that are members of an active group with Exclude these hosts from "All hosts" groups turned on.

To keep some hosts out of "all hosts" groups (for example test machines), create a group with those hosts and turn on Exclude these hosts from "All hosts" groups in its Hosts section.

Choose hosts automatically with JSONPath

A JSONPath group picks hosts by what the agent reports about them and by the data rules collected about them.

Where the data comes from

Host info is what the agent reports about the host on every check-in. You can use these fields:

FieldWhat it holdsName in an expression
Host nameThe host name in LEA.$host."name"
Operating systemThe operating system family, for example linux.$host."os"
DistributionThe distribution name, for example Ubuntu or Oracle Linux Server.$host."distribution"
Distribution versionThe full distribution version, for example 22.04.$host."distribution_version"
Distribution major versionThe major distribution version, for example 8.$host."distribution_major"
KernelThe kernel release.$host."kernel"
ArchitectureThe processor architecture, for example amd64 or aarch64.$host."architecture"
IP addressThe IP address the agent reports.$host."ip"
Agent versionThe version of the LEA agent.$host."agent_version"
Deployment tokenThe name of the deployment token the host enrolled with.$host."deployment_token"
CriticalityThe criticality you set on the host: low, medium, high or critical.$host."criticality"

Labels are the tags you give hosts yourself, on the host page → Configuration, in a bulk edit or through a deployment token (see Configure a host). Choose Label as the data, then the label name; the value list suggests what your hosts carry. In an expression a label is $host."labels"."<name>", for example $ ? ($host."labels"."site" like_regex "^tlv\s*$").

Collected tags are the latest outputs of rules that have a Command info key (tag). Each rule stores its output on the host under its tag. Three built-in rules do this:

Built-in ruleTagWhat it holds
Host NamehostnameThe host name.
MAC Addressmac_addrThe network card addresses.
Package Inventory Snapshotpackage_inventoryThe list of installed packages.

The collected data of one host looks like this:

{
  "hostname": {"stdout": "web-01\n", "stderr": "", "returncode": 0, "verified": true}
}

Important: Collected tags only exist when the hosts run the collecting rule. The built-in rules are active but in no group after installation. Add them to a group the hosts belong to, for example All Hosts. You can see the collected data on a host page → Configuration → Collected host tags.

Any rule you write can collect data the same way: set its Command info key (tag). See Write and edit rules.

Build the conditions

  1. In Hosts, click JSONPath.
  2. Under Membership conditions, keep Builder selected.
  3. For each condition, choose:
    • Data: Host info, Label or Collected tag.
    • Field (host info) or Tag and Part (collected tag: Output, Errors or Return code). The tag list shows how many hosts report each tag and which rules collect it.
    • Condition: is, is not, contains, does not contain, starts with, ends with or matches regex. A return code can only be is or is not a number.
    • Value. For host info, the list suggests the values your hosts report. Tick Ignore case to ignore upper and lower case.
  4. Click Add condition for more conditions. With more than one, choose whether hosts must match all conditions or any condition.
  5. Click Save.

The box under the conditions shows the expression the builder writes. Under it you see whether the expression is valid and how many hosts it matches now, for example "Matches 5 of 21 hosts.", with the first matching hosts. You should see the expected hosts there before you save.

  • NO MATCH: no host matches yet. Hosts join by themselves once their data arrives.
  • ALL HOSTS: every host matches. Check the conditions; an All hosts group may be what you want.
  • INVALID: the expression cannot be used. The reason is shown next to it, and Save is refused until you fix it.

A condition with an empty value is ignored. "Is" ignores a trailing line break, so it works with command output such as host names.

Test the expression on a host

Use Test on a host to see why a host matches or not.

  1. Under Membership conditions, in Test on a host, pick a host.
  2. You should see MATCHES or DOES NOT MATCH, then the host's Host info and Collected tags.
  3. In Builder, click any value to add it as an "is" condition. For output with several lines, the first line is added as a "contains" condition. Long outputs are shortened; Show all expands them.

Write the expression by hand

Click Advanced to type the expression yourself. An expression the builder did not write, for example one saved before the builder existed, always opens in Advanced and the builder never rewrites it. Builder is then greyed out; clear the box to start again in the builder.

The expression is a PostgreSQL JSONPath filter of the form $ ? (<condition>):

  • A collected tag: @."<tag>".stdout, @."<tag>".stderr or @."<tag>".returncode.
  • Host info: $host."<field>", with the names from the table above. A label: $host."labels"."<name>".
  • Compare text with like_regex "<pattern>"; add flag "i" after the pattern to ignore case. Compare numbers with == or !=.
  • Combine conditions with && (and) or || (or). Put !( … ) around a condition to negate it. A negated condition also matches hosts that do not have that data at all; add exists(@."<tag>".stdout) && before it to skip them, as the builder does for is not and does not contain.
Hosts you wantExpression
Host names that start with web-$ ? (@."hostname".stdout like_regex "^web-")
Ubuntu hosts$ ? ($host."distribution" like_regex "^Ubuntu")
Oracle Linux hosts on amd64 whose package list mentions nginx$ ? ($host."distribution" like_regex "^Oracle Linux" && $host."architecture" == "amd64" && @."package_inventory".stdout like_regex "nginx")

The older form $.<tag>.stdout ? (@ like_regex "<pattern>") still works.

An expression is refused when you save it if it cannot be read, uses a name other than $host after a $, or is a bare condition such as $.hostname.stdout == "x". A bare condition would match every host, so wrap it: $ ? (@."hostname".stdout == "x").

You should see the hosts on the group page → Hosts tab after you save, with Membership "inherited". New hosts that match join by themselves once their data arrives.

Nest groups

Nesting lets one group include another group's hosts or rules, so you maintain them in one place.

IncludeEffectExample
HostsThe group's hosts include the hosts of the nested group."Production" includes the hosts of "Web servers" and "Database servers".
RulesThe group's rules include the rules of the nested group."Oracle Linux hosts" includes the rules of "Kernel security". New rules added to "Kernel security" reach these hosts too.
  1. Edit the group and open Nested groups.
  2. Click Add nested group.
  3. Choose the Group and, in Include, Hosts or Rules.
  4. Check the list Members that will be added.
  5. Click Add, then Save.

The Nested groups table in the editor lists each nested group:

ColumnWhat it shows
IncludesWhether this group takes the nested group's hosts or its rules.
MembersHow many hosts or rules this group takes from the nested group. For hosts, only hosts added to it by hand count.

Limits:

  • One level only. A group that has nested groups cannot itself be nested. A nested group cannot have its own nested groups.
  • No group can include itself, and two groups cannot include each other.
  • Only the nested group's static hosts are included. Its All hosts or JSONPath membership is not followed.
  • An inactive nested group contributes nothing.

If you break a limit, saving fails with a message such as "Multi-level nesting not allowed". More detail: Group nesting reference.

Choose how to assign rules

When some hosts need a rule they do not run yet, there is usually more than one way to give it to them. Pick the one that changes the least:

WayWhen it fitsWatch out
Add the rule to a group the hosts already belong toThe rule fits every host in that group. Simplest.Every other host in the group gets it too.
Add the hosts to an existing groupThe hosts should run everything that group runs.They get all of that group's rules, not only the one you need.
Nest a group for rulesA group of hosts (for example "Oracle Linux hosts") should run a whole set of rules kept in another group (for example "Kernel security"). Rules added there later reach these hosts too, without copying the hosts into it.The one-level limit (below).
Nest a group for hostsOne group should cover the hosts of several others, for example "Production" includes "Web servers" and "Database servers".Only the nested group's static hosts are included.
JSONPath groupMembership should follow what hosts report, so new matching hosts join by themselves.The collecting rule must run on the hosts. See Choose hosts automatically with JSONPath.

Before you change anything, look at the current layout: the host page → Groups tab shows how the host is a member (direct, dynamic or through nesting), and the group page → Nesting tab shows what each group includes. Remember the nesting limits: a group that already nests others cannot be nested, and a nested group cannot nest others.

To manage groups from a script, see Manage groups through the API.

Turn rules on or off for a group

A rule's Active switch is global: an inactive rule runs on no host in any group. To change what one group runs:

  • Stop a rule for one group: edit the group, open Rules and remove the rule. If the rule comes from a nested group, remove it there, or remove the nesting.
  • Stop everything a group assigns: edit the group and turn Active off. Its hosts keep running rules from their other groups.
  • Stop a rule everywhere: edit the rule and turn Active off. See Write and edit rules.

To add one rule to a group quickly, open the rule → Groups tab → + Add to group.... To add many rules, select them on the Rules page and click Add to group in the selection bar; pick + New group… there to create a group from them on the spot.

Read the groups list

The Groups page shows Groups, Active, Inactive, With hosts and Missing hosts or rules (groups that assign nothing because they have no hosts or no rules). Click a number to filter.

ColumnWhat it shows
Group nameThe name of the group.
Hosts in groupHow many hosts are members of the group now, then their names (hover for all). Hosts join by hand, by JSONPath, through All hosts or through a nested group. Click to open them in Compliance. An inactive group shows 0.
Rules in groupHow many rules the group assigns, then their names (hover for all): its own rules plus the rules it takes from nested groups. Click to open them in Rules. An inactive group shows 0.

The icons in each row open the group's hosts on Compliance (View Compliance) and Execution (View Execution), its rules (View Rules), the editor (Edit Group) and a copy (Clone Group).

Read the group page

The group page (/groups/<id>) shows INACTIVE when the group is off, and the state of its checks (N FAILING CHECKS, ALL PASSING or NO RESULTS). The line below says how membership works (static, all hosts or the JSONPath expression). Buttons: Check group now (runs every rule of the group on its hosts now, see Check now), Compliance, Execution, Rules (opens the Rules page filtered to this group), Clone (opens a copy of the group in the editor; it is only created when you save it) and Edit. You can also right-click a group anywhere and choose Rules in group or Clone group. The numbers show Hosts, Rules and Checks passing.

TabWhat you find there
HostsEvery member host with OS, Last seen, Membership (direct or inherited) and how the group's rules do on it. Filter With failures or No failures.
RulesEvery rule the group runs with Severity, Status (active or INACTIVE), Assignment (direct or nested) and how it does on the group's hosts.
NestingIncluded in (parents): groups that include this one. Includes (children): groups this one includes, and whether it takes their hosts or rules.
EnvironmentThe check-in interval of the group's hosts and the environment variables added to every rule and function command they run. See Check-in interval and Environment variables.
Held rulesHosts of this group that run an older version of one of its rules. Update all moves them to the current version. See Rule library and updates.

Read the Hosts and Rules tabs

ColumnWhat it shows
MembershipWhether the host was added to this group by hand ("direct") or belongs through All hosts, a JSONPath expression or a nested group ("inherited").
Group rule checksHow the group's active rules do on this host: how many fail, how many pass and how many still await a first result.
StatusWhether the rule is switched on; an INACTIVE rule runs on no host in any group.
AssignmentWhether the rule was added to this group itself ("direct") or comes from a nested group ("nested").
Hosts in this groupHow this rule does on the group's active hosts: how many fail, how many pass and how many still await a first result. An informational rule (one without expectations) shows INFO and a grey bar of how many of the hosts that should run it have reported, for example 10 of 15 reported: it only collects data and never passes or fails.

Check-in interval

Open the group page → Environment → Check-in interval to set how often the agents of the group's hosts check in with the server. Choose one of the values allowed in Settings → Agent Management and click Save; each host picks it up at its next check-in.

  • A group's value overrides the value set on each of its hosts and the default in Settings → Agent Management.
  • A host in several groups that set an interval uses the shortest one; its Configuration tab marks it SEVERAL GROUPS.
  • Choose Not set and save to stop overriding: the hosts go back to their own value or the default.
  • All Hosts has no interval of its own: the default in Settings applies to every host.

See Check-in interval for the whole order.

Environment variables

Open the group page → Environment to give the group's hosts environment variables, for example a proxy for one site. Every rule and function command the hosts run gets them. Click Add variable or Add secret, then Save.

  • Set a variable on All Hosts to give it to every host.
  • A host that is in several groups gets the value of the group with the lowest id; the host page → Configuration → Effective variables marks such a name CONFLICT.
  • A value set on the host itself always wins. See Environment variables for names, secrets and probation.

Together with labels this keeps settings in one place: give a group a JSONPath condition on a label, set the variables on the group, and every host that gets the label also gets the variables. A deployment token that adds hosts to the group does the same for new hosts.

Limit access to some groups

Groups are also the scope of access: an administrator can give a team a role on some groups only, so they see and work on the hosts of those groups and nothing else.

  1. Open Settings → Access → Bindings.
  2. Click Add role mapping (for a whole team) or Add grant (for one person).
  3. Pick the Role, for example Operator, and in Scope pick the groups.
  4. Click Save or Grant.

What the scope covers:

  • The hosts of the picked groups and of every group they nest for hosts, with the same membership rules as everywhere else (static, All hosts, JSONPath).
  • Groups that contain one of those hosts stay visible, so the rules those hosts run are complete.
  • Rules and functions are always shown in full.

A person limited to groups sees Scoped to: and the group names in the left menu. Changing a group's members changes what they see within seconds. Full steps and examples are in Access: roles and scopes.

Important: Deleting a group or removing hosts from it also removes them from the access of everyone scoped to it.

Delete a group

  1. Edit the group.
  2. Click the bin icon (Delete) at the top right and confirm.

Hosts and rules are not deleted. Hosts stop running the rules they got only from this group.

If something goes wrong

  • A host does not run a rule: check that the host is active, is a member of an active group (host page → Groups), and that the rule is active and in that group or in a group it nests for rules.
  • A JSONPath group is empty: the collecting rule does not run on the hosts, or the expression is wrong. See Choose hosts automatically with JSONPath.
  • "This expression is a bare condition and would match every host": wrap the condition as $ ? (<condition>). See Write the expression by hand.
  • "Invalid JSONPath: … could not find jsonpath variable": the expression uses a $ name other than $host, often a typo such as $hosts. Use $host."<field>" for host info and @."<tag>" for collected tags.
  • "Invalid JSONPath: …" with another reason: check the quotes and brackets. Use Test on a host to see the data the expression runs on.
  • "Fix the JSONPath expression before saving": the expression is shown as INVALID; fix it in Advanced, or clear the box and build the conditions in Builder.
  • "Matches every host.": the conditions are too wide. Test them on a host that should not match.
  • "Group name is required" or "JSONPath expression is required": fill in the field.
  • A nesting error on save: see the limits in Nest groups.
  • A host cannot be removed from a group on its host page: it is a member through nesting, a JSONPath expression or "all hosts". Change the group that provides the membership.

For more, see Troubleshooting.