Skip to content

Commit 56e04ea

Browse files
committed
updated images
1 parent 9de1132 commit 56e04ea

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/sql_reference.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Questions: This guide describes the custom SQL functions supported in OpenObserv
44
These functions allow you to filter records based on keyword or pattern matches within one or more fields.
55

66
### `str_match(field, 'value')`
7+
78
**Alias**: `match_field(field, 'value')` (Available in OpenObserve version 0.15.0 and later) <br>
89

910
**Description**: <br>
@@ -18,9 +19,12 @@ SELECT * FROM "default" WHERE str_match(k8s_pod_name, 'main-openobserve-ingester
1819
```
1920
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.
2021

22+
![str_match](./images/sql-reference/str-match.png)
23+
2124
---
2225
### `str_match_ignore_case(field, 'value')`
2326
**Alias**: `match_field_ignore_case(field, 'value')` (Available in OpenObserve version 0.15.0 and later)<br>
27+
2428
**Description**: <br>
2529

2630
- 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
3337
```
3438
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`.
3539

40+
![str_match_ignore_case](./images/sql-reference/str-ignore-case.png)
41+
3642
---
3743

3844
### `match_all('value')`
@@ -52,6 +58,8 @@ SELECT * FROM "default" WHERE match_all('openobserve-querier')
5258
```
5359
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`.
5460

61+
![match_all](./images/sql-reference/match-all.png)
62+
5563
---
5664
### `re_match(field, 'pattern')`
5765
**Description**: <br>
@@ -70,13 +78,18 @@ SELECT * FROM "default" WHERE re_match(k8s_container_name, 'openobserve-querier|
7078
```
7179
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.
7280

81+
![re_match](./images/sql-reference/re-match.png)
82+
83+
7384
To perform a case-insensitive search:
7485

7586
```sql
7687
SELECT * FROM "default" WHERE re_match(k8s_container_name, '(?i)openobserve-querier')
7788
```
7889
This query returns logs where the `k8s_container_name` field contains any casing variation of `openobserve-querier`, such as `OpenObserve-Querier` or `OPENOBSERVE-QUERIER`.
7990

91+
![re_match_ignore_case](./images/sql-reference/re-match-ignore-case.png)
92+
8093
---
8194

8295
### `re_not_match(field, 'pattern')`
@@ -91,6 +104,8 @@ SELECT * FROM "default" WHERE re_not_match(k8s_container_name, 'openobserve-quer
91104
```
92105
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.
93106

107+
![re_not_match](./images/sql-reference/re-not-match.png)
108+
94109
---
95110

96111
## Array Functions
@@ -115,6 +130,8 @@ SELECT *, arr_descending(emails) as sorted_emails FROM "default" ORDER BY _times
115130
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:
116131
117132

133+
![arr_descending](./images/sql-reference/array-descending.png)
134+
118135
---
119136

120137
### `arrcount(arrfield)`
@@ -127,6 +144,8 @@ SELECT *, arrcount(emails) as email_count FROM "default" ORDER BY _timestamp DES
127144
```
128145
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`.
129146

147+
![arrcount](./images/sql-reference/array-count.png)
148+
130149
---
131150

132151
### `arrindex(field, start, end)`
@@ -142,6 +161,8 @@ SELECT *, arrindex(emails, 0, 1) as selected_emails FROM "default" ORDER BY _tim
142161
In this query, the `emails` field contains a value such as `["[email protected]", "[email protected]", "[email protected]"]`. The function extracts elements at index `0` and `1`. The result is:
143162
144163

164+
![arrindex](./images/sql-reference/array-index.png)
165+
145166
---
146167

147168
### `arrjoin(field, delimiter)`
@@ -156,6 +177,8 @@ SELECT *, arrjoin(emails, ' | ') as joined_numbers FROM "default" ORDER BY _time
156177
In this query, the `emails` field contains a value such as `["[email protected]", "[email protected]", "[email protected]"]`. The function joins all elements using the delimiter `|`. The result is:
157178
158179

180+
![arr_join](./images/sql-reference/array-join.png)
181+
159182
---
160183

161184
### `arrsort(field)`
@@ -170,6 +193,9 @@ SELECT *, arrsort(emails) as increasing_numbers FROM "default" ORDER BY _timesta
170193
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:
171194
172195

196+
![arrsort](./images/sql-reference/array-sort.png)
197+
198+
173199
---
174200

175201
### `arrzip(field1, field2, delimiter)`
@@ -186,6 +212,8 @@ In this query, the `emails` field contains `["[email protected]", "[email protected]"]` a
186212
The result is:
187213
188214

215+
![arrzip](./images/sql-reference/array-zip.png)
216+
189217
---
190218

191219
### `spath(field, path)`
@@ -287,6 +315,8 @@ Each row in the result shows:
287315
- **`key`**: The start time of the 30-second bucket.
288316
- **`num`**: The count of log records that fall within that time bucket.
289317

318+
![histogram](./images/sql-reference/histogram.png)
319+
290320
!!! note
291321
To avoid unexpected bucket sizes based on internal defaults, always specify the bucket duration explicitly using units.
292322

0 commit comments

Comments
 (0)