Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ node_modules
*_test_output.json
doc/locale/en/
doc/output/
dashboard.json
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## Added
- Options to build static dashboards

## Changed
- Set default Prometheus job to `tarantool`
- Set default InfluxDB measurement to `tarantool_http`
- Use in-built `$__rate_interval` instead of user-defined `$rate_time_range`


## [1.3.0] - 2022-06-29
Grafana revisions: [InfluxDB revision 13](https://grafana.com/api/dashboards/12567/revisions/13/download), [Prometheus revision 13](https://grafana.com/api/dashboards/13054/revisions/13/download), [InfluxDB TDG revision 2](https://grafana.com/api/dashboards/16405/revisions/2/download), [Prometheus TDG revision 2](https://grafana.com/api/dashboards/16406/revisions/2/download).

## Added
- Panels for expirationd module statistics


## [1.2.1] - 2022-06-24
Grafana revisions: [InfluxDB revision 12](https://grafana.com/api/dashboards/12567/revisions/12/download), [Prometheus revision 12](https://grafana.com/api/dashboards/13054/revisions/12/download), [InfluxDB TDG revision 2](https://grafana.com/api/dashboards/16405/revisions/2/download), [Prometheus TDG revision 2](https://grafana.com/api/dashboards/16406/revisions/2/download).

Expand Down
52 changes: 51 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,67 @@
.PHONY: build-deps test-deps run-tests update-tests
JOB ?= tarantool
POLICY ?= autogen
MEASUREMENT ?= tarantool_http
OUTPUT_STATIC_DASHBOARD ?= dashboard.json

.PHONY: build-deps
build-deps:
go get github.com/google/go-jsonnet/cmd/jsonnet
go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
jb install


_build-static-prometheus:
ifndef DATASOURCE
@echo 1>&2 "DATASOURCE must be set"
false
endif
# JOB is optional, default is "tarantool"
jsonnet -J ./vendor -J . \
--ext-str DATASOURCE=${DATASOURCE} \
--ext-str JOB=${JOB} \
dashboard/build/prometheus/${DASHBOARD_BUILD_SOURCE} -o ${OUTPUT_STATIC_DASHBOARD}

.PHONY: build-static-prometheus
build-static-prometheus:
make DASHBOARD_BUILD_SOURCE=dashboard_static.jsonnet _build-static-prometheus

.PHONY: build-static-tdg-prometheus
build-static-tdg-prometheus:
make DASHBOARD_BUILD_SOURCE=tdg_dashboard_static.jsonnet _build-static-prometheus


_build-static-influxdb:
ifndef DATASOURCE
@echo 1>&2 "DATASOURCE must be set"
false
endif
# POLICY is optional, default is "autogen"
# MEASUREMENT is optional, default is "tarantool_http"
jsonnet -J ./vendor -J . \
--ext-str DATASOURCE=${DATASOURCE} \
--ext-str POLICY=${POLICY} \
--ext-str MEASUREMENT=${MEASUREMENT} \
dashboard/build/influxdb/${DASHBOARD_BUILD_SOURCE} -o ${OUTPUT_STATIC_DASHBOARD}

.PHONY: build-static-influxdb
build-static-influxdb:
make DASHBOARD_BUILD_SOURCE=dashboard_static.jsonnet _build-static-influxdb

.PHONY: build-static-tdg-influxdb
build-static-tdg-influxdb:
make DASHBOARD_BUILD_SOURCE=tdg_dashboard_static.jsonnet _build-static-influxdb


.PHONY: test-deps
test-deps: build-deps
go get github.com/google/go-jsonnet/cmd/jsonnetfmt
GO111MODULE=on go get github.com/prometheus/prometheus/cmd/promtool@fcfc0e8888749cbf67aa9aac14c5d78e4c23d0a5

.PHONY: run-tests
run-tests:
./tests.sh
promtool test rules example_cluster/prometheus/test_alerts.yml

.PHONY: update-tests
update-tests:
./tests.sh update
94 changes: 56 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ Refer to dashboard [documentation page](https://www.tarantool.io/en/doc/latest/b

You need to set the following variables for Prometheus datasource:

- `Job`,
- `Rate time range` (default valie is `2m`).
- `Job`.

Datasource variables can be obtained from your datasource configuration.
Variables for example monitoring cluster are described in [Monitoring cluster](#monitoring-cluster) section.
Expand All @@ -76,13 +75,12 @@ You can also interact with Prometheus at [localhost:9090](http://localhost:9090/

To set up an InfluxDB dashboard for monitoring example app, use the following variables:

- `Measurement`: `tarantool_app_http`;
- `Measurement`: `tarantool_http`;
- `Policy`: `default`.

To set up an Prometheus dashboard for monitoring example app, use the following variables:

- `Job`: `tarantool_app`;
- `Rate time range`: `2m`.
- `Job`: `tarantool`.

### Monitoring local app

Expand Down Expand Up @@ -114,22 +112,45 @@ make test-deps
```
to install build dependencies and dependencies that are required to run tests locally.

You can compile Prometheus dashboard template with
To build a static dashboard with no input and dynamic variables, run `make` commands.
```bash
jsonnet -J ./vendor/ -e "local dashboard = import 'dashboard/prometheus_dashboard.libsonnet'; dashboard.build()"
make DATASOURCE=Prometheus JOB=tarantool \
OUTPUT_STATIC_DASHBOARD=mydashboard.json build-static-prometheus
```
Following targets are available:
- `build-static-prometheus`: Tarantool dashboard for a Prometheus datasource;
- `build-static-tdg-prometheus`: TDG dashboard for a Prometheus datasource;
- `build-static-influxdb`: Tarantool dashboard for an InfluxDB datasource;
- `build-static-tdg-influxdb`: TDG dashboard for an InfluxDB datasource.

Variables for Prometheus targets:
- `DATASOURCE`: name of a Prometheus data source;
- `JOB` (optional, default `tarantool`): name of a Prometheus job collecting your application metrics;
- `OUTPUT_STATIC_DASHBOARD` (optional, default `dashboard.json`): compiled dashboard file.

Variables for InfluxDB targets:
- `DATASOURCE`: name of a InfluxDB data source;
- `POLICY` (optional, default `autogen`): InfluxDB metrics retention policy;
- `MEASUREMENT` (optional, default `tarantool_http`): name of a InfluxDB measurement with your application metrics;
- `OUTPUT_STATIC_DASHBOARD` (optional, default `dashboard.json`): compiled dashboard file.

You can also compile configurable Prometheus dashboard template (the same we publish to
Grafana Official & community built dashboards) with
```bash
jsonnet -J ./vendor/ -e "local dashboard = import 'dashboard/build/prometheus/dashboard.libsonnet'; dashboard.build()"
```
and InfluxDB dashboard template with
```bash
jsonnet -J ./vendor/ -e "local dashboard = import 'dashboard/influxdb_dashboard.libsonnet'; dashboard.build()"
jsonnet -J ./vendor/ -e "local dashboard = import 'dashboard/build/influxdb/dashboard.libsonnet'; dashboard.build()"
```

To save output into `output.json` file, use
```bash
jsonnet -J ./vendor/ -e "local dashboard = import 'dashboard/prometheus_dashboard.libsonnet'; dashboard.build()" -o ./output.json
jsonnet -J ./vendor/ -e "local dashboard = import 'dashboard/build/prometheus/dashboard.libsonnet'; dashboard.build()" -o ./output.json
```
and to save output into clipboard, use
```bash
jsonnet -J ./vendor/ -e "local dashboard = import 'dashboard/prometheus_dashboard.libsonnet'; dashboard.build()" | xclip -selection clipboard
jsonnet -J ./vendor/ -e "local dashboard = import 'dashboard/build/prometheus/dashboard.libsonnet'; dashboard.build()" | xclip -selection clipboard
```

You can run tests with
Expand Down Expand Up @@ -186,8 +207,8 @@ You can add your own custom panels to the bottom of the template dashboard.
Import one of them in your jsonnet script to build your own custom dashboard.
```jsonnet
# my_dashboard.jsonnet
local prometheus_dashboard = import 'grafana-dashboard/dashboard/prometheus_dashboard.libsonnet';
local influxdb_dashboard = import 'grafana-dashboard/dashboard/influxdb_dashboard.libsonnet';
local prometheus_dashboard = import 'grafana-dashboard/dashboard/build/prometheus/dashboard.libsonnet';
local influxdb_dashboard = import 'grafana-dashboard/dashboard/build/influxdb/dashboard.libsonnet';
```

3. To add your custom panels to a dashboard template, you must create panel objects.
Expand All @@ -208,7 +229,7 @@ You can add your own custom panels to the bottom of the template dashboard.
default_graph( # graph panel shortcut
title, # The title of the graph panel
description, # (optional) The description of the panel
datasource, # Targets datasource. Use dashboard/variable.libsonnet to fill this value
datasource, # Targets datasource. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
format, # (default 'none') Unit of the Y axes
min, # (optional) Min of the Y axes
max, # (optional) Max of the Y axes
Expand Down Expand Up @@ -241,21 +262,20 @@ You can add your own custom panels to the bottom of the template dashboard.
# vendor/grafana-dashboard/dashboard/panels/common.libsonnet

default_metric_target( # plain "select metric" shortcut
datasource, # Target datasource. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
datasource_type, # Target datasource type. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
metric_name, # Target metric name to select
job, # (Prometheus only) Prometheus metrics job. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
policy, # (InfluxDB only) InfluxDB metrics policy. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
measurement, # (InfluxDB only) InfluxDB metrics measurement. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
job, # (Prometheus only) Prometheus metrics job. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
policy, # (InfluxDB only) InfluxDB metrics policy. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
measurement, # (InfluxDB only) InfluxDB metrics measurement. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
converter, # (InfluxDB only, default 'mean') InfluxDB metrics converter (aggregation, selector, etc.)
),

default_rps_target( # counter metric transformed to rps shortcut
datasource, # Target datasource. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
datasource_type, # Target datasource type. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
metric_name, # Target metric name to select
job, # (Prometheus only) Prometheus metrics job. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
rate_time_range, # (Prometheus only) Prometheus rps computation rate time range. Use vendor/grafana-dashboard/dashboard/variable.libsonnet to fill this value
policy, # (InfluxDB only) InfluxDB metrics policy. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
measurement, # (InfluxDB only) InfluxDB metrics measurement. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
job, # (Prometheus only) Prometheus metrics job. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
policy, # (InfluxDB only) InfluxDB metrics policy. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
measurement, # (InfluxDB only) InfluxDB metrics measurement. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
)
```

Expand All @@ -264,17 +284,16 @@ You can add your own custom panels to the bottom of the template dashboard.
To use dashboard-wide input and template variables in your queries you must use `grafana-dashboard/dashboard/variable.libsonnet`.
It imports json object with variable values you neet to set in your queries.

If you want to build a Prometheus dashboard, use
If you want to build a Prometheus dashboard with default input variables, use
```jsonnet
datasource=variable.datasource.prometheus,
job=variable.prometheus.job,
rate_time_range=variable.prometheus.rate_time_range
datasource=variable.datasource_var.prometheus,
job=variable.prometheus.job
```
in your targets.

If you want to build an InfluxDB dashboard, use
If you want to build an InfluxDB dashboard with default input variables, use
```jsonnet
datasource=variable.datasource.influxdb,
datasource=variable.datasource_var.influxdb,
policy=variable.influxdb.policy,
measurement=variable.influxdb.measurement
```
Expand All @@ -293,12 +312,12 @@ You can add your own custom panels to the bottom of the template dashboard.
My custom component used memory.
Shows mean value.
|||,
datasource=variable.datasource.prometheus,
datasource=variable.datasource_var.prometheus,
format='bytes',
panel_width=12,
panel_height=6,
).addTarget(common.default_metric_target(
datasource=variable.datasource.prometheus,
datasource_type=variable.datasource_type.prometheus,
metric_name='my_component_memory',
job=variable.prometheus.job,
))
Expand All @@ -315,15 +334,14 @@ You can add your own custom panels to the bottom of the template dashboard.
and collects info on process to summary collector
'my_component_load_metric'.
|||,
datasource=variable.datasource.prometheus,
datasource=variable.datasource_var.prometheus,
labelY1='requests per second',
panel_width=18,
panel_height=6,
).addTarget(common.default_rps_target(
datasource=variable.datasource.prometheus,
datasource_type=variable.datasource_type.prometheus,
metric_name='my_component_load_metric_count',
job=variable.prometheus.job,
rate_time_range=variable.prometheus.rate_time_range,
))
```
Corresponding InfluxDB panels could be built with
Expand All @@ -337,12 +355,12 @@ You can add your own custom panels to the bottom of the template dashboard.
My custom component used memory.
Shows mean value.
|||,
datasource=variable.datasource.influxdb,
datasource=variable.datasource_var.influxdb,
format='bytes',
panel_width=12,
panel_height=6,
).addTarget(common.default_metric_target(
datasource=variable.datasource.influxdb,
datasource_type=variable.datasource_type.influxdb,
metric_name='my_component_memory',
policy=variable.influxdb.policy,
measurement=variable.influxdb.measurement,
Expand All @@ -355,12 +373,12 @@ You can add your own custom panels to the bottom of the template dashboard.
and collects info on process to summary collector
'my_component_load_metric'.
|||,
datasource=variable.datasource.influxdb,
datasource=variable.datasource_var.influxdb,
labelY1='requests per second',
panel_width=18,
panel_height=6,
).addTarget(common.default_rps_target(
datasource=variable.datasource.influxdb,
datasource_type=variable.datasource_type.influxdb,
metric_name='my_component_load_metric_count',
policy=variable.influxdb.policy,
measurement=variable.influxdb.measurement,
Expand All @@ -371,7 +389,7 @@ You can add your own custom panels to the bottom of the template dashboard.
To add your custom panels, call `addPanel(panel)` or `addPanels(panel_array)` in dashboard template:
```jsonnet
# my_dashboard.jsonnet
local prometheus_dashboard = import 'grafana-dashboard/dashboard/prometheus_dashboard.libsonnet';
local prometheus_dashboard = import 'grafana-dashboard/dashboard/build/prometheus/dashboard.libsonnet';

...

Expand Down
29 changes: 29 additions & 0 deletions dashboard/build/influxdb/dashboard.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local grafana = import 'grafonnet/grafana.libsonnet';

local dashboard_raw = import 'dashboard/build/influxdb/dashboard_raw.libsonnet';
local variable = import 'dashboard/variable.libsonnet';

dashboard_raw(
datasource=variable.datasource_var.influxdb,
policy=variable.influxdb.policy,
measurement=variable.influxdb.measurement
).addInput(
name='DS_INFLUXDB',
label='InfluxDB bank',
type='datasource',
pluginId='influxdb',
pluginName='InfluxDB',
description='InfluxDB Tarantool metrics bank'
).addInput(
name='INFLUXDB_MEASUREMENT',
label='Measurement',
type='constant',
value='tarantool_http',
description='InfluxDB Tarantool metrics measurement'
).addInput(
name='INFLUXDB_POLICY',
label='Policy',
type='constant',
value='autogen',
description='InfluxDB Tarantool metrics policy'
)
Loading