An open API service indexing awesome lists of open source software.

https://github.com/odis-labs/refana

Define Grafana dashboards with ReasonML
https://github.com/odis-labs/refana

Last synced: 8 months ago
JSON representation

Define Grafana dashboards with ReasonML

Awesome Lists containing this project

README

          

# Refana

Define Grafana dashboards with ReasonML.

- [Homepage](https://odis-labs.github.io/refana/refana)
- [API reference](https://odis-labs.github.io/refana/refana/Refana)

## Usage

### Defining metrics

```reason
let cpu = (~name) =>
Grafana.(Query.prometheus(Prometheus_query {
"id": "CPU",
"expr": fmt("rate(cpu_seconds{container_name=~'%s'}[30s])", name),
"format": "time_series",
"legend": "cpu_seconds@{{pod_name}}"
}));

let mem = (~name) =>
Grafana.(Query.prometheus(Prometheus_query {
"id": "MEM",
"expr": fmt("sum(memory_rss{container_name=~'%s'}) by (pod_name)", name),
"format": "time_series",
"legend": "memory_rss@{{pod_name}}"
}));
```

### Creating panels

```reason
let name = "my-app";

let metrics = Grafana.[
Panel.row(Row {
"title": "My metrics",
"position": size(~width=24, ~height=1),
}),

Panel.graph(Graph {
"title": "Container CPU usage",
"position": size(~width=12, ~height=9),
"queries": [cpu(~name)]
}),
Panel.graph(Graph {
"title": "Container memory usage",
"position": size(~width=12, ~height=9),
"queries": [Std.Grafana.Metrics.mem(~name)]
})
];
```

### Creating dashboards

```reason
let dash = Grafana.Dashboard {
"title": "My Monitoring Dashboard",
"panels": Grafana.panels([metrics])
}
```