Bug #9299
closedExtend groups search capabilities for complex JSON Properties / JsonPath
Description
Currently when the feature of extended JSON-Based node properties is enabled, there is no real optimal way to define dynamic groups based on that.
The current option to match a Key=Value pair is as following:
- [ Properties ▼] [ Name=Value ▼] [ Name= ▼] <field_of_key>
- [ Properties ▼] [ Name=Value ▼] [ = ▼] <field_of_value>
My proposal is that you create a new dropdown-type field that says like:
- [ Properties ▼] [ JSON Data ▼] <field_of_key> [< match_operator> ▼] <field_ov_matched_value>
This could be used to create a new type of dynamic group, that would match on a specific value inside the JSON value of the property.
(Legend: [ X ▼]
is a dropdown menu, <field>
is an input-type field.)
Updated by François ARMAND about 8 years ago
- Category set to Web - Nodes & inventories
- Target version set to Ideas (not version specific)
This is an excellent idea, and it seems to be somehow the natural way of building dyngroup from properties given the way node properties are used elsewhere.
We are going to work on that kind of stuff in 4.1.
Thanks for reporting and sharing the idea.
Updated by François ARMAND almost 8 years ago
- Related to User story #9551: Group criteria operator for properties added
Updated by François ARMAND almost 8 years ago
So, it seems that it won't go into 4.1 but 4.2. The idea and use case it still really clear.
Updated by Benoît PECCATTE over 7 years ago
- Tracker changed from Bug to User story
Updated by François ARMAND over 7 years ago
- Related to Bug #10599: Impossible to search or build groups based on JSON values in node properties added
Updated by François ARMAND over 7 years ago
- Related to Bug #10743: Dynamic group search not available on boolean node property value added
Updated by Benoît PECCATTE over 7 years ago
- Tracker changed from User story to Bug
- Priority set to 0
Updated by Benoît PECCATTE over 7 years ago
- Severity set to Major - prevents use of part of Rudder | no simple workaround
- User visibility set to Operational - other Techniques | Technique editor | Rudder settings
- Effort required set to Medium
- Priority changed from 0 to 31
Updated by François ARMAND over 6 years ago
- Subject changed from Extend dynamic groups search capabilities for complex JSON Properties to Extend groups search capabilities for complex JSON Properties / JsonPath
- Target version changed from Ideas (not version specific) to 4.3.2
Updated by François ARMAND over 6 years ago
- Status changed from New to In progress
Updated by François ARMAND over 6 years ago
Now that #12572 is added, we have the possibility to do that ticket in a simple way IF we accept to not modify the select/input layout, which is a big change.
I propose to add a new operator, JSON Path ("Name:JsonPath"), which would allows to use JsonPath in the right part of the ":". JsonPath is a kind of XPath for JSON: https://github.com/json-path/JsonPath.
The semantic would be "as long as the JsonPath selector returns a non-empty list, the search is ok and the node selected".
For example, let say you have a node with a property whose name is "user" and value is:
{ "id": "xxxxxx", "accepted": true, "personal": { "name": "Smith Jones", "address": { "streetaddress": "7 24th Street", "city": "New York", "state": "NY", "postalcode": 10038 }, "phones": [ {"type":"home","number":"(541) 754-3010"}, {"type":"mobile","number":"(541) 754-9999"} ] } } }
The following query would all select the node (I'm only displaying what would go in the input text field):
//select based on the value of a JSON leaf - boolean type user:$.[?(@.accepted==true)]" } //select based on the value of a JSON leaf - string type user:$.personal.address[?(@.city=='New York')] //select because "city" exists (whatever its value) user:$.personal.address.city //select based on a regex user:$.personal.phones[?(@.number=~/.*123.*/)] //select based on belonging to a set user:$.personal.address[?(@.state in ['NY', 'CA', 'LA', 'TX'])]
It's just a glimpse of what is possible, JsonPath allows a lot of other operations. See examples in https://github.com/json-path/JsonPath.
Updated by François ARMAND over 6 years ago
- Status changed from In progress to Pending technical review
- Assignee changed from François ARMAND to Vincent MEMBRÉ
- Pull Request set to https://github.com/Normation/rudder/pull/1961
Updated by François ARMAND over 6 years ago
- Related to Bug #12572: Custom node properties from inventory are not found in group search added
Updated by François ARMAND over 6 years ago
- Related to User story #4670: Allows inventories to be augmented by the user with custom properties added
Updated by François ARMAND over 6 years ago
- Status changed from Pending technical review to Pending release
Applied in changeset rudder|0b8a0e2eb96f36c206c94d9fc41b922f6f59b653.
Updated by Vincent MEMBRÉ over 6 years ago
This bug has been fixed in Rudder 4.3.2 which was released today.
- 4.3.2: Announce Changelog
- Download: https://www.rudder-project.org/site/get-rudder/downloads/
Updated by François ARMAND almost 6 years ago
- Status changed from Pending release to Released
- Priority changed from 29 to 0