ceph/monitoring/ceph-mixin/test-jsonnet.sh
Arthur Outhenin-Chalandre 98236e3a1d
mgr/dashboard: monitoring: refactor into ceph-mixin
Mixin is a way to bundle dashboards, prometheus rules and alerts into
jsonnet package. Shifting to mixin will allow easier integration with
monitoring automation that some users may use.

This commit moves `/monitoring/grafana/dashboards` and
`/monitoring/prometheus` to `/monitoring/ceph-mixin`. Prometheus alerts
was also converted to Jsonnet using an automated way (from yaml to json
to jsonnet). This commit minimises any change made to the generated files
and should not change neithers the dashboards nor the Prometheus alerts.

In the future some configuration will also be added to jsonnet to add
more functionalities to the dashboards or alerts (i.e.: multi cluster).

Fixes: https://tracker.ceph.com/issues/53374
Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
2022-02-03 13:08:20 +01:00

32 lines
824 B
Bash
Executable File

#!/bin/sh -e
TEMPDIR=$(mktemp -d)
BASEDIR=$(dirname "$0")
jsonnet -J vendor -m ${TEMPDIR} $BASEDIR/dashboards.jsonnet
truncate -s 0 ${TEMPDIR}/json_difference.log
for file in ${BASEDIR}/dashboards_out/*.json
do
file_name="$(basename $file)"
for generated_file in ${TEMPDIR}/*.json
do
generated_file_name="$(basename $generated_file)"
if [ "$file_name" == "$generated_file_name" ]; then
jsondiff --indent 2 "${generated_file}" "${file}" \
| tee -a ${TEMPDIR}/json_difference.log
fi
done
done
err=0
if [ $(wc -l < ${TEMPDIR}/json_difference.log) -eq 0 ]
then
rm -rf ${TEMPDIR}
echo "Congratulations! Grafonnet Check Passed"
else
rm -rf ${TEMPDIR}
echo "Grafonnet Check Failed, failed comparing generated file with existing"
exit 1
fi