Rule-Based Label Mapping
New APIs for managing the new feature Rule-based label mapping are the following:
Label Mapping API Methods
Functionality | HTTP | URI |
|---|---|---|
Returns the collection of label mapping rules. |
|
|
Creates a new label-mapping rule. |
|
|
Deletes multiple label mapping rules |
|
|
Gets the instance of a single label-mapping rule. |
|
|
Updates the instance of a single rule. |
|
|
Deletes the specified label-mapping rule. |
|
|
Reorders label-mapping rules. |
|
|
This asynchronous API runs a set of label-mapping rules on a set of workloads. |
|
|
Gets the status of the async job to run the rules. |
|
|
Downloads the results of the run rules job. |
|
|
Assigns labels from the results of the label-mapping rules run job. |
|
|
Rule-Based Label Mapping Reference
This topic covers examples of rule-based label mapping.
Examples
Example response for GET /api/v2/orgs/:xorg_id/label_mapping_rules
[
{
"href": "/orgs/1/label_mapping_rules/48ed8903-878e-4010-859a-63d19be797c3",
"enabled": true,
"position": 40,
"created_at": "2024-04-24T06:54:00.530Z",
"updated_at": "2024-04-24T06:54:00.535Z",
"expression": {
"property": "hostname",
"values": [
"this"
],
"operator": "starts_with"
},
"created_by": {
"href": "/users/2"
},
"updated_by": {
"href": "/users/2"
},
"label_assignments": [
{
"label": {
"href": "/orgs/1/labels/24"
}
},
{
"label": {
"href": "/orgs/1/labels/11"
}
},
{
"label": {
"href": "/orgs/1/labels/20"
}
}
]
},
{
"href": "/orgs/1/label_mapping_rules/d1479032-f7cb-479f-87bd-1bc7bd816a74",
"enabled": true,
"position": 41,
"created_at": "2024-04-26T18:18:10.238Z",
"updated_at": "2024-04-26T18:18:10.256Z",
"expression": {
"property": "hostname",
"values": [
"perf-workload-1"
],
"operator": "equals"
},
"created_by": {
"href": "/users/1"
},
"updated_by": {
"href": "/users/1"
},
"label_assignments": [
{
"label": {
"href": "/orgs/1/labels/9"
}
}
]
},
{
"href": "/orgs/1/label_mapping_rules/d4ddb653-56e9-4150-a93e-8a734c510c03",
"enabled": true,
"position": 43,
"created_at": "2024-04-28T00:05:38.146Z",
"updated_at": "2024-04-28T00:05:38.150Z",
"expression": {
"property": "hostname",
"values": [
"perf-workload-2"
],
"operator": "equals"
},
"created_by": {
"href": "/users/2"
},
"updated_by": {
"href": "/users/2"
},
"label_assignments": [
{
"label": {
"href": "/orgs/1/labels/7"
}
}
]
}
]Example Request for POST /api/v2/orgs/:xorg_id/label_mapping_rules
{
"expression": {
"logical_operator": "and",
"child_expressions": [
{
"property": "os",
"operator": "equals",
"values": ["linux"]
},
{
"property": "process",
"operator": "contains",
"values": ["mysql"]
}
]
},
"label_assignments": [
{
"label": {
"key": 'os',
"value": 'Linux'
}
},
{
"label": {
"key": 'role',
"value": 'Database'
}
}
]
}
}Example Response for POST /api/v2/orgs/:xorg_id/label_mapping_rules
{
"href": "/orgs/1/label_mapping_rules/4512e359-bda3-49d1-8f9e-b9a03357e4ee",
"enabled": true,
"position": 2,
"created_at": "2024-04-18T23:45:49.237Z",
"updated_at": "2024-04-18T23:45:49.290Z",
"expression": {
"property": "os",
"operator": "contains",
"values": [
"windows"
]
},
"created_by": {
"href": "/users/1"
},
"updated_by": {
"href": "/users/1"
},
"label_assignments": [
{
"label": {
"key": "os",
"value": "Windows"
}
}
]
}