-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-openobserve.sh
executable file
·63 lines (52 loc) · 1.93 KB
/
setup-openobserve.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
source .env
OPENOBSERVE="http://127.0.0.1:5080"
openobserve_status() {
curl --silent -X "GET" \
"${OPENOBSERVE}/healthz" \
-H "accept: application/json" \
| sed -e 's/^.*"status":"\([^"]*\)".*$/\1/g'
}
openobserve_api_get() {
curl --silent -X "GET" \
"${OPENOBSERVE}/api/$1/$2" \
-H "accept: application/json" \
-u ${ZO_ROOT_USER_EMAIL}:${ZO_ROOT_USER_PASSWORD}
}
openobserve_api_post() {
curl --silent -X "POST" \
"${OPENOBSERVE}/api/$1/$2" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-u ${ZO_ROOT_USER_EMAIL}:${ZO_ROOT_USER_PASSWORD} \
--output /dev/null \
--data "$3"
}
echo "Wait until OpenObserve is ready..."
while [[ $(openobserve_status) != "ok" ]]; do
sleep 1
done
echo "Create OpenObserve functions..."
openobserve_api_post lab functions ParseWinEvtLog.function.json
echo "Create OpenObserve saved views..."
# Lab user
openobserve_api_post lab savedviews @openobserve/WordPress.view.json
openobserve_api_post lab savedviews @openobserve/SuricataAlerts.view.json
openobserve_api_post lab savedviews @openobserve/SuricataFlows.view.json
openobserve_api_post lab savedviews @openobserve/WindowsEventLog.view.json
openobserve_api_post lab savedviews @openobserve/WindowsLogon.view.json
openobserve_api_post lab savedviews @openobserve/WindowsProcess.view.json
# Admin user
openobserve_api_post admin savedviews @openobserve/Docker.view.json
openobserve_api_post admin savedviews @openobserve/Suricata.view.json
echo "Create OpenObserve dashboards..."
openobserve_api_post lab dashboards @openobserve/LabDashboard.dashboard.json
echo "Create OpenObserve users..."
openobserve_api_post lab users "{
\"email\": \"${ZO_STUDENT_USER_EMAIL}\",
\"password\": \"${ZO_STUDENT_USER_PASSWORD}\",
\"first_name\": \"Student\",
\"last_name\": \"User\",
\"is_external\": false,
\"role\": \"member\"
}"