Skip to content

Commit 0d56877

Browse files
committed
Centralize API auth instructions into shared section
Move curl authentication examples from the critical nodes endpoint section into a new "Authenticate to API endpoints" section that applies to all HTTP endpoints on the page. The critical nodes section now references the shared section via anchor link. Addresses review feedback from stevendanna on #23368.
1 parent 8a839a7 commit 0d56877

7 files changed

Lines changed: 140 additions & 112 deletions

File tree

src/current/v23.2/monitoring-and-alerting.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,25 @@ If the cluster is unavailable, a database's `crdb_internal` system catalog canno
6969

7070
For details, see [`crdb_internal`]({% link {{ page.version.version }}/crdb-internal.md %}).
7171

72+
### Authenticate to API endpoints
73+
74+
To call the HTTP API endpoints on this page using `curl`:
75+
76+
For an insecure or local testing cluster, use HTTP:
77+
78+
{% include_cached copy-clipboard.html %}
79+
~~~ shell
80+
curl http://<host>:<http-port>/<endpoint>
81+
~~~
82+
83+
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
84+
85+
{% include_cached copy-clipboard.html %}
86+
~~~ shell
87+
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
88+
curl --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/<endpoint>
89+
~~~
90+
7291
### Health endpoints
7392

7493
CockroachDB provides two HTTP endpoints for checking the health of individual nodes.
@@ -209,22 +228,7 @@ If you find under-replicated ranges or constraint violations, you will need to [
209228

210229
#### Request the endpoint
211230

212-
To return the JSON response, send a `POST` request to `/_status/critical_nodes`.
213-
214-
For an insecure or local testing cluster, use HTTP:
215-
216-
{% include_cached copy-clipboard.html %}
217-
~~~ shell
218-
curl -X POST http://<host>:<http-port>/_status/critical_nodes
219-
~~~
220-
221-
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
222-
223-
{% include_cached copy-clipboard.html %}
224-
~~~ shell
225-
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
226-
curl -X POST --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/_status/critical_nodes
227-
~~~
231+
To return the JSON response, send a `POST` request to `/_status/critical_nodes`. For authentication details, refer to [Authenticate to API endpoints](#authenticate-to-api-endpoints).
228232

229233
#### Fields
230234

src/current/v24.1/monitoring-and-alerting.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ If the cluster is unavailable, a database's `crdb_internal` system catalog canno
6767

6868
For details, see [`crdb_internal`]({% link {{ page.version.version }}/crdb-internal.md %}).
6969

70+
### Authenticate to API endpoints
71+
72+
To call the HTTP API endpoints on this page using `curl`:
73+
74+
For an insecure or local testing cluster, use HTTP:
75+
76+
{% include_cached copy-clipboard.html %}
77+
~~~ shell
78+
curl http://<host>:<http-port>/<endpoint>
79+
~~~
80+
81+
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
82+
83+
{% include_cached copy-clipboard.html %}
84+
~~~ shell
85+
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
86+
curl --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/<endpoint>
87+
~~~
88+
7089
### Health endpoints
7190

7291
CockroachDB provides two HTTP endpoints for checking the health of individual nodes.
@@ -207,22 +226,7 @@ If you find under-replicated ranges or constraint violations, you will need to [
207226

208227
#### Request the endpoint
209228

210-
To return the JSON response, send a `POST` request to `/_status/critical_nodes`.
211-
212-
For an insecure or local testing cluster, use HTTP:
213-
214-
{% include_cached copy-clipboard.html %}
215-
~~~ shell
216-
curl -X POST http://<host>:<http-port>/_status/critical_nodes
217-
~~~
218-
219-
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
220-
221-
{% include_cached copy-clipboard.html %}
222-
~~~ shell
223-
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
224-
curl -X POST --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/_status/critical_nodes
225-
~~~
229+
To return the JSON response, send a `POST` request to `/_status/critical_nodes`. For authentication details, refer to [Authenticate to API endpoints](#authenticate-to-api-endpoints).
226230

227231
#### Fields
228232

src/current/v24.3/monitoring-and-alerting.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ If the cluster is unavailable, a database's `crdb_internal` system catalog canno
6767

6868
For details, see [`crdb_internal`]({% link {{ page.version.version }}/crdb-internal.md %}).
6969

70+
### Authenticate to API endpoints
71+
72+
To call the HTTP API endpoints on this page using `curl`:
73+
74+
For an insecure or local testing cluster, use HTTP:
75+
76+
{% include_cached copy-clipboard.html %}
77+
~~~ shell
78+
curl http://<host>:<http-port>/<endpoint>
79+
~~~
80+
81+
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
82+
83+
{% include_cached copy-clipboard.html %}
84+
~~~ shell
85+
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
86+
curl --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/<endpoint>
87+
~~~
88+
7089
### Health endpoints
7190

7291
CockroachDB provides two HTTP endpoints for checking the health of individual nodes.
@@ -207,22 +226,7 @@ If you find under-replicated ranges or constraint violations, you will need to [
207226

208227
#### Request the endpoint
209228

210-
To return the JSON response, send a `POST` request to `/_status/critical_nodes`.
211-
212-
For an insecure or local testing cluster, use HTTP:
213-
214-
{% include_cached copy-clipboard.html %}
215-
~~~ shell
216-
curl -X POST http://<host>:<http-port>/_status/critical_nodes
217-
~~~
218-
219-
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
220-
221-
{% include_cached copy-clipboard.html %}
222-
~~~ shell
223-
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
224-
curl -X POST --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/_status/critical_nodes
225-
~~~
229+
To return the JSON response, send a `POST` request to `/_status/critical_nodes`. For authentication details, refer to [Authenticate to API endpoints](#authenticate-to-api-endpoints).
226230

227231
#### Fields
228232

src/current/v25.2/monitoring-and-alerting.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ If the cluster is unavailable, a database's `crdb_internal` system catalog canno
6767

6868
For details, see [`crdb_internal`]({% link {{ page.version.version }}/crdb-internal.md %}).
6969

70+
### Authenticate to API endpoints
71+
72+
To call the HTTP API endpoints on this page using `curl`:
73+
74+
For an insecure or local testing cluster, use HTTP:
75+
76+
{% include_cached copy-clipboard.html %}
77+
~~~ shell
78+
curl http://<host>:<http-port>/<endpoint>
79+
~~~
80+
81+
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
82+
83+
{% include_cached copy-clipboard.html %}
84+
~~~ shell
85+
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
86+
curl --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/<endpoint>
87+
~~~
88+
7089
### Health endpoints
7190

7291
CockroachDB provides two HTTP endpoints for checking the health of individual nodes.
@@ -204,22 +223,7 @@ If you find under-replicated ranges or constraint violations, you will need to [
204223

205224
#### Request the endpoint
206225

207-
To return the JSON response, send a `POST` request to `/_status/critical_nodes`.
208-
209-
For an insecure or local testing cluster, use HTTP:
210-
211-
{% include_cached copy-clipboard.html %}
212-
~~~ shell
213-
curl -X POST http://<host>:<http-port>/_status/critical_nodes
214-
~~~
215-
216-
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
217-
218-
{% include_cached copy-clipboard.html %}
219-
~~~ shell
220-
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
221-
curl -X POST --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/_status/critical_nodes
222-
~~~
226+
To return the JSON response, send a `POST` request to `/_status/critical_nodes`. For authentication details, refer to [Authenticate to API endpoints](#authenticate-to-api-endpoints).
223227

224228
#### Fields
225229

src/current/v25.4/monitoring-and-alerting.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ If the cluster is unavailable, a database's `crdb_internal` system catalog canno
6767

6868
For details, see [`crdb_internal`]({% link {{ page.version.version }}/crdb-internal.md %}).
6969

70+
### Authenticate to API endpoints
71+
72+
To call the HTTP API endpoints on this page using `curl`:
73+
74+
For an insecure or local testing cluster, use HTTP:
75+
76+
{% include_cached copy-clipboard.html %}
77+
~~~ shell
78+
curl http://<host>:<http-port>/<endpoint>
79+
~~~
80+
81+
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
82+
83+
{% include_cached copy-clipboard.html %}
84+
~~~ shell
85+
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
86+
curl --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/<endpoint>
87+
~~~
88+
7089
### Health endpoints
7190

7291
CockroachDB provides two HTTP endpoints for checking the health of individual nodes.
@@ -181,22 +200,7 @@ If you find under-replicated ranges or constraint violations, you will need to [
181200

182201
#### Request the endpoint
183202

184-
To return the JSON response, send a `POST` request to `/_status/critical_nodes`.
185-
186-
For an insecure or local testing cluster, use HTTP:
187-
188-
{% include_cached copy-clipboard.html %}
189-
~~~ shell
190-
curl -X POST http://<host>:<http-port>/_status/critical_nodes
191-
~~~
192-
193-
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
194-
195-
{% include_cached copy-clipboard.html %}
196-
~~~ shell
197-
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
198-
curl -X POST --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/_status/critical_nodes
199-
~~~
203+
To return the JSON response, send a `POST` request to `/_status/critical_nodes`. For authentication details, refer to [Authenticate to API endpoints](#authenticate-to-api-endpoints).
200204

201205
#### Fields
202206

src/current/v26.1/monitoring-and-alerting.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ If the cluster is unavailable, a database's `crdb_internal` system catalog canno
6767

6868
For details, see [`crdb_internal`]({% link {{ page.version.version }}/crdb-internal.md %}).
6969

70+
### Authenticate to API endpoints
71+
72+
To call the HTTP API endpoints on this page using `curl`:
73+
74+
For an insecure or local testing cluster, use HTTP:
75+
76+
{% include_cached copy-clipboard.html %}
77+
~~~ shell
78+
curl http://<host>:<http-port>/<endpoint>
79+
~~~
80+
81+
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
82+
83+
{% include_cached copy-clipboard.html %}
84+
~~~ shell
85+
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
86+
curl --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/<endpoint>
87+
~~~
88+
7089
### Health endpoints
7190

7291
CockroachDB provides two HTTP endpoints for checking the health of individual nodes.
@@ -181,22 +200,7 @@ If you find under-replicated ranges or constraint violations, you will need to [
181200

182201
#### Request the endpoint
183202

184-
To return the JSON response, send a `POST` request to `/_status/critical_nodes`.
185-
186-
For an insecure or local testing cluster, use HTTP:
187-
188-
{% include_cached copy-clipboard.html %}
189-
~~~ shell
190-
curl -X POST http://<host>:<http-port>/_status/critical_nodes
191-
~~~
192-
193-
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
194-
195-
{% include_cached copy-clipboard.html %}
196-
~~~ shell
197-
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
198-
curl -X POST --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/_status/critical_nodes
199-
~~~
203+
To return the JSON response, send a `POST` request to `/_status/critical_nodes`. For authentication details, refer to [Authenticate to API endpoints](#authenticate-to-api-endpoints).
200204

201205
#### Fields
202206

src/current/v26.2/monitoring-and-alerting.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,25 @@ If the cluster is unavailable, a database's `crdb_internal` system catalog canno
7979

8080
For details, see [`crdb_internal`]({% link {{ page.version.version }}/crdb-internal.md %}).
8181

82+
### Authenticate to API endpoints
83+
84+
To call the HTTP API endpoints on this page using `curl`:
85+
86+
For an insecure or local testing cluster, use HTTP:
87+
88+
{% include_cached copy-clipboard.html %}
89+
~~~ shell
90+
curl http://<host>:<http-port>/<endpoint>
91+
~~~
92+
93+
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
94+
95+
{% include_cached copy-clipboard.html %}
96+
~~~ shell
97+
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
98+
curl --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/<endpoint>
99+
~~~
100+
82101
### Health endpoints
83102

84103
CockroachDB provides two HTTP endpoints for checking the health of individual nodes.
@@ -193,22 +212,7 @@ If you find under-replicated ranges or constraint violations, you will need to [
193212

194213
#### Request the endpoint
195214

196-
To return the JSON response, send a `POST` request to `/_status/critical_nodes`.
197-
198-
For an insecure or local testing cluster, use HTTP:
199-
200-
{% include_cached copy-clipboard.html %}
201-
~~~ shell
202-
curl -X POST http://<host>:<http-port>/_status/critical_nodes
203-
~~~
204-
205-
For a secure cluster, authenticate to the HTTPS endpoint with [`cockroach auth-session login`]({% link {{ page.version.version }}/cockroach-auth-session.md %}#log-in-to-the-http-interface), then pass the authentication cookie to `curl`.
206-
207-
{% include_cached copy-clipboard.html %}
208-
~~~ shell
209-
cockroach auth-session login <user> --certs-dir=certs --only-cookie > $HOME/.cockroachdb_api_key
210-
curl -X POST --cookie $HOME/.cockroachdb_api_key --cacert certs/ca.crt https://<host>:<http-port>/_status/critical_nodes
211-
~~~
215+
To return the JSON response, send a `POST` request to `/_status/critical_nodes`. For authentication details, refer to [Authenticate to API endpoints](#authenticate-to-api-endpoints).
212216

213217
#### Fields
214218

0 commit comments

Comments
 (0)