Commit 9396d9b
authored
feat: detect schema for a log event (#966)
Server can generate schema for a sample log event
before creating stream. This helps user create the static schema
New API endpoint `POST /logstream/schema/detect` with body as a json object
returns schema. Also supports json array input.
eg. for request json -
```
{
"datetime": "2024-10-21T05:40:58.280Z",
"b": 2.0,
"c": 1,
"host": "backend",
"a": false,
"id": "duzrixscdpavbdgc",
"message": "Tom is interested in mathematics.",
"method": "GET",
"p_metadata": "state=fatal",
"p_tags": "environment=development",
"p_timestamp": "2024-10-15T14:00:00+05:30",
"referrer": "http://www.facebook.com/",
"status": 404,
"user-identifier": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 OPR/91.0.4516.20"
}
```
API returns
```
{
"fields": [
{
"name": "datetime",
"data_type": {
"Timestamp": [
"Millisecond",
null
]
},
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "b",
"data_type": "Float64",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "c",
"data_type": "Int64",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "host",
"data_type": "Utf8",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "a",
"data_type": "Boolean",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "id",
"data_type": "Utf8",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "message",
"data_type": "Utf8",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "method",
"data_type": "Utf8",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "p_metadata",
"data_type": "Utf8",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "p_tags",
"data_type": "Utf8",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "p_timestamp",
"data_type": {
"Timestamp": [
"Millisecond",
null
]
},
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "referrer",
"data_type": "Utf8",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "status",
"data_type": "Int64",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
},
{
"name": "user-identifier",
"data_type": "Utf8",
"nullable": true,
"dict_id": 0,
"dict_is_ordered": false,
"metadata": {}
}
],
"metadata": {}
}
```
console then asks user to confirm this schema or change as per his requirement
once confirmed, he can create stream with the static schema1 parent d39e2f1 commit 9396d9b
File tree
5 files changed
+76
-0
lines changed- server/src
- event
- handlers/http
- modal
- rbac
5 files changed
+76
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
92 | 114 | | |
93 | 115 | | |
94 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
261 | 272 | | |
262 | 273 | | |
263 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
295 | 306 | | |
296 | 307 | | |
297 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
| |||
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| 219 | + | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
| |||
0 commit comments