Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 4a43261

Browse files
committed
Add import scripts for kibana dashboards
1 parent 7033338 commit 4a43261

File tree

6 files changed

+364
-0
lines changed

6 files changed

+364
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ jobs:
152152
repository: scbexperimental/persistence-elastic
153153
path: ./persistence/persistence-elastic/
154154
tag_with_ref: true
155+
- uses: docker/build-push-action@v1
156+
name: "Build & Push Elastic PersistenceProvider Dashboard Importer Image"
157+
with:
158+
username: ${{ secrets.DOCKER_USERNAME }}
159+
password: ${{ secrets.DOCKER_PASSWORD }}
160+
repository: scbexperimental/persistence-elastic-dashboard-importer
161+
path: ./persistence/persistence-elastic/dashboardImporter/
162+
tag_with_ref: true
155163
scannerImages:
156164
# Note we only build images for scanner that don't provider official public container images
157165
name: "Build Scanner Images"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM alpine:3.11
2+
3+
RUN apk add --no-cache curl bash
4+
5+
RUN addgroup -S app && adduser -S -G app app
6+
USER app
7+
8+
WORKDIR /home/dashboard-importer/
9+
10+
COPY dashboards/ ./dashboards/
11+
COPY import-dashboards.sh ./
12+
13+
CMD [ "bash", "import-dashboards.sh" ]

persistence/persistence-elastic/dashboardImporter/dashboards/daily-summary.json

Lines changed: 301 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
kibanaURL=${1:-"http://localhost:5601"}
4+
5+
exportDashboard() {
6+
local filename=$1
7+
local id=$2
8+
curl ${kibanaURL}/api/kibana/dashboards/export?dashboard=${id} > ./dashboards/${filename}
9+
}
10+
11+
exportDashboard "daily-summary.json" "34c734b0-6e79-11ea-bdc0-35f8aa7c4664"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
kibanaURL=${KIBANA_URL:-"http://localhost:5601"}
4+
5+
echo "Waiting until kibana becomes availible"
6+
until $(curl --output /dev/null --silent --head --fail ${kibanaURL}); do
7+
printf '.'
8+
sleep 5
9+
done
10+
echo "Kibana is availible"
11+
12+
for filename in ./dashboards/*.json; do
13+
echo "Importing dashboard '${filename}'"
14+
curl -i -H "Content-Type: application/json" -H "kbn-xsrf: reporting" -X POST --data @${filename} ${kibanaURL}/api/kibana/dashboards/import
15+
done
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Dashboard Importer
2+
3+
Imports all standard secureCodeBox Dashboards to Kibana.
4+
This comes pre-bundled as a kubernetes job. If you install the Elastic Persistence Provider via helm you will get this by default ;)
5+
6+
## Updating the Kibana Dashboards
7+
8+
If you made changes to the Kibana Dashboards which you want rolled out to everybody, you can update the dashboards in the [dashboards](./dashboards/) folder. To update the easily you can use the [export-dashboards](./export-dashboards.sh) bash script.
9+
10+
```bash
11+
# Default call. Assumes Kibana to be available at "http://localhost:5601"
12+
./export-dashboards.sh
13+
14+
# With a custom kibana endpoint
15+
./export-dashboards.sh "https://kibana.local.example.com"
16+
```

0 commit comments

Comments
 (0)