You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/admin/monitoring/prometheus-grafana.md
+50-24Lines changed: 50 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,32 +3,33 @@
3
3
4
4
## Introduction
5
5
6
-
If you are running CrateDB in a production environment, you have probably wondered what would be the best way to monitor the servers to identify issues before they become problematic and to collect statistics that you can use for capacity planning.
6
+
In production, monitor CrateDB proactively to catch issues early and
7
+
collect statistics for capacity planning.
7
8
8
-
We recommend pairing two well-known OSS solutions, [Prometheus](https://prometheus.io/) which is a system that collects and stores performance metrics, and [Grafana](https://grafana.com/) which is a system to create dashboards.
9
+
Pair two OSS tools: use [Prometheus] to collect and store metrics,
10
+
and [Grafana] to build dashboards.
9
11
10
12
For a CrateDB environment, we are interested in:
11
13
* CrateDB-specific metrics, such as the number of shards or number of failed queries
12
14
* and OS metrics, such as available disk space, memory usage, or CPU usage
13
15
14
16
For what concerns CrateDB-specific metrics we recommend making these available to Prometheus by using the [Crate JMX HTTP Exporter](https://cratedb.com/docs/crate/reference/en/5.1/admin/monitoring.html#exposing-jmx-via-http) and [Prometheus SQL Exporter](https://github.com/justwatchcom/sql_exporter). For what concerns OS metrics, in Linux environments, we recommend using the [Prometheus Node Exporter](https://prometheus.io/docs/guides/node-exporter/).
15
17
16
-
Things are a bit different of course if you are using containers, or if you are using the fully-managed cloud-hosted [CrateDB Cloud](https://cratedb.com/products/cratedb-cloud), but let’s see how all this works on an on-premises installation by setting all this up together.
18
+
Containerized and [CrateDB Cloud] setups differ. This tutorial targets
19
+
standalone and on‑premises installations.
17
20
18
21
## First we need a CrateDB cluster
19
22
20
23
First things first, we will need a CrateDB cluster, you may have one already and that is great, but if you do not we can get one up quickly.
21
24
22
25
You can review the installation documentation at {ref}`install` and {ref}`multi_node_setup`.
23
26
24
-
In my case, I am using Ubuntu and I did it like this, first I ssh to the first machine and run:
25
-
26
-
```
27
+
On Ubuntu, start on the first node and run:
28
+
```shell
27
29
nano /etc/default/crate
28
30
```
29
31
30
-
This is a configuration file that will be used by CrateDB, we only need one line to configure memory settings here (this is a required step otherwise we will fail bootstrap checks):
31
-
32
+
This configuration file sets the JVM heap. Configure it to satisfy bootstrap checks:
32
33
```
33
34
CRATE_HEAP_SIZE=4G
34
35
```
@@ -89,9 +90,10 @@ And this requires both nodes to be available for the cluster to operate in this
You would run this on a machine that is not part of the CrateDB cluster and it can be installed with:
225
228
226
-
```
229
+
```shell
227
230
apt install prometheus --no-install-recommends
228
231
```
229
232
230
-
Please note that by default this will right away become available on port 9090 without authentication requirements, you can use `policy-rcd-declarative` to prevent the service from starting immediately after installation and you can define a YAML web config file with `basic_auth_users` and then refer to that file in `/etc/default/prometheus`.
233
+
By default, Prometheus binds to :9090 without authentication. Prevent
234
+
auto-start during install (e.g., with `policy-rcd-declarative`), then
235
+
configure web auth using a YAML file.
231
236
232
-
For a large deployment where you also use Prometheus to monitor other systems, you may also want to use a CrateDB cluster as the storage for all Prometheus metrics, you can read more about this at [CrateDB Prometheus Adapter](https://github.com/crate/cratedb-prometheus-adapter).
237
+
Create `/etc/prometheus/web.yml`:
233
238
234
-
Now we will configure Prometheus to scrape metrics from the node explorer from the CrateDB machines and also metrics from our Crate JMX HTTP Exporter:
239
+
basic_auth_users:
240
+
admin: <bcrypt hash>
235
241
236
-
```
242
+
Point Prometheus at it (e.g., `/etc/default/prometheus`):
Now we will configure Prometheus to scrape metrics from the node explorer from
254
+
the CrateDB machines and also metrics from our Crate JMX HTTP Exporter:
255
+
```shell
237
256
nano /etc/prometheus/prometheus.yml
238
257
```
239
258
240
259
Where it says:
241
-
242
260
```yaml
243
261
- job_name: 'node'
244
262
static_configs:
245
263
- targets: ['localhost:9100']
246
264
```
247
265
248
-
We replace this with the below configuration, which reflects port 8080 (Crate JMX Exporter), port 9100 (Prometheus Node Exporter), port 9237 (Prometheus SQL Exporter), as well as port 9100 (Prometheus Node Exporter).
266
+
Replace it with the following jobs: port 9100 (Node Exporter),
267
+
port 8080 (Crate JMX Exporter), and port 9237 (SQL Exporter),
268
+
like outlined below.
249
269
```yaml
250
270
- job_name: 'node'
251
271
static_configs:
@@ -272,9 +292,11 @@ apt install grafana
272
292
systemctl start grafana-server
273
293
```
274
294
275
-
If you now point your browser to *http://\<Grafana host>:3000* you will be welcomed by the Grafana login screen, the first time you can log in with admin as both the username and password, make sure to change this password right away.
295
+
Open `http://<grafana-host>:3000` to access the Grafana login screen.
296
+
The default credentials are `admin`/`admin`; change the password immediately.
276
297
277
-
Click on "Add your first data source", then click on "Prometheus", and enter the URL *http://\<Prometheus host>:9090*.
298
+
Click on "Add your first data source", then click "Prometheus" and set the
299
+
URL to `http://<prometheus-host>:9090`.
278
300
279
301
If you had configured basic authentication for Prometheus this is where you would need to enter the credentials.
280
302
@@ -298,7 +320,6 @@ If you decide to build your own dashboard or use an entirely different monitorin
298
320
* Circuit breaker memory in use: `sum(crate_circuitbreakers{property="used"}) by (name)`
299
321
* Number of shards: `crate_node{name="shard_stats",property="total"}`
300
322
* Garbage Collector rates: `sum(rate(jvm_gc_collection_seconds_count[5m])) by (gc)`
301
-
* Thread pool queue size: `crate_threadpools{property="queueSize"}`
302
323
* Thread pool rejected operations: `crate_threadpools{property="rejected"}`
303
324
* Operating system metrics
304
325
* CPU utilization
@@ -311,3 +332,8 @@ If you decide to build your own dashboard or use an entirely different monitorin
311
332
## Wrapping up
312
333
313
334
We got a Grafana dashboard that allows us to check live and historical data around performance and capacity metrics in our CrateDB cluster, this illustrates one possible setup. You could use different tools depending on your environment and preferences. Still, we recommend you use the interface of the Crate JMX HTTP Exporter to collect CrateDB-specific metrics and that you always also monitor the health of the environment at the OS level as we have done here with the Prometheus Node Exporter.
0 commit comments