Skip to content

Commit a2c83c7

Browse files
committed
add draft a section about dot notation
1 parent 10a5d4a commit a2c83c7

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

doc/.DS_Store

6 KB
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _dot_notation:
2+
3+
Dot Notation
4+
============
5+
6+
Dot notation is used to refer to nested fields inside data structures in our configuration language.
7+
For example, :code:`nested.field` refers to the field :code:`data["event"]["field"]` (Python syntax) inside a nested dictionary called :code:`data`.
8+
9+
This notation can be used throughout the application:
10+
11+
- Lucene-based rule filters: :code:`filter: "nested.field: *"`
12+
- Read or written fields in processor configurations: e.g., :code:`source_fields: ["nested.field"]`, :code:`target_field: "nested.field"`
13+
- Read or written fields in input configurations: e.g., :code:`metafield_name: "nested.field"``
14+
- Read or written fields in output configurations
15+
16+
17+
Escaping Special Characters
18+
---------------------------
19+
20+
Since the dot is interpreted as a special character, it must be escaped with a backslash to be used literally:
21+
:code:`complex\\.field`.
22+
Note that string literals with quotes typically require an additional layer of backslashes:
23+
:code:`target_field: "complex\\\\.field"`.
24+
If backslashes are part of the actual field name, they must also be escaped:
25+
:code:`complex\\field` or :code:`"complex\\\\field"`.
26+
27+
Putting a backslash in front of a non-special character results in the *backslash being dropped* and the character being used literally.
28+
Therefore, a literal backslash can only be produced by using a double backslash in the field reference.
29+
30+
31+
Future Compatibility
32+
--------------------
33+
34+
Dropping backslashes in front of non-special characters provides a downwards-compatible path for introducing new special characters in the syntax.
35+
After announcing an upcoming change, users can start escaping the soon-to-be special character in their configuration files.
36+
This ensures the character is interpreted literally in both the old and new versions, allowing for a seamless transition.

doc/source/configuration/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ Configuration
2121
getter
2222
metrics
2323
yaml_tags
24+
dot_notation

0 commit comments

Comments
 (0)