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

Add opensearch mixin #51

Draft
wants to merge 5 commits into
base: main
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.
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
@@ -0,0 +1 @@
.src/vendor
27 changes: 27 additions & 0 deletions .src/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From python:3.12-slim-bookworm

ARG JB_VERSION=v0.6.0

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
ca-certificates \
curl \
git \
jsonnet \
&& curl --location --output /usr/local/bin/jb https://github.com/jsonnet-bundler/jsonnet-bundler/releases/download/${JB_VERSION}/jb-linux-amd64 \
&& chmod +x /usr/local/bin/jb \
&& apt-get remove -y \
curl \
&& apt-get clean \
&& apt-get autoremove -y \
&& rm -rf \
/var/lib/apt/lists/* \
/var/tmp/*

COPY files/mixins.py /mixins.py

WORKDIR /srv/.src
CMD ["/mixins.py"]

1 change: 1 addition & 0 deletions .src/Dockerfile
69 changes: 69 additions & 0 deletions .src/files/mixins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/local/bin/python3

import os
import subprocess

dashboards_out_prefix = "../grafana/dashboards"
rules_out_prefix = "../prometheus"

print("Installing dependencies...")
try:
out = subprocess.run(["/usr/local/bin/jb", "install"], capture_output=True)
except subprocess.SubprocessError as e:
print(e.stderr)
raise e
print(out.stdout.decode())
print(out.stderr.decode())

for path, _, filenames in os.walk("mixins"):
for file in filenames:
dashboards_out = os.path.join(
dashboards_out_prefix, *os.path.normpath(path).split(os.sep)[1:]
)
if file.endswith(".libsonnet"):
name = file.removesuffix(".libsonnet")
print("Processing mixin " + name)
print("Creating dashboard(s)...")
os.makedirs(dashboards_out, exist_ok=True)
try:
subprocess.run(
[
"jsonnet",
"-J",
"vendor",
"-m",
dashboards_out,
"-e",
'(import "' + os.path.join(path, file) + '").grafanaDashboards',
]
)
except subprocess.SubprocessError as e:
print(e.stderr)
raise e
for kind, suffix in [
("prometheusAlerts", ".rules"),
("prometheusRules", ".rec.rules"),
]:
print("Creating " + kind + "...")
prometheus_out = os.path.join(rules_out_prefix, name + suffix)
with open(prometheus_out, "w") as f:
try:
subprocess.run(
[
"jsonnet",
"-J",
"vendor",
"-S",
"-e",
'std.manifestYamlDoc((import "'
+ os.path.join(path, file)
+ '").'
+ kind
+ ")",
],
stdout=f,
)
except subprocess.SubprocessError as e:
print(e.stderr)
raise e
print(prometheus_out)
51 changes: 51 additions & 0 deletions .src/jsonnetfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"version": 1,
"dependencies": [
{
"source": {
"git": {
"remote": "https://github.com/prometheus/alertmanager.git",
"subdir": "doc/alertmanager-mixin"
}
},
"version": "main"
},
{
"source": {
"git": {
"remote": "https://github.com/ceph/ceph.git",
"subdir": "monitoring/ceph-mixin"
}
},
"version": "main"
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "opensearch-mixin"
}
},
"version": "master"
},
{
"source": {
"git": {
"remote": "https://github.com/prometheus/node_exporter.git",
"subdir": "docs/node-mixin"
}
},
"version": "master"
},
{
"source": {
"git": {
"remote": "https://github.com/prometheus/prometheus.git",
"subdir": "documentation/prometheus-mixin"
}
},
"version": "main"
}
],
"legacyImports": true
}
166 changes: 166 additions & 0 deletions .src/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"version": 1,
"dependencies": [
{
"source": {
"git": {
"remote": "https://github.com/ceph/ceph.git",
"subdir": "monitoring/ceph-mixin"
}
},
"version": "54a75a0e407aaa5c4fff987e7ad91001bfa79fbf",
"sum": "ZnyCIu25NBI6Q3Ru7QK1DHf7DBMEURSMQdEJXzCyIgA="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet-lib.git",
"subdir": "grafonnet"
}
},
"version": "a1d61cce1da59c71409b99b5c7568511fec661ea",
"sum": "342u++/7rViR/zj2jeJOjshzglkZ1SY+hFNuyCBFMdc="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet-lib.git",
"subdir": "grafonnet-7.0"
}
},
"version": "a1d61cce1da59c71409b99b5c7568511fec661ea",
"sum": "gCtR9s/4D5fxU9aKXg0Bru+/njZhA0YjLjPiASc61FM="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet.git",
"subdir": "gen/grafonnet-latest"
}
},
"version": "82a19822e54a0a12a51e24dbd48fcde717dc0864",
"sum": "64fMUPI3frXGj4X1FqFd1t7r04w3CUSmXaDcJ23EYbQ="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet.git",
"subdir": "gen/grafonnet-v10.0.0"
}
},
"version": "82a19822e54a0a12a51e24dbd48fcde717dc0864",
"sum": "xdcrJPJlpkq4+5LpGwN4tPAuheNNLXZjE6tDcyvFjr0="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet.git",
"subdir": "gen/grafonnet-v11.0.0"
}
},
"version": "82a19822e54a0a12a51e24dbd48fcde717dc0864",
"sum": "0BvzR0i4bS4hc2O3xDv6i9m52z7mPrjvqxtcPrGhynA="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/grafonnet.git",
"subdir": "gen/grafonnet-v11.1.0"
}
},
"version": "82a19822e54a0a12a51e24dbd48fcde717dc0864",
"sum": "41w7p/rwrNsITqNHMXtGSJAfAyKmnflg6rFhKBduUxM="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "common-lib"
}
},
"version": "a8fc2139d881ae632a8c956eb9dd4b84b24f362e",
"sum": "c2Omoqo8FTwR/V3VC+hRN5CEyI0UDD1OyYXnEqwiKLY="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "grafana-builder"
}
},
"version": "a8fc2139d881ae632a8c956eb9dd4b84b24f362e",
"sum": "yxqWcq/N3E/a/XreeU6EuE6X7kYPnG0AspAQFKOjASo="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/jsonnet-libs.git",
"subdir": "opensearch-mixin"
}
},
"version": "a8fc2139d881ae632a8c956eb9dd4b84b24f362e",
"sum": "AK83KBy5roMxhT0taG54ERV20oG9mhaCJA+EHRzuPO4="
},
{
"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="
},
{
"source": {
"git": {
"remote": "https://github.com/prometheus/alertmanager.git",
"subdir": "doc/alertmanager-mixin"
}
},
"version": "f6b942cf9b3a503d59192eada300d2ad97cba82f",
"sum": "Mf4h1BYLle2nrgjf/HXrBbl0Zk8N+xaoEM017o0BC+k="
},
{
"source": {
"git": {
"remote": "https://github.com/prometheus/node_exporter.git",
"subdir": "docs/node-mixin"
}
},
"version": "0fddfd1ba530c954dc042c5d138de82ecd4e4ff1",
"sum": "cQCW+1N0Xae5yXecCWDK2oAlN0luBS/5GrwBYSlaFms="
},
{
"source": {
"git": {
"remote": "https://github.com/prometheus/prometheus.git",
"subdir": "documentation/prometheus-mixin"
}
},
"version": "d3074b39c38493ebb81514c0ec962b7853ed0162",
"sum": "dYLcLzGH4yF3qB7OGC/7z4nqeTNjv42L7Q3BENU8XJI="
},
{
"source": {
"git": {
"remote": "https://github.com/yugui/jsonnetunit.git",
"subdir": "jsonnetunit"
}
},
"version": "6927c58cae7624a00f368b977ccc477d4f74071f",
"sum": "9FFqqln65hooRF0l6rjICDtnTxUlmDj34+sKMh4sjPI="
}
],
"legacyImports": false
}
7 changes: 7 additions & 0 deletions .src/mixins/ceph/ceph.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local ceph = import "ceph-mixin/mixin.libsonnet";

ceph {
prometheusRules+: {},
prometheusAlerts+: {},
grafanaDashboards+: {}
}
7 changes: 7 additions & 0 deletions .src/mixins/infrastructure/alertmanager.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local alertmanager = import "alertmanager-mixin/mixin.libsonnet";

alertmanager {
prometheusRules+: {},
prometheusAlerts+: {},
grafanaDashboards+: {}
}
11 changes: 11 additions & 0 deletions .src/mixins/infrastructure/node.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
local node = import "node-mixin/mixin.libsonnet";

node {
prometheusRules+: {},
prometheusAlerts+: {},
grafanaDashboards+: {
# Hide unused dashboards
'nodes-darwin.json':: super['nodes-darwin.json'],
'nodes-aix.json':: super['nodes-aix.json']
}
}
10 changes: 10 additions & 0 deletions .src/mixins/infrastructure/opensearch.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local opensearch = import "opensearch-mixin/mixin.libsonnet";

opensearch {
_config+:: {
enableLokiLogs: false,
},
prometheusRules+: {},
prometheusAlerts+: {},
grafanaDashboards+: {}
}
7 changes: 7 additions & 0 deletions .src/mixins/infrastructure/prometheus.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local prometheus = import "prometheus-mixin/mixin.libsonnet";

prometheus {
prometheusRules+: {},
prometheusAlerts+: {},
grafanaDashboards+: {}
}
Loading
Loading