You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sql_reference.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@ Questions: This guide describes the custom SQL functions supported in OpenObserv
4
4
These functions allow you to filter records based on keyword or pattern matches within one or more fields.
5
5
6
6
### `str_match(field, 'value')`
7
+
7
8
**Alias**: `match_field(field, 'value')` (Available in OpenObserve version 0.15.0 and later) <br>
8
9
9
10
**Description**: <br>
@@ -18,9 +19,12 @@ SELECT * FROM "default" WHERE str_match(k8s_pod_name, 'main-openobserve-ingester
18
19
```
19
20
This query filters logs from the `default` stream where the `k8s_pod_name` field contains the exact string `main-openobserve-ingester-1`. It does not match values such as `Main-OpenObserve-Ingester-1`, `main-openobserve-ingester-0`, or any case variation.
**Alias**: `match_field_ignore_case(field, 'value')` (Available in OpenObserve version 0.15.0 and later)<br>
27
+
24
28
**Description**: <br>
25
29
26
30
- Filters logs where the specified field contains the string value.
@@ -33,6 +37,8 @@ SELECT * FROM "default" WHERE str_match_ignore_case(k8s_pod_name, 'MAIN-OPENOBSE
33
37
```
34
38
This query filters logs from the `default` stream where the `k8s_pod_name` field contains any casing variation of `main-openobserve-ingester-1`, such as `MAIN-OPENOBSERVE-INGESTER-1`, `Main-OpenObserve-Ingester-1`, or `main-openobserve-ingester-1`.
@@ -52,6 +58,8 @@ SELECT * FROM "default" WHERE match_all('openobserve-querier')
52
58
```
53
59
This query returns all logs in the `default` stream where the keyword `openobserve-querier` appears in any of the full-text indexed fields. It matches all casing variations, such as `OpenObserve-Querier` or `OPENOBSERVE-QUERIER`.
@@ -70,13 +78,18 @@ SELECT * FROM "default" WHERE re_match(k8s_container_name, 'openobserve-querier|
70
78
```
71
79
This query returns logs from the `default` stream where the `k8s_container_name` field matches any of the strings `openobserve-querier`, `controller`, or `nats`. The match is case-sensitive.
This query returns logs where the `k8s_container_name` field contains any casing variation of `openobserve-querier`, such as `OpenObserve-Querier` or `OPENOBSERVE-QUERIER`.
@@ -91,6 +104,8 @@ SELECT * FROM "default" WHERE re_not_match(k8s_container_name, 'openobserve-quer
91
104
```
92
105
This query returns logs from the `default` stream where the `k8s_container_name` field does not match any of the values `openobserve-querier`, `controller`, or `nats`. The match is case-sensitive.
@@ -115,6 +130,8 @@ SELECT *, arr_descending(emails) as sorted_emails FROM "default" ORDER BY _times
115
130
In this query, the emails field contains a stringified JSON array such as `["[email protected]", "[email protected]", "[email protected]"]`. The query creates a new field `sorted_emails`, which contains the elements sorted in descending order:
@@ -127,6 +144,8 @@ SELECT *, arrcount(emails) as email_count FROM "default" ORDER BY _timestamp DES
127
144
```
128
145
In this query, the `emails` field contains a value such as `["[email protected]", "[email protected]", "[email protected]"]`. The function counts the number of elements in the array and returns the result: `3`.
@@ -170,6 +193,9 @@ SELECT *, arrsort(emails) as increasing_numbers FROM "default" ORDER BY _timesta
170
193
In this query, the emails field contains a value such as `["[email protected]", "[email protected]", "[email protected]"]`. The function sorts the elements in increasing lexicographical order. The result is:
0 commit comments