Skip to content

Commit d7c50d4

Browse files
Merge pull request #74 from axoflow/some-filterx-fixes
Some filterx fixes
2 parents a09338f + e9dbcae commit d7c50d4

File tree

3 files changed

+31
-32
lines changed

3 files changed

+31
-32
lines changed

content/filterx/_index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ filterx {
8585
The same is true for complex objects, like JSON, for example:
8686

8787
```shell
88-
js = json_object({
88+
js = json({
8989
"key": "value",
9090
"second-key": "another-value"
9191
});
@@ -145,7 +145,7 @@ Variables can have the following types. All of these types have a matching funct
145145
- `dict`
146146
- `double`
147147
- `int`
148-
- [`json, json_object`]({{< relref "/filterx/function-reference.md#json" >}}) and [`json_array`]({{< relref "/filterx/function-reference.md#json-array" >}}) for JSON or JSON-like objects. The `json` type is an alias for the `json_object` type.
148+
- [`json`]({{< relref "/filterx/function-reference.md#json" >}}) and [`json_array`]({{< relref "/filterx/function-reference.md#json-array" >}}) for JSON or JSON-like objects.
149149
- `list`
150150
- `null`
151151
- `otel_array`
@@ -254,7 +254,7 @@ my_list = []; # Creates an empty list (which defaults to a JSON list)
254254
my_array = {}; # Creates an empty dictionary (which defaults to a JSON object)
255255

256256
my_list2 = json_array(); # Creates an empty JSON list
257-
my_array2 = json_object(); # Creates an empty JSON object. json() is an alias for json_object()
257+
my_array2 = json(); # Creates an empty JSON object.
258258
```
259259

260260
You can add elements to lists and dictionaries like this:
@@ -287,7 +287,7 @@ ${MESSAGE} = list;
287287

288288
In all three cases, the value of `${MESSAGE}` is the same JSON array: `["first_element", "second_element", "third_element"]`.
289289

290-
You can define JSON objects using the `json_object` type, for example:
290+
You can define JSON objects using the `json()` type, for example:
291291

292292
```shell
293293
js1 = json();
@@ -300,14 +300,14 @@ js1 += {
300300
}
301301
};
302302

303-
js2 = json_object({"key": "value"})
303+
js2 = json({"key": "value"})
304304
```
305305

306306
Naturally, you can assign values from other variables to an object, for example:
307307

308308
```shell
309309
js = json_array(["foo", "bar", "baz"]);
310-
${MESSAGE} = json_object({
310+
${MESSAGE} = json({
311311
"key": "value",
312312
"list": list
313313
});
@@ -316,7 +316,7 @@ ${MESSAGE} = json_object({
316316
or
317317

318318
```shell
319-
js = json_object({
319+
js = json({
320320
"key": ${MY-NAME-VALUE-PAIR},
321321
"key-from-expression": isset(${HOST}) ? ${HOST} : "default-hostname",
322322
"list": list

content/filterx/function-reference.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Functions have arguments that can be either mandatory or optional.
1717

1818
## cache_json_file {#cache-json-file}
1919

20-
Load the contents of an external JSON file in an efficient manner. You can use this to lookup contextual information. (Basically, this is a FilterX-specific implementation of the [`add-contextual-data() functionality`]({{< relref "/chapter-enrich-data/data-enrichment-add-contextual-data/_index.md" >}}).)
20+
Load the contents of an external JSON file in an efficient manner. You can use this function to lookup contextual information. (Basically, this is a FilterX-specific implementation of the [`add-contextual-data() functionality`]({{< relref "/chapter-enrich-data/data-enrichment-add-contextual-data/_index.md" >}}).)
2121

2222
Usage: `cache_json_file("/path/to/file.json")`
2323

@@ -61,8 +61,8 @@ date = datetime("1701350398.123000+01:00");
6161

6262
Usually, you use the [strptime](#strptime) FilterX function to create datetime values. Alternatively, you can cast an integer, double, string, or isodate variable into datetime with the `datetime()` FilterX function. Note that:
6363

64-
- When casting from an integer, the integer is the number of microseconds elapsed since the UNIX epoch (January 1, 1970 12:00:00 AM).
65-
- When casting from a double, the double is the number of seconds elapsed since the UNIX epoch (January 1, 1970 12:00:00 AM). (The part before the floating points is the seconds, the part after the floating point is the microseconds.)
64+
- When casting from an integer, the integer is the number of microseconds elapsed since the UNIX epoch (00:00:00 UTC on 1 January 1970).
65+
- When casting from a double, the double is the number of seconds elapsed since the UNIX epoch (00:00:00 UTC on 1 January 1970). (The part before the floating points is the seconds, the part after the floating point is the microseconds.)
6666
- When casting from a string, the string (for example, `1701350398.123000+01:00`) is interpreted as: `<the number of seconds elapsed since the UNIX epoch>.<microseconds>+<timezone relative to UTC (GMT +00:00)>`
6767

6868
## flatten
@@ -90,7 +90,7 @@ Only the input is mandatory, other arguments are optional. Note that the delimit
9090

9191
By default, the delimiter is the comma (`delimiter=","`), the `columns` and `default_value` are empty.
9292

93-
If the `columns` option is set, {{< product >}} checks that the number of entries in the input data matches the number of columns. If there are fewer entries, it adds the `default_value` to the missing entries.
93+
If the `columns` option is set, {{< product >}} checks that the number of fields or entries in the input data matches the number of columns. If there are fewer items, it adds the `default_value` to the missing entries.
9494

9595
## format_kv {#format-kv}
9696

@@ -137,18 +137,20 @@ Usage: `istype(object, "type_str")`
137137
For example:
138138

139139
```shell
140-
istype({"key": "value"}, "json_object"); # True
140+
obj = json();
141+
istype(obj, "json_object"); # True
142+
141143
istype(${PID}, "string");
142144
istype(my-local-json-object.mylist, "json_array");
143145
```
144146

145147
If the object doesn't exist, `istype()` returns with an error, causing the FilterX statement to become false, and logs an error message to the `internal()` source of {{< product >}}.
146148

147-
## json, json_object {#json}
149+
## json {#json}
148150

149-
Cast a value into a JSON object. `json_object()` is an alias for `json()`.
151+
Cast a value into a JSON object.
150152

151-
Usage: `json(<string or expression to cast as json>)`
153+
Usage: `json(<string or expression to cast to json>)`
152154

153155
For example:
154156

@@ -160,7 +162,7 @@ js = json({"key": "value"});
160162

161163
Cast a value into a JSON array.
162164

163-
Usage: `json_array(<string or expression to cast as json array>)`
165+
Usage: `json_array(<string or expression to cast to json array>)`
164166

165167
For example:
166168

@@ -176,7 +178,7 @@ Usage: `len(object)`
176178

177179
## lower
178180

179-
Converts a string into lowercase characters.
181+
Converts all characters of a string lowercase characters.
180182

181183
Usage: `lower(string)`
182184

@@ -202,19 +204,19 @@ Creates an [OpenTelemetry scope object]({{< relref "/filterx/filterx-otel/_index
202204

203205
## parse_csv {#parse-csv}
204206

205-
Separate a comma-separated or similar string.
207+
Split a comma-separated or similar string.
206208

207209
Usage: `parse_csv(msg_str [columns=json_array, delimiter=string, string_delimiters=json_array, dialect=string, strip_whitespace=boolean, greedy=boolean])`
208210

209211
For details, see {{% xref "/filterx/filterx-parsing/csv/_index.md" %}}.
210212

211213
## parse_kv {#parse-kv}
212214

213-
Separate a string consisting of whitespace or comma-separated `key=value` pairs (for example, WELF-formatted messages).
215+
Split a string consisting of whitespace or comma-separated `key=value` pairs (for example, WELF-formatted messages).
214216

215217
Usage: `parse_kv(msg, value_separator="=", pair_separator=", ", stray_words_key="stray_words")`
216218

217-
The `value_separator` must be a single-character string. The `pair_separator` must be a string.
219+
The `value_separator` must be a single character. The `pair_separator` can consist of multiple characters.
218220

219221
For details, see {{% xref "/filterx/filterx-parsing/key-value-parser/_index.md" %}}.
220222

@@ -255,7 +257,7 @@ ${MY-LIST}.named = regexp_search("first-word second-part third", /(?<one>first-w
255257

256258
### Mixed match groups
257259

258-
If you use mixed (some named, some unnamed) groups, the output is a dictionary, where {{< product >}} automatically assigns a key to the unnamed groups. For example:
260+
If you use mixed (some named, some unnamed) groups in your regular expression, the output is a dictionary, where {{< product >}} automatically assigns a key to the unnamed groups. For example:
259261

260262
```shell
261263
${MY-LIST} = json(); # Creates an empty JSON object
@@ -286,19 +288,17 @@ regexp_subst(${MESSAGE}, "IP", "IP-Address", global=true);
286288

287289
{{< include-headless "chunk/filterx-regexp-notes.md" >}}
288290

289-
For a case sensitive search, use the `ignorecase=true` option.
290-
291291
### Options
292292

293293
You can use the following flags with the `regexp_subst` function:
294294

295295
- `global=true`:
296296

297-
Replace every occurrence of the search string.
297+
Replace every match of the regular expression, not only the first one.
298298

299299
- `ignorecase=true`:
300300

301-
Do case insensitive search.
301+
Do case insensitive match.
302302

303303
- `jit=true`:
304304

@@ -310,7 +310,7 @@ You can use the following flags with the `regexp_subst` function:
310310

311311
## string
312312

313-
Cast a value into a string. Note currently {{< product >}} evaluates strings and executes [template functions]({{< relref "/filterx/_index.md#template-functions" >}}) and template expressions. In the future, template evaluation will be moved to a separate FilterX function.
313+
Cast a value into a string. Note that currently {{< product >}} evaluates strings and executes [template functions]({{< relref "/filterx/_index.md#template-functions" >}}) and template expressions within the strings. In the future, template evaluation will be moved to a separate FilterX function.
314314

315315
Usage: `string(<string or expression to cast>)`
316316

@@ -340,11 +340,11 @@ If none of the format strings match, `strptime` returns the null value and logs
340340

341341
{{% /alert %}}
342342

343-
You can use the following elements in the format string:
343+
You can use the following format codes in the format string:
344344

345345
{{< include-headless "chunk/date-string-format.md" >}}
346346

347-
The [`isodate`](#isodate) FilterX function is a specialized version of `strptime` that accepts only a fixed format.
347+
The [`isodate`](#isodate) FilterX function is a specialized variant of `strptime`, that accepts only a fixed format.
348348

349349
## unset
350350

@@ -389,7 +389,7 @@ Usage: `unset_empties(object, recursive=true)`
389389

390390
## upper
391391

392-
Converts a string into uppercase characters.
392+
Converts all characters of a string uppercase characters.
393393

394394
Usage: `upper(string)`
395395

content/headless/chunk/date-string-format.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@
4444
4545
{{% alert title="Warning" color="warning" %}}
4646
47-
When using the %z and %Z format elements, consider that while %z strictly expects a specified timezone, and triggers a warning if the timezone is not specified, %Z does not trigger a warning if the timezone is not specified.
47+
When using the `%z` and `%Z` format codes, consider that while `%z` strictly expects a specified timezone, and triggers a warning if the timezone is missing, `%Z` does not trigger a warning if the timezone is not specified.
4848
49-
For further information about the %z and %Z format elements, see the 'DESCRIPTION' section on the [srtptime(3) - NetBSD Manual Pages](https://man.netbsd.org/NetBSD-7.0/i386/strptime.3).
49+
For further information about the `%z` and `%Z` format codes, see the 'DESCRIPTION' section on the [srtptime(3) - NetBSD Manual Pages](https://man.netbsd.org/NetBSD-7.0/i386/strptime.3).
5050
5151
{{% /alert %}}
5252
53-
5453
For example, for the date `01/Jan/2016:13:05:05 PST` use the following format string: `"%d/%b/%Y:%H:%M:%S %Z"`

0 commit comments

Comments
 (0)