Skip to content

Commit e130b7e

Browse files
authored
[docs] Update documentation for dynamic namespace configuration in Coordinator (#2874)
1 parent b51a695 commit e130b7e

8 files changed

Lines changed: 172 additions & 56 deletions

File tree

site/content/docs/how_to/cluster_hard_way.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ Shortly after, you should see your node complete bootstrapping:
163163
20:10:14.764771[I] successfully updated topology to 3 hosts
164164
```
165165

166+
Once the node has completed bootstrapping, mark the namespace as ready so the coordinator knows it's ready to receive reads and writes:
167+
168+
```shell
169+
curl -X POST http://localhost:7201/api/v1/services/m3db/namespace/ready -d '{
170+
"name": "1week_namespace"
171+
}
172+
```
173+
166174
If you need to setup multiple namespaces, you can run the above `/api/v1/database/create` command multiple times with different namespace configurations.
167175
168176
### Replication factor (RF)

site/content/docs/how_to/kubernetes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ $ curl -sSf -X POST http://localhost:9003/query -d '{
245245
}
246246
```
247247
248+
To read and write metrics via the Coordinator (and not directly through the DB node API), you must mark the namespace as ready:
249+
250+
```shell
251+
curl -X POST http://localhost:7201/api/v1/services/m3db/namespace/ready -d '{
252+
"name": "default"
253+
}
254+
```
255+
256+
You should now be able to use both the Coordinator and DB node API to perform reads and writes.
257+
248258
### Adding nodes
249259
250260
You can easily scale your M3DB cluster by scaling the StatefulSet and informing the cluster topology of the change:

site/content/docs/how_to/query.md

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,61 @@ The configuration file linked above uses an embedded etcd cluster, which is fine
3434

3535
## Aggregation
3636

37-
You will notice that in the setup linked above, M3DB has just one unaggregated namespace configured. If you want aggregated metrics, you will need to set up an aggregated namespace in M3DB **and** in the m3query configuration. It is important to note that all writes go to all namespaces so as long as you include all namespaces in your query config, you will be querying all namespaces. Aggregation is done strictly by the query service. For example if you have an aggregated namespace setup in M3DB named `metrics_10s_48h`, you can add the following to the query config:
37+
You will notice that in the setup linked above, M3DB has just one unaggregated namespace configured. If you want aggregated metrics, you will need to set up an aggregated namespace. It is important to note that all writes go to all namespaces marked as ready. Aggregation is done strictly by the query service. As an example, to configure an aggregated namespace named `metrics_10s_48h`, you can execute the following API call:
3838

39-
```yaml
40-
- namespace: metrics_10s_48h
41-
type: aggregated
42-
retention: 48h
43-
resolution: 10s
39+
```shell
40+
curl -X POST <M3_COORDINATOR_IP_ADDRESS>:<CONFIGURED_PORT(default 7201)>/api/v1/services/m3db/namespace -d '{
41+
"name": "metrics_10s_48h",
42+
"options": {
43+
"bootstrapEnabled": true,
44+
"flushEnabled": true,
45+
"writesToCommitLog": true,
46+
"cleanupEnabled": true,
47+
"snapshotEnabled": true,
48+
"repairEnabled": false,
49+
"retentionOptions": {
50+
"retentionPeriodDuration": "48h",
51+
"blockSizeDuration": "2h",
52+
"bufferFutureDuration": "10m",
53+
"bufferPastDuration": "10m",
54+
"blockDataExpiry": true,
55+
"blockDataExpiryAfterNotAccessedPeriodDuration": "5m"
56+
},
57+
"indexOptions": {
58+
"enabled": true,
59+
"blockSizeDuration": "2h"
60+
},
61+
"aggregationOptions": {
62+
"aggregations": [
63+
{
64+
"aggregated": true,
65+
"attributes": { "resolutionDuration": "10s" }
66+
}
67+
]
68+
}
69+
}
70+
}'
4471
```
4572

73+
4674
### Disabling automatic aggregation
4775

48-
If you run Statsite, m3agg, or some other aggregation tier, you will want to set the `all` flag under `downsample` to `false`. Otherwise, you will be aggregating metrics that have already been aggregated.
76+
If you run Statsite, m3agg, or some other aggregation tier, you will want to set the `all` flag under `downsample` to `false`. Otherwise, you will be aggregating metrics that have already been aggregated. Using the example above, `aggregationOptions` would be configured as follows
4977

50-
```yaml
51-
- namespace: metrics_10s_48h
52-
type: aggregated
53-
retention: 48h
54-
resolution: 10s
55-
downsample:
56-
all: false
78+
```shell
79+
...
80+
"aggregationOptions": {
81+
"aggregations": [
82+
{
83+
"aggregated": true,
84+
"attributes": {
85+
"resolutionDuration": "10s",
86+
"downsampleOptions": { "all": false }
87+
}
88+
}
89+
]
90+
}
91+
...
5792
```
5893
5994
## ID generation

site/content/docs/how_to/use_as_tsdb.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,15 @@ curl -X POST http://localhost:7201/api/v1/database/create -d '{
143143

144144
Note that the `retentionTime` is set artificially low to conserve resources.
145145

146-
After a few moments, the M3DB container should finish bootstrapping. At this point it should be ready to serve write and read queries.
146+
After a few moments, the M3DB container should finish bootstrapping. Once bootstrapping is finished, mark the namespace as ready to receive traffic:
147+
148+
```shell
149+
curl -X POST http://localhost:7201/api/v1/services/m3db/namespace/ready -d '{
150+
"name": "default"
151+
}
152+
```
153+
154+
At this point it should be ready to serve write and read queries.
147155
148156
#### Clients
149157

site/content/docs/operational_guide/mapping_rollup.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,22 @@ downsample:
140140
retention: 720h
141141
```
142142

143-
**Note:** In order to store rolled up metrics in an `unaggregated` namespace,
144-
a matching `aggregated` namespace must be added to the coordinator config. For
145-
example, if in the above rule, the `720h` namespace under `storagePolicies`
146-
is `unaggregated`, the following will need to be added to the coordinator config.
147-
148-
```yaml
149-
- namespace: default
150-
resolution: 30s
151-
retention: 720h
152-
type: aggregated
153-
downsample:
154-
all: false
143+
**Note:** In order to store rolled up metrics in an `unaggregated` namespace, the namespace's `aggregationOptions` must have a matching `aggregation`. For example, if in the above rule, the `720h` namespace under `storagePolicies`
144+
is `unaggregated`, the `aggregationOptions` for that namespace should resemble the following:
145+
146+
```json
147+
"aggregationOptions": {
148+
"aggregations": [
149+
{
150+
"aggregated": false
151+
},
152+
{
153+
"aggregated": true,
154+
"attributes": {
155+
"resolutionDuration": "30s",
156+
"downsampleOptions": { "all": false }
157+
}
158+
}
159+
]
160+
}
155161
```

site/content/docs/operational_guide/multiple_m3db_clusters.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ Example config file with `clusterManagement` (see end of the config):
1717

1818
```bash
1919
clusters:
20-
# Should match the namespace(s) set up in the DB nodes
21-
- namespaces:
22-
- namespace: 21d
23-
retention: 504h
24-
type: unaggregated
25-
client:
20+
- client:
2621
config:
2722
service:
2823
env: default_env
@@ -45,16 +40,7 @@ clusters:
4540
backoffFactor: 2
4641
maxRetries: 3
4742
jitter: true
48-
- namespaces:
49-
- namespace: 90d
50-
retention: 2160h
51-
type: aggregated
52-
resolution: 10m
53-
- namespace: 500d
54-
retention: 12000h
55-
type: aggregated
56-
resolution: 1h
57-
client:
43+
- client:
5844
config:
5945
service:
6046
env: lts_env

site/content/docs/operational_guide/namespace_configuration.md

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@ curl -X POST <M3_COORDINATOR_IP_ADDRESS>:<CONFIGURED_PORT(default 7201)>/api/v1/
3232

3333
will create a namespace called `default_unaggregated` with a retention of `24 hours`. All of the other namespace options will either use reasonable default values or be calculated based on the provided `retentionTime`.
3434

35-
Adding a namespace does not require restarting M3DB, but will require modifying the M3Coordinator configuration to include the new namespace, and then restarting it.
35+
Adding a namespace requires you mark the namespace as ready once M3DB has finished bootstrapping it. This is done so that M3Coordinator knows the namespace is ready to receive reads and writes. Use the `api/v1/services/m3db/namespace/ready` endpoint to accomplish this:
36+
37+
```shell
38+
curl -X POST <M3_COORDINATOR_IP_ADDRESS>:<CONFIGURED_PORT(default 7201)>/api/v1/services/m3db/namespace/ready -d '{
39+
"name": "default_unaggregated"
40+
}
41+
```
3642
3743
If you feel the need to configure the namespace options yourself (for performance or other reasons), read the `Advanced` section below.
3844
3945
#### Advanced (Hard Way)
4046
4147
The "advanced" API allows you to configure every aspect of the namespace that you're adding which can sometimes be helpful for development, debugging, and tuning clusters for maximum performance.
42-
Adding a namespace is a simple as using the `POST` `api/v1/namespace` API on an M3Coordinator instance.
48+
Adding a namespace is a simple as using the `POST` `api/v1/services/m3db/namespace` API on an M3Coordinator instance.
4349

4450
```shell
4551
curl -X POST <M3_COORDINATOR_IP_ADDRESS>:<CONFIGURED_PORT(default 7201)>/api/v1/services/m3db/namespace -d '{
@@ -52,31 +58,41 @@ curl -X POST <M3_COORDINATOR_IP_ADDRESS>:<CONFIGURED_PORT(default 7201)>/api/v1/
5258
"snapshotEnabled": true,
5359
"repairEnabled": false,
5460
"retentionOptions": {
55-
"retentionPeriod": "2d",
56-
"blockSize": "2h",
57-
"bufferFuture": "10m",
58-
"bufferPast": "10m",
61+
"retentionPeriodDuration": "2d",
62+
"blockSizeDuration": "2h",
63+
"bufferFutureDuration": "10m",
64+
"bufferPastDuration": "10m",
5965
"blockDataExpiry": true,
60-
"blockDataExpiryAfterNotAccessedPeriod": "5m"
66+
"blockDataExpiryAfterNotAccessedPeriodDuration": "5m"
6167
},
6268
"indexOptions": {
6369
"enabled": true,
64-
"blockSize": "2h"
70+
"blockSizeDuration": "2h"
71+
},
72+
"aggregationOptions": {
73+
"aggregations": [
74+
{ "aggregated": false }
75+
]
6576
}
6677
}
6778
}'
6879
```
6980

70-
Adding a namespace does not require restarting M3DB, but will require modifying the M3Coordinator configuration to include the new namespace, and then restarting it.
81+
Adding a namespace requires you to mark the namespace as ready so M3Coordinator know it is ready to receive traffic:
82+
83+
```shell
84+
curl -X POST <M3_COORDINATOR_IP_ADDRESS>:<CONFIGURED_PORT(default 7201)>/api/v1/services/m3db/namespace/ready -d '{
85+
"name": "default_unaggregated"
86+
}
87+
```
7188
7289
### Deleting a Namespace
7390
7491
Deleting a namespace is a simple as using the `DELETE` `/api/v1/services/m3db/namespace` API on an M3Coordinator instance.
7592
7693
`curl -X DELETE <M3_COORDINATOR_IP_ADDRESS>:<CONFIGURED_PORT(default 7201)>/api/v1/services/m3db/namespace/<NAMESPACE_NAME>`
7794
78-
Note that deleting a namespace will not have any effect on the M3DB nodes until they are all restarted. In addition, the namespace will need to be removed from the M3Coordinator configuration and then the M3Coordinator node will need to be restarted.
79-
95+
Note that deleting a namespace will not have any effect on the M3DB nodes until they are all restarted.
8096
### Modifying a Namespace
8197
8298
There is currently no atomic namespace modification endpoint. Instead, you will need to delete a namespace and then add it back again with the same name, but modified settings. Review the individual namespace settings above to determine whether or not a given setting is safe to modify. For example, it is never safe to modify the blockSize of a namespace.
@@ -169,7 +185,7 @@ While it may be tempting to configure `bufferPast` and `bufferFuture` to very la
169185
170186
Can be modified without creating a new namespace: `yes`
171187
172-
### Index Options
188+
### indexOptions
173189
174190
#### enabled
175191
@@ -183,3 +199,26 @@ The size of blocks (in duration) that the index uses.
183199
Should match the databases [blocksize](#blocksize) for optimal memory usage.
184200
185201
Can be modified without creating a new namespace: `no`
202+
203+
### aggregationOptions
204+
Options for the Coordinator to use to make decisions around how to aggregate data points.
205+
206+
Can be modified without creating a new namespace: `yes`
207+
208+
#### aggregations
209+
One or more set of instructions on how data points should be aggregated within the namespace.
210+
211+
##### aggregated
212+
Whether data points are aggregated.
213+
214+
##### attributes
215+
If aggregated is true, specifies how to aggregate data.
216+
217+
###### resolutionNanos
218+
The time range to aggregate data across.
219+
220+
###### downsampleOptions
221+
Options related to downsampling data
222+
223+
###### _all_
224+
Whether to send data points to this namespace. If false, the coordinator will not auto-aggregate incoming data points and data points must be sent the namespace via rules. Defaults to true.

site/content/docs/quickstart/_index.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ This quickstart uses the _{{% apiendpoint %}}database/create_ endpoint that crea
9494

9595
You can create [placements](/docs/operational_guide/placement_configuration/) and [namespaces](/docs/operational_guide/namespace_configuration/#advanced-hard-way) separately if you need more control over their settings.
9696

97-
The `namespaceName` argument must match the namespace in the `local` section of the `M3Coordinator` YAML configuration. If you [add any namespaces](/docs/operational_guide/namespace_configuration) you also need to add them to the `local` section of `M3Coordinator`'s YAML config.
9897

9998
In another terminal, use the following command.
10099

@@ -267,6 +266,31 @@ curl {{% apiendpoint %}}placement | jq .
267266
[Read more about the bootstrapping process](/docs/operational_guide/bootstrapping_crash_recovery/).
268267
{{% /notice %}}
269268

269+
### Readying a Namespace
270+
271+
Once a namespace has finished bootstrapping, it must be marked as ready before receiving traffic. This can be done by calling the _{{% apiendpoint %}}namespace/ready_.
272+
273+
{{< tabs name="ready_namespaces" >}}
274+
{{% tab name="Command" %}}
275+
276+
```shell
277+
curl -X POST http://localhost:7201/api/v1/services/m3db/namespace/ready -d '{
278+
"name": "default"
279+
} | jq .
280+
```
281+
282+
{{% /tab %}}
283+
{{% tab name="Output" %}}
284+
285+
```json
286+
{
287+
"ready": true
288+
}
289+
```
290+
291+
{{% /tab %}}
292+
{{< /tabs >}}
293+
270294
### View Details of a Namespace
271295
272296
You can also view the attributes of all namespaces by calling the _{{% apiendpoint %}}namespace_ endpoint

0 commit comments

Comments
 (0)