generated from pagopa/pagopa-quarkus-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-local-infra.sh
169 lines (156 loc) · 3.71 KB
/
run-local-infra.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
project=$1
if [ -z "$project" ]
then
project="generic"
fi
cd docker
docker compose down --remove-orphans --volumes
docker compose up -d
cd ..
sleep 30
echo ""
echo ""
echo "Add policy"
printf -v body -- '{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_primary_shard_size": "50gb",
"max_age": "2d"
}
}
},
"warm": {
"min_age": "2d",
"actions": {
"set_priority": {
"priority": 50
}
}
},
"cold": {
"min_age": "4d",
"actions": {
"set_priority": {
"priority": 0
}
}
},
"delete": {
"min_age": "7d",
"actions": {
"delete": {}
}
}
},
"_meta": {
"description": "Policy for %s"
}
}
}
' ${project}
curl -k -X PUT "http://localhost:9200/_ilm/policy/logs-${project}" \
-H 'kbn-xsrf: true' \
-H 'Content-Type: application/json' \
-d "${body}"
echo ""
echo ""
echo "Add _component_template settings"
printf -v body -- '{
"template":{
"settings": {
"index.lifecycle.name": "logs-%s"
}
},
"_meta": {
"description": "Settings for %s"
}
}
' ${project} ${project}
curl -k -X PUT "http://localhost:9200/_component_template/logs-${project}-settings" \
-H 'kbn-xsrf: true' \
-H 'Content-Type: application/json' \
-d "${body}"
echo ""
echo ""
echo "Add _component_template mappings"
printf -v body -- '{
"template":{
"settings": {
"index.lifecycle.name": "logs-%s"
}
},
"_meta": {
"description": "Settings for %s"
}
}
' ${project} ${project}
curl -k -X PUT "http://localhost:9200/_component_template/logs-${project}-mappings" \
-H 'kbn-xsrf: true' \
-H 'Content-Type: application/json' \
-d "${body}"
echo ""
echo ""
echo "Add _index_template"
printf -v body -- '{
"index_patterns": [
"logs-%s-*"
],
"data_stream": {},
"composed_of": [ "logs-%s-mappings", "logs-%s-settings" ],
"priority": 500,
"_meta": {
"description": "Index template for %s"
}
}
' ${project} ${project} ${project} ${project}
curl -k -X PUT "http://localhost:9200/_index_template/logs-${project}" \
-H 'kbn-xsrf: true' \
-H 'Content-Type: application/json' \
-d "${body}"
echo ""
echo ""
echo "Add space"
printf -v body -- '{
"id": "%s",
"name": "%s",
"description" : "This is the %s Space",
"color": "#4C54E7",
"disabledFeatures": []
}
' ${project} ${project} ${project}
curl -k -X POST "http://localhost:5601/api/spaces/space" \
-H 'kbn-xsrf: true' \
-H 'Content-Type: application/json' \
-d "${body}"
echo ""
echo ""
echo "Add data_views"
printf -v body -- '{
"data_view": {
"title": "logs-%s-log-*",
"name": "Log Data View",
"timeFieldName": "@timestamp"
}
}
' ${project}
data_view=$(curl -k -X POST "http://localhost:5601/s/${project}/api/data_views/data_view" \
-H 'kbn-xsrf: true' \
-H 'Content-Type: application/json' \
-d "${body}")
echo ""
echo ""
echo "Set default data_views"
printf -v body -- '{
"data_view_id": "%s"
}
' $(echo "$data_view" | jq ".data_view.id")
curl -X POST "http://localhost:5601/s/${project}/api/data_views/default" \
-H 'kbn-xsrf: true' \
-H 'Content-Type: application/json' \
-d "${body}"
# Note: if the previous curl fails, you don't have the space set as default, not a big problem :)