Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start work on mixin dashboards #885

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ elasticsearch_exporter
*-stamp
.tarballs
/vendor
vendor/
20 changes: 20 additions & 0 deletions elasticsearch_mixin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Elasticsearch Exporter Mixin

This is a mixin for the elasticsearch_exporter to define dashboards, alerts, and monitoring queries for use with this exporter.

Good example of upstream mixin for reference: https://github.com/kubernetes-monitoring/kubernetes-mixin


## Development

### JSONNET
```go install github.com/google/go-jsonnet/cmd/jsonnet@latest```

### JSONNET BUNDLER
jsonnet bundler is a package manager for jsonnet

```go install -a github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest```


### Grafonnet
```jb install github.com/grafana/grafonnet/gen/grafonnet-latest@main```
6 changes: 6 additions & 0 deletions elasticsearch_mixin/config.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
_config+:: {
dashboardNamePrefix: 'Elasticsearch Exporter / ',
dashboardTags: ['elasticsearch-exporter-mixin'],
},
}
3 changes: 3 additions & 0 deletions elasticsearch_mixin/dashboards.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
local dashboards = (import 'mixin.libsonnet').grafanaDashboards;

{ [name]: dashboards[name] for name in std.objectFields(dashboards)}
20 changes: 20 additions & 0 deletions elasticsearch_mixin/dashboards/cluster.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local g = import 'g.libsonnet';

local dashboard = g.dashboard;

local variables = import './variables.libsonnet';

{
grafanaDashboards+:: {
'cluster.json':
dashboard.new('%s Cluster' % $._config.dashboardNamePrefix)
+ dashboard.withTags($._config.dashboardTags)
+ dashboard.withRefresh('1m')
+ dashboard.time.withFrom(value='now-1h')
+ dashboard.graphTooltip.withSharedCrosshair()
+ dashboard.withVariables([
variables.datasource,
variables.cluster,
])
}
}
1 change: 1 addition & 0 deletions elasticsearch_mixin/dashboards/dashboards.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(import 'cluster.libsonnet')
1 change: 1 addition & 0 deletions elasticsearch_mixin/dashboards/g.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet"
15 changes: 15 additions & 0 deletions elasticsearch_mixin/dashboards/variables.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local g = import './g.libsonnet';
local var = g.dashboard.variable;

{
datasource:
var.datasource.new('datasource', 'prometheus'),

cluster:
var.query.new('cluster')
+ var.query.withDatasourceFromVariable(self.datasource)
+ var.query.queryTypes.withLabelValues(
'cluster',
'elasticsearch_cluster_health_status',
)
}
15 changes: 15 additions & 0 deletions elasticsearch_mixin/jsonnetfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1,
"dependencies": [
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet.git",
"subdir": "gen/grafonnet-latest"
}
},
"version": "main"
}
],
"legacyImports": true
}
46 changes: 46 additions & 0 deletions elasticsearch_mixin/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"version": 1,
"dependencies": [
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet.git",
"subdir": "gen/grafonnet-latest"
}
},
"version": "1c56af39815c4903e47c27194444456f005f65df",
"sum": "GxEO83uxgsDclLp/fmlUJZDbSGpeUZY6Ap3G2cgdL1g="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet.git",
"subdir": "gen/grafonnet-v10.4.0"
}
},
"version": "1c56af39815c4903e47c27194444456f005f65df",
"sum": "DKj+Sn+rlI48g/aoJpzkfPge46ya0jLk5kcZoiZ2X/I="
},
{
"source": {
"git": {
"remote": "https://github.com/jsonnet-libs/docsonnet.git",
"subdir": "doc-util"
}
},
"version": "6ac6c69685b8c29c54515448eaca583da2d88150",
"sum": "BrAL/k23jq+xy9oA7TWIhUx07dsA/QLm3g7ktCwe//U="
},
{
"source": {
"git": {
"remote": "https://github.com/jsonnet-libs/xtd.git",
"subdir": ""
}
},
"version": "63d430b69a95741061c2f7fc9d84b1a778511d9c",
"sum": "qiZi3axUSXCVzKUF83zSAxklwrnitMmrDK4XAfjPMdE="
}
],
"legacyImports": false
}
3 changes: 3 additions & 0 deletions elasticsearch_mixin/mixin.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// (import 'alerts/alerts.libsonnet') +
(import 'dashboards/dashboards.libsonnet') +
(import 'config.libsonnet')