package tezt-tezos

  1. Overview
  2. Docs

Create Grafana dashboards.

type config = {
  1. url : Uri.t;
  2. api_token : string option;
  3. data_source : string;
  4. timeout : float;
}

Grafana configuration.

url is the base URL of the Grafana API.

api_token is the bearer token to use in the Authorization header. If not provided, it will try to connect without authenticating (insecure mode).

data_source is the name of the InfluxDB data source configured in Grafana.

val config_of_json : Tezt.JSON.t -> config

Read a Grafana configuration from a JSON value.

type yaxis = {
  1. format : string;
  2. label : string option;
}

Y axes for Grafana panels.

format is the unit of the axis. A typical example is "s", meaning "seconds". See Grafana documentation for other possible values.

type duration =
  1. | Seconds of int
  2. | Minutes of int
  3. | Hours of int
  4. | Days of int
  5. | Weeks of int
  6. | Month of int
  7. | Years of int

Represent a duration, used to express intervals for example.

type alias = string

The alias associated to a curve in the graph.

type graph = {
  1. title : string;
  2. description : string;
  3. queries : (InfluxDB.select * alias option) list;
  4. interval : duration option;
  5. yaxis_1 : yaxis option;
  6. yaxis_2 : yaxis option;
}

Grafana graph panels.

Queries should use Grafana_time_filter in their WHERE clause and Grafana_interval in a GROUP BY time clause to reduce the size of the query. If an interval is specified, it will represent the minimum accepted by Grafana_interval to draw the graph.

The GROUP BY time clause should usually also contain a FILL clause to make continuous graphs instead of bunches of dots.

Each query is optionally associated to an alias. This alias will be used to name the resulting curve in the graph key. If this alias is not given, Grafana will deduce it automatically from the query.

Example query: InfluxDB.select [Function (MEAN, Field "duration")] ~from:(Measurement "rpc") ~where:Grafana_time_filter ~group_by:(Time {interval = Grafana_interval; tag = None; fill = None})

type panel =
  1. | Row of string
  2. | Graph of graph

Grafana panels.

Rows are horizontal separators between graphs, with a title.

type dashboard = {
  1. uid : string;
  2. title : string;
  3. description : string;
  4. panels : panel list;
}

Grafana dashboards.

uid is a unique identifier of your choosing. It will be used in the URL of the dashboard. It must be composed of between 1 and 128 alphanumeric characters, dashes, periods or underscores.

val update_dashboard : config -> dashboard -> unit Lwt.t

Create or update a dashboard.

If the dashboard already exists, it is deleted first. All version history is lost.

  • raises Invalid_arg

    if the dashboard UID is invalid.

val simple_query : ?tags:(InfluxDB.tag * string) list -> measurement:InfluxDB.measurement -> field:InfluxDB.field -> test:string -> unit -> InfluxDB.select

Make a simple SELECT query for a graph panel.

Usage: simple_query ~tags:[("tag1", "value1"), ("tag2", "value2")] ~measurement ~field ~test:test_title ()

Default tags is an empty list.

This returns the following query: SELECT MEAN(field) FROM measurement WHERE $timeFilter AND test = test_title AND tag1 = value1 AND tag2 = value2 GROUP BY time($__interval) fill(previous)

val simple_graph : ?title:string -> ?description:string -> ?yaxis_format:string -> ?tags:(InfluxDB.tag * string) list -> ?interval:duration -> measurement:InfluxDB.measurement -> field:InfluxDB.field -> test:string -> unit -> panel

Make a graph panel from a simple query.

Usage: simple_graph ~measurement ~field ~test ()

The query is built using simple_query.

Default title is the measurement name. Default description is "". Default yaxis_format is s (seconds). Default tags is an empty list.

val graphs_per_tags : ?title:string -> ?description:string -> ?yaxis_format:string -> ?interval:duration -> measurement:InfluxDB.measurement -> field:InfluxDB.field -> test:string -> tags:(InfluxDB.tag * string) list -> unit -> panel

Make a graph panel that draws a curve per given tag.

Usage: graphs_per_tags ~measurement ~field ~test:test_title ~tags:[(tag1, value1); (tag2, value2)] ()

This will draw a curve in the resulting graph for each one of the following request:

SELECT MEAN(field) FROM measurement WHERE $timeFilter AND test = test_title AND tag1 = value1 GROUP BY time($__interval) fill(previous)

SELECT MEAN(field) FROM measurement WHERE $timeFilter AND test = test_name AND tag2 = value2 GROUP BY time($__interval) fill(previous)

Default title is the measurement name. Default description is "". Default yaxis_format is s (seconds). Default tags is an empty list.

OCaml

Innovation. Community. Security.