Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created November 14, 2023 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoelzro/bdff74120c43828a21645267d3577ebe to your computer and use it in GitHub Desktop.
Save hoelzro/bdff74120c43828a21645267d3577ebe to your computer and use it in GitHub Desktop.
apiVersion: 1
providers:
- name: example-provider
options:
path: /etc/dashboards
foldersFromFilesStructure: true
GF_SECURITY_ADMIN_USER=admin
GF_SECURITY_ADMIN_PASSWORD=admin
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "grafana",
"uid": "grafana"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"queryType": "randomWalk",
"refId": "A"
}
],
"title": "Panel Title",
"type": "timeseries"
}
],
"refresh": "",
"schemaVersion": 38,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "New dashboard",
"version": 0,
"weekStart": ""
}
#!/bin/zsh
set -e -u
REV=$(git rev-parse HEAD)
buildah build -t grafana-git-$REV .
trap "podman stop grafana-bisect-$REV" EXIT
podman run --detach --name grafana-bisect-$REV --rm --env-file=env-file -p 3000:3000 --mount type=bind,source=dash.yaml,destination=/etc/grafana/provisioning/dashboards/dash.yaml --mount type=bind,source=random.json,destination=/etc/dashboards/example-folder/random.json grafana-git-$REV
ready=''
# wait for container to become ready
sleep 2
for i in {1..60..5}; do
dashboard_count=$(curl -s -u admin:admin http://localhost:3000/api/search | jq length)
if [[ $dashboard_count -eq 2 ]] ; then
ready=1
break
fi
sleep 5
done
if [[ -z "$ready" ]] ; then
echo "container never became ready" >&2
exit 1
fi
curl -s -Lo /dev/null -f -u admin:admin -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"email":"xavier@example.com","login":"example","name":"Xavier Ample","password":"p4ss"}' http://localhost:3000/api/admin/users
sleep 1
dashboard_count=$(curl -s -f -u example:p4ss http://localhost:3000/api/search | jq length)
if [[ $dashboard_count -eq 2 ]] ; then
exit 0
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment