Project: M3 (Observability and Analysis / Observability)
File: cluster-common-steps.md

Once a namespace has finished bootstrapping, you must mark it as ready before receiving traffic by using the {{% apiendpoint %}}services/m3db/namespace/ready. {{< tabs name="ready_namespaces" >}} {{% tab name="Command" %}} {{< codeinclude file="docs/includes/quickstart/ready-namespace.sh" language="shell" >}} {{% /tab %}} {{% tab name="Output" %}} ```json { "ready": true } ``` {{% /tab %}} {{< /tabs >}} You can also view the attributes of all namespaces by calling the {{% apiendpoint %}}services/m3db/namespace endpoint {{< tabs name="check_namespaces" >}} {{% tab name="Command" %}} ```shell curl {{% apiendpoint %}}services/m3db/namespace | jq . ``` {{% notice tip %}} Add `?debug=1` to the request to convert nano units in the output into standard units. {{% /notice %}} {{% /tab %}} {{% tab name="Output" %}} ```json { "registry": { "namespaces": { "default": { "bootstrapEnabled": true, "flushEnabled": true, "writesToCommitLog": true, "cleanupEnabled": true, "repairEnabled": false, "retentionOptions": { "retentionPeriodNanos": "43200000000000", "blockSizeNanos": "1800000000000", "bufferFutureNanos": "120000000000", "bufferPastNanos": "600000000000", "blockDataExpiry": true, "blockDataExpiryAfterNotAccessPeriodNanos": "300000000000", "futureRetentionPeriodNanos": "0" }, "snapshotEnabled": true, "indexOptions": { "enabled": true, "blockSizeNanos": "1800000000000" }, "schemaOptions": null, "coldWritesEnabled": false, "runtimeOptions": null } } } } ``` {{% /tab %}} {{< /tabs >}} We recommend a replication factor of 3, with each replica spread across failure domains such as a physical server rack, data center or availability zone. Read our for more details. Read the to determine the appropriate number of shards to specify. M3 supports ingesting and formatted metrics. This quickstart focuses on Prometheus metrics which consist of a value, a timestamp, and tags to bring context and meaning to the metric. You can write metrics using one of two endpoints: - Write a Prometheus remote write query to M3DB with a binary snappy compressed Prometheus WriteRequest protobuf message. {{% apiendpoint %}}json/write - Write a JSON payload of metrics data. This endpoint is quick for testing purposes but is not as performant for production usage. For this quickstart, use the {{% apiendpoint %}}json/write endpoint to write a tagged metric to M3 with the following data in the request body, all fields are required: `tags`: An object of at least one `name`/`value` pairs `timestamp`: The UNIX timestamp for the data `value`: The value for the data, can be of any type {{% notice tip %}} The examples below use `name` as the name for one of the tags, which is a Prometheus reserved tag that allows you to query metrics using the value of the tag to filter results. {{% /notice %}} {{% notice tip %}} Label names may contain ASCII letters, numbers, underscores, and Unicode characters. They must match the regex

{{% /notice %}} {{< tabs name="write_metrics" >}} {{< tab name="Command 1" >}} {{< codeinclude file="docs/includes/write-metrics-1.sh" language="shell" >}} {{< /tab >}} {{< tab name="Command 2" >}} {{< codeinclude file="docs/includes/write-metrics-2.sh" language="shell" >}} {{< /tab >}} {{< tab name="Command 3" >}} {{< codeinclude file="docs/includes/write-metrics-3.sh" language="shell" >}} {{< /tab >}} {{< /tabs >}} M3 supports three query engines: Prometheus (default), Graphite, and the M3 Query Engine. This quickstart uses Prometheus as the query engine, and you have access to . To query metrics, use the {{% apiendpoint %}}queryrange_ endpoint with the following data in the request body, all fields are required: `query`: A PromQL query `start`: Timestamp in `RFC3339Nano` of start range for results `end`: Timestamp in `RFC3339Nano` of end range for results `step`: A duration or float of the query resolution, the interval between results in the timespan between `start` and `end`. Below are some examples using the metrics written above. {{< tabs name="examplepromqlregex" >}} {{% tab name="Linux" %}} <!-- TODO: Check this on Linux --> ```shell curl -X "POST" -G "{{% apiendpoint %}}query_range" \ -d "query=third_avenue" \ -d "start=$(date "+%s" -d "45 seconds ago")" \ -d "end=$( date +%s )" \ -d "step=5s" | jq . ``` {{% /tab %}} {{% tab name="macOS/BSD" %}} ```shell curl -X "POST" -G "{{% apiendpoint %}}query_range" \ -d "query=third_avenue" \ -d "start=$( date -v -45S +%s )" \ -d "end=$( date +%s )" \ -d "step=5s" | jq . ``` {{% /tab %}} {{% tab name="Output" %}} ```json { "status": "success", "data": { "resultType": "matrix", "result": [ { "metric": { "name": "third_avenue", "checkout": "1", "city": "new_york" }, "values": [ [ {{% now %}}, "3347.26" ], [ {{% now %}}, "5347.26" ], [ {{% now %}}, "7347.26" ] ] } ] } } ``` {{% /tab %}} {{< /tabs >}} {{< tabs name="examplepromqlrange" >}} {{% tab name="Linux" %}} <!-- TODO: Check Linux command --> ```shell curl -X "POST" -G "{{% apiendpoint %}}query_range" \ -d "query=third_avenue > 6000" \ -d "start=$(date "+%s" -d "45 seconds ago")" \ -d "end=$( date +%s )" \ -d "step=5s" | jq . ``` {{% /tab %}} {{% tab name="macOS/BSD" %}} ```shell curl -X "POST" -G "{{% apiendpoint %}}query_range" \ -d "query=third_avenue > 6000" \ -d "start=$(date -v -45S "+%s")" \ -d "end=$( date +%s )" \ -d "step=5s" | jq . ``` {{% /tab %}} {{% tab name="Output" %}} ```json { "status": "success", "data": { "resultType": "matrix", "result": [ { "metric": { "name": "third_avenue", "checkout": "1", "city": "new_york" }, "values": [ [ {{% now %}}, "7347.26" ] ] } ] } } ``` {{% /tab %}} {{< /tabs >}}