|
1 |
| -# Set Settings for stream |
| 1 | +## Set or Update Stream Settings |
2 | 2 |
|
3 |
| -Endpoint: `PUT /api/{organization}/streams/{stream}/settings?type={StreamType}` |
| 3 | +You can configure settings for a stream at creation time or update them later. Use the same endpoint with different HTTP methods depending on the operation. |
4 | 4 |
|
5 |
| -## Request |
| 5 | +## Create Stream Settings |
6 | 6 |
|
| 7 | +Use this operation to define stream settings when creating a stream. |
7 | 8 |
|
8 |
| -- type: logs / metrics / traces |
| 9 | +### Endpoint |
| 10 | +``` |
| 11 | +POST /api/{org_id}/streams/{stream_name}/settings |
| 12 | +``` |
| 13 | +### Request Body |
9 | 14 |
|
10 |
| - default is `logs`. |
| 15 | +Use the `StreamSettings` schema. All fields are optional. |
11 | 16 |
|
12 |
| -- JSON Body |
| 17 | +```json |
| 18 | +{ |
| 19 | + "partition_time_level": "day", |
| 20 | + "partition_keys": ["k8s_cluster", "k8s_namespace_name"], |
| 21 | + "index_fields": ["k8s_pod_name", "service_name"], |
| 22 | + "full_text_search_keys": ["body"], |
| 23 | + "bloom_filter_fields": ["trace_id"], |
| 24 | + "data_retention": 30, |
| 25 | + "flatten_level": 1, |
| 26 | + "defined_schema_fields": ["severity", "log_file_path"], |
| 27 | + "max_query_range": 168, |
| 28 | + "store_original_data": true, |
| 29 | + "approx_partition": false, |
| 30 | + "extended_retention_days": [], |
| 31 | + "index_original_data": false, |
| 32 | + "index_all_values": false |
| 33 | +} |
| 34 | +``` |
| 35 | +### Response |
| 36 | +``` |
| 37 | +{ |
| 38 | + "code": 200 |
| 39 | +} |
| 40 | +``` |
13 | 41 |
|
14 |
| - ```json |
15 |
| - { |
16 |
| - "partition_keys": ["namespace"], |
17 |
| - "full_text_search_keys": ["logs", "body"], |
18 |
| - "index_fields": ["k8s_namespace_name", "k8s_pod_name"], |
19 |
| - "bloom_filter_fields": [], |
20 |
| - "data_retention": 15 |
21 |
| - } |
22 |
| - ``` |
| 42 | +## Update Stream Settings |
| 43 | +Use this operation to partially update an existing stream’s settings. |
23 | 44 |
|
24 |
| -Description |
| 45 | +### Endpoint |
25 | 46 |
|
26 |
| -| Field name | Data type | Default value | Description | |
27 |
| -|------------|-----------|---------------|-------------| |
28 |
| -| partition_keys | array[string] | - | custom partition keys for the stream. By default OpenObserve uses timestamp as the first level partition key | |
29 |
| -| full_text_search_keys | array[string] | - | full text search fields, will created inverted index with split the values to multiple tokens. default OpenObserve uses `log`, `message`, `msg`, `content`, `data`, `json`, if there is no those fields in your stream, will report error: `you should set the full text search fields`. | |
30 |
| -| index_fields | array[string] | - | index fields, will created inverted index with the original value. | |
31 |
| -| bloom_filter_fields | array[string] | - | enable bloom filter for the field, for high cardinal number fields have better performance | |
32 |
| -| data_retention | int64 | - | the default value based on `ZO_COMPACT_DATA_RETENTION_DAYS=3650` | |
| 47 | +``` |
| 48 | +PUT /api/{org_id}/streams/{stream_name}/settings |
| 49 | +``` |
| 50 | +### Request Body |
33 | 51 |
|
34 |
| -## Response |
| 52 | +Use the `UpdateStreamSettings` schema. Fields that support `add`, `remove`, or `set` use wrapper syntax. |
35 | 53 |
|
36 |
| -```json |
| 54 | +``` |
37 | 55 | {
|
38 |
| - "code": 200 |
| 56 | + "data_retention": 120, |
| 57 | + "max_query_range": 30, |
| 58 | + "extended_retention_days": { |
| 59 | + "add": [ |
| 60 | + { |
| 61 | + "start": "2025-06-16T00:00:00Z", |
| 62 | + "end": "2026-02-21T00:00:00Z" |
| 63 | + } |
| 64 | + ] |
| 65 | + } |
39 | 66 | }
|
40 | 67 | ```
|
| 68 | +### Response |
| 69 | +``` |
| 70 | +{ |
| 71 | + "code": 200 |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +## Field Description |
| 76 | + |
| 77 | +| Field name | Description | |
| 78 | +|---------------------------|-------------| |
| 79 | +| `partition_time_level` | Sets time-based partition granularity: `hour`, `day`, or `month`. Default is `hour` for logs and `day` for metrics. | |
| 80 | +| `partition_keys` | Additional fields used to partition data folders. Improves query performance for filtered fields. Use low to medium cardinality fields. | |
| 81 | +| `full_text_search_keys` | Fields to tokenize for full-text search. Required for `match_all` or substring queries. Defaults to common log message field names if unset. | |
| 82 | +| `index_fields` | Fields to enable exact-match indexing. Improves `field = value` query speed. Use selectively to avoid index bloat. | |
| 83 | +| `bloom_filter_fields` | Fields to apply bloom filters. Optimizes rare value lookups. Best for high-cardinality identifiers like `trace_id`. | |
| 84 | +| `data_retention` | Number of days to retain stream data. Overrides global retention. Minimum allowed is 3 days. | |
| 85 | +| `flatten_level` | Defines how many JSON levels to flatten. `0` flattens all levels. Controls field explosion in nested logs. | |
| 86 | +| `defined_schema_fields` | Fields explicitly included in the user-defined schema. Others are dropped or stored raw. Reduces schema and index size. | |
| 87 | +| `max_query_range` | Limits the maximum query window in hours. Prevents overly large queries from affecting performance. | |
| 88 | +| `store_original_data` | Retains the original log body for dropped fields. Enables viewing but not searching unless `index_original_data` is enabled. | |
| 89 | +| `approx_partition` | Enables uniform time slicing for query execution. Improves parallelism for skewed data distributions. | |
| 90 | +| `extended_retention_days` | Defines time ranges to retain data beyond standard retention. Must be configured before data expires. | |
| 91 | +| `index_original_data` | Indexes the raw log body for full-text search. Allows search across fields not defined in the schema. | |
| 92 | +| `index_all_values` | Indexes all fields for exact-match search. Increases ingestion cost. Best for small, stable schemas. | |
| 93 | +| `distinct_value_fields` | Maintains summaries of distinct field values. Powers UI filter suggestions and value lookups. | |
| 94 | + |
| 95 | + |
0 commit comments