mirror of
https://github.com/floci-io/floci.git
synced 2026-12-05 02:58:00 -05:00
feat(logs): support stats, ispresent and like in Insights queries (#9925)
This commit is contained in:
1 parent
da918e772c
commit
df3fe5ce38
5 files changed
+538
-42
No files matched your search
@@ -310,13 +310,19 @@ with `InvalidParameterException`. Supported commands:
|
||||
|---|---|
|
||||
| `fields a, b, ...` | Projection. Defaults to `@timestamp, @message`. `display` is an alias |
|
||||
| `filter <field> = 'v'` | Equality. `!=` and `==` are also accepted; `where` is an alias. An unquoted value must be a number and compares by value, so `n = 2` matches `2` and `2.0`. Comparisons can be joined with `or` (any case) and grouped with parentheses, for example `filter (type = 'A' or type = 'B')` |
|
||||
| `filter ispresent(field)` | Keeps events whose field exists and is not JSON `null` |
|
||||
| `filter field like /regex/` | Matches with a regular expression; `like 'text'` matches a substring, and `not like` negates either form |
|
||||
| `stats ... [by field, bin(1h)]` | Supports `count(*)`, `count(field)`, `count_distinct(field)`, and `latest(field)`, with optional aliases and grouping fields or time bins. Place `stats` after any filters and before `sort` or `limit` |
|
||||
| `sort <field> [asc\|desc]` | `order` is an alias |
|
||||
| `dedup <field, ...>` | Keeps the first row per unique tuple, applied after sorting |
|
||||
| `limit N` | The effective cap is the smallest of this value, the `StartQuery` `limit` parameter, and `FLOCI_SERVICES_CLOUDWATCHLOGS_MAX_EVENTS_PER_QUERY` |
|
||||
|
||||
Fields may be `@timestamp`, `@message`, `@ingestionTime`, `@ptr`, or a dotted path into
|
||||
a JSON log message (for example `level` or `params.job_id`). A `@ptr` column is always
|
||||
included in each result row, appended unless `fields` already names it.
|
||||
a JSON log message (for example `level` or `params.job_id`). A `@ptr` column is included
|
||||
in each nonaggregated result row, appended unless `fields` already names it. A `stats`
|
||||
result contains only its aggregate and grouping columns. For `stats` queries,
|
||||
`statistics.recordsMatched` counts matching log events, not aggregate result rows. For
|
||||
nonaggregated queries, it counts rows returned after `dedup` and `limit`.
|
||||
|
||||
A command or filter operator outside this subset fails the query instead of being dropped:
|
||||
`StartQuery` still returns a query id, and `GetQueryResults` reports `status: Failed` with no
|
||||
@@ -326,16 +332,16 @@ degrade silently, so it is worth knowing how each case behaves:
|
||||
|
||||
| Input | Result |
|
||||
|---|---|
|
||||
| An unsupported command (`stats`, `parse`, ...) | The query fails. Logged as `Unsupported command: stats` |
|
||||
| A `filter` whose operator is not `=`, `!=` or `==`, for example `<`, `<=`, `>`, `>=`, `like /ERROR/` or `=~ /ERROR/` | The query fails. Logged as `Unsupported filter expression: ...` |
|
||||
| A `filter` using `and`, `not` or `\|\|`, or with text after the value, as in `filter level = 'ERROR' x` | The query fails. AWS evaluates `and` and `not`, ignores the trailing text, and rejects an unparenthesized `\|\|` at `StartQuery` with `MalformedQueryException` (use `or`) |
|
||||
| An unsupported command (`parse`, ...) | The query fails. Logged as `Unsupported command: parse` |
|
||||
| A `filter` whose operator is not supported, for example `<`, `<=`, `>`, `>=` or `=~ /ERROR/` | The query fails. Logged as `Unsupported filter expression: ...` |
|
||||
| A `filter` using `and`, a standalone `not` or `\|\|`, or with text after the value, as in `filter level = 'ERROR' x` | The query fails. AWS evaluates `and` and `not`, ignores the trailing text, and rejects an unparenthesized `\|\|` at `StartQuery` with `MalformedQueryException` (use `or`) |
|
||||
| A blank query, or an empty stage as in a trailing `\|` | The query fails. AWS rejects it at `StartQuery` |
|
||||
| A `filter` with a backslash escape, a backtick-quoted field name, an expression such as `1+1` in place of the field, or an unquoted value that is not a number, such as `level = ERROR` or `n = 1+1` | The query fails. AWS interprets them |
|
||||
| A quoted filter value with a backslash escape, a backtick-quoted field name, an expression such as `1+1` in place of the field, or an unquoted value that is not a number, such as `level = ERROR` or `n = 1+1` | The query fails. Backslash escapes within `like /regex/` are supported |
|
||||
| A projected field that does not exist | Rendered as an empty string. No warning |
|
||||
| A `sort` direction other than `asc` / `desc` | Treated as ascending. No warning |
|
||||
|
||||
For matching events by a pattern, `FilterLogEvents` is the more predictable option today: it
|
||||
applies the filter pattern syntax (`?ERROR ?WARN`, `{ $.level = "ERROR" }`, and so on) as AWS does.
|
||||
For CloudWatch filter pattern syntax (`?ERROR ?WARN`, `{ $.level = "ERROR" }`, and so on),
|
||||
use `FilterLogEvents`.
|
||||
|
||||
### Reading events past the limit
|
||||
|
||||
|
||||
Reference in new issue
Block a user