Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-flock / stx-monitor-armada-app / monitor-helm / 0006-add-system-info.patch
1 From 4f42518e2e15a65e340e15029c50b53b20e119e9 Mon Sep 17 00:00:00 2001
2 From: Kevin Smith <kevin.smith@windriver.com>
3 Date: Sat, 14 Sep 2019 12:10:44 -0400
4 Subject: [PATCH 1/1] add system info
5
6 ---
7  stable/filebeat/templates/configmap.yaml    | 22 ++++++++++++++---
8  stable/filebeat/templates/daemonset.yaml    | 36 ++++++++++++++++++++++++++++
9  stable/filebeat/values.yaml                 |  4 ++++
10  stable/logstash/templates/statefulset.yaml  | 10 ++++++++
11  stable/logstash/values.yaml                 |  3 +++
12  stable/metricbeat/templates/configmap.yaml  | 22 ++++++++++++++---
13  stable/metricbeat/templates/daemonset.yaml  | 37 ++++++++++++++++++++++++++++-
14  stable/metricbeat/templates/deployment.yaml | 18 ++++++++++++++
15  stable/metricbeat/values.yaml               |  4 ++++
16  9 files changed, 149 insertions(+), 7 deletions(-)
17
18 diff --git a/stable/filebeat/templates/configmap.yaml b/stable/filebeat/templates/configmap.yaml
19 index 8377e5a..c08a4bc 100644
20 --- a/stable/filebeat/templates/configmap.yaml
21 +++ b/stable/filebeat/templates/configmap.yaml
22 @@ -18,7 +18,9 @@ data:
23      BEAT_VER=$($BEAT version | awk '{print $3}')
24  
25      ADDR=$OUTPUT_ELASTICSEARCH_HOSTS
26 -    echo $ADDR
27 +    ESPATH=$OUTPUT_ELASTICSEARCH_PATH
28 +
29 +    echo $ADDR$ESPATH
30  
31      # Check if this is a map of entries.  If so, we'll only export the template
32      # to the first address
33 @@ -28,7 +30,7 @@ data:
34         # Take the first entry in case there are more than one
35         ADDR=${ADDR%%,*}
36      fi
37 -    echo $ADDR
38 +    echo $ADDR$ESPATH
39  
40      # Check if user has formatted with http:// on front, if not we need to add
41      HTTP='http://'
42 @@ -53,7 +55,21 @@ data:
43         # remove the lifecycle section of the yaml, as elasticsearch will choke
44         # on it as oss version does not support ilm.
45         sed -i '/lifecycle/,+3d' /tmp/beat.template.json
46 -       curl -v $CURL_G -XPUT -H "Content-Type: application/json" $HTTP$ADDR/_template/$BEAT-$BEAT_VER -d@/tmp/beat.template.json
47 +
48 +       # "unset" is the special system name when none has been set through
49 +       # overrides..  We key on that to know what template name and index pattern to set
50 +       if [[ $SYSTEM_NAME_FOR_INDEX != unset ]]; then
51 +          # replace the standard index pattern with one including our system name,
52 +          # which will match our created indices
53 +          sed -i "s/$BEAT-$BEAT_VER/$BEAT-$BEAT_VER$SYSTEM_NAME_FOR_INDEX/g" /tmp/beat.template.json
54 +          # give the template a name with the system name appended.
55 +          curl -v $CURL_G -XPUT -H "Content-Type: application/json" $HTTP$ADDR$ESPATH/_template/$BEAT-$BEAT_VER$SYSTEM_NAME_FOR_INDEX -d@/tmp/beat.template.json
56 +       else
57 +          # apply a higher order to this template in case there are templates with system names
58 +          # which should be applied first
59 +          sed -i "s/\"order\": 1/\"order\": 2/g" /tmp/beat.template.json
60 +          curl -v $CURL_G -XPUT -H "Content-Type: application/json" $HTTP$ADDR$ESPATH/_template/$BEAT-$BEAT_VER -d@/tmp/beat.template.json
61 +       fi
62      else
63         echo "logstash not configured, not exporting template, should be done for us."
64      fi
65 diff --git a/stable/filebeat/templates/daemonset.yaml b/stable/filebeat/templates/daemonset.yaml
66 index b8536fb..b1833a9 100644
67 --- a/stable/filebeat/templates/daemonset.yaml
68 +++ b/stable/filebeat/templates/daemonset.yaml
69 @@ -64,6 +64,24 @@ spec:
70        {{- end }}
71        {{- end }}
72        {{- end }}
73 +      ## make system name and index parms visible
74 +      {{- if .Values.systemNameForIndex}}
75 +      {{  $systemNameNoSpecial := regexReplaceAll "[^A-Za-z0-9-]+" .Values.systemNameForIndex "" }}
76 +      {{  $systemNameFormatted := $systemNameNoSpecial | lower | trunc 200 }}
77 +        - name: SYSTEM_NAME_FOR_INDEX
78 +          value: {{ printf "-%s" $systemNameFormatted | quote }}
79 +        - name: INDEX_PATTERN
80 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}-*"
81 +        - name: INDEX_NAME
82 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}"
83 +      {{- else }}
84 +        - name: SYSTEM_NAME_FOR_INDEX
85 +          value: "unset"
86 +        - name: INDEX_PATTERN
87 +          value: "{{ .Values.indexNamePrefix }}-*"
88 +        - name: INDEX_NAME
89 +          value: "{{ .Values.indexNamePrefix }}"
90 +      {{- end }}
91  {{- if .Values.indexTemplateLoad }}
92        - name: "load-es-template"
93          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
94 @@ -116,6 +134,24 @@ spec:
95        {{- end }}
96        {{- end }}
97        {{- end }}
98 +      ## make system name and index parms visible
99 +      {{- if .Values.systemNameForIndex}}
100 +      {{  $systemNameNoSpecial := regexReplaceAll "[^A-Za-z0-9-]+" .Values.systemNameForIndex "" }}
101 +      {{  $systemNameFormatted := $systemNameNoSpecial | lower | trunc 200 }}
102 +        - name: SYSTEM_NAME_FOR_INDEX
103 +          value: {{ printf "-%s" $systemNameFormatted | quote }}
104 +        - name: INDEX_PATTERN
105 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}-*"
106 +        - name: INDEX_NAME
107 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}"
108 +      {{- else }}
109 +        - name: SYSTEM_NAME_FOR_INDEX
110 +          value: "unset"
111 +        - name: INDEX_PATTERN
112 +          value: "{{ .Values.indexNamePrefix }}-*"
113 +        - name: INDEX_NAME
114 +          value: "{{ .Values.indexNamePrefix }}"
115 +      {{- end }}
116  {{- if .Values.extraVars }}
117  {{ toYaml .Values.extraVars | indent 8 }}
118  {{- end }}
119 diff --git a/stable/filebeat/values.yaml b/stable/filebeat/values.yaml
120 index b4b766f..3897c82 100644
121 --- a/stable/filebeat/values.yaml
122 +++ b/stable/filebeat/values.yaml
123 @@ -68,6 +68,10 @@ extraVars: []
124    #       name: configmap
125    #       key: config.key
126  
127 +# Will be used in index name
128 +systemNameForIndex: ""
129 +indexNamePrefix: filebeat-%{[agent.version]}
130 +
131  # Add additional volumes and mounts, for example to read other log files on the host
132  extraVolumes: []
133    # - hostPath:
134 diff --git a/stable/logstash/templates/statefulset.yaml b/stable/logstash/templates/statefulset.yaml
135 index cca0050..070ef56 100644
136 --- a/stable/logstash/templates/statefulset.yaml
137 +++ b/stable/logstash/templates/statefulset.yaml
138 @@ -71,6 +71,16 @@ spec:
139                value: {{ .Values.elasticsearch.host | quote }}
140              - name: ELASTICSEARCH_PORT
141                value: {{ .Values.elasticsearch.port | quote }}
142 +            ## make system name visible for in setting index.
143 +          {{- if .Values.systemNameForIndex}}
144 +          {{  $systemNameNoSpecial := regexReplaceAll "[^A-Za-z0-9-]+" .Values.systemNameForIndex "" }}
145 +          {{  $systemNameFormatted := $systemNameNoSpecial | lower | trunc 200 }}
146 +            - name: SYSTEM_NAME_FOR_INDEX
147 +              value: {{ printf "-%s" $systemNameFormatted | quote }}
148 +          {{- else }}
149 +            - name: SYSTEM_NAME_FOR_INDEX
150 +              value: ""
151 +          {{- end }}
152              ## Additional env vars
153            {{- range $key, $value := .Values.config }}
154              - name: {{ $key | upper | replace "." "_" }}
155 diff --git a/stable/logstash/values.yaml b/stable/logstash/values.yaml
156 index 9a452b1..9ba80c9 100644
157 --- a/stable/logstash/values.yaml
158 +++ b/stable/logstash/values.yaml
159 @@ -220,6 +220,9 @@ patterns:
160    # main: |-
161    #   TESTING {"foo":.*}$
162  
163 +# Will be used in index names
164 +systemNameForIndex: ""
165 +
166  ## Custom files that can be referenced by plugins.
167  ## Each YAML heredoc will become located in the logstash home directory under
168  ## the files subdirectory.
169 diff --git a/stable/metricbeat/templates/configmap.yaml b/stable/metricbeat/templates/configmap.yaml
170 index 4249e7f..9ae276d 100644
171 --- a/stable/metricbeat/templates/configmap.yaml
172 +++ b/stable/metricbeat/templates/configmap.yaml
173 @@ -18,7 +18,9 @@ data:
174      BEAT_VER=$($BEAT version | awk '{print $3}')
175  
176      ADDR=$OUTPUT_ELASTICSEARCH_HOSTS
177 -    echo $ADDR
178 +    ESPATH=$OUTPUT_ELASTICSEARCH_PATH
179 +
180 +    echo $ADDR$ESPATH
181  
182      # Check if this is a map of entries.  If so, we'll only export the template
183      # to the first address
184 @@ -28,7 +30,7 @@ data:
185         # Take the first entry in case there are more than one
186         ADDR=${ADDR%%,*}
187      fi
188 -    echo $ADDR
189 +    echo $ADDR$ESPATH
190  
191      # Check if user has formatted with http:// on front, if not we need to add
192      HTTP='http://'
193 @@ -53,7 +55,21 @@ data:
194         # remove the lifecycle section of the yaml, as elasticsearch will choke
195         # on it as oss version does not support ilm.
196         sed -i '/lifecycle/,+3d' /tmp/beat.template.json
197 -       curl -v $CURL_G -XPUT -H "Content-Type: application/json" $HTTP$ADDR/_template/$BEAT-$BEAT_VER -d@/tmp/beat.template.json
198 +
199 +       # "unset" is the special system name when none has been set through
200 +       # overrides..  We key on that to know what template name and index pattern to set
201 +       if [[ $SYSTEM_NAME_FOR_INDEX != unset ]]; then
202 +          # replace the standard index pattern with one including our system name,
203 +          # which will match our created indices
204 +          sed -i "s/$BEAT-$BEAT_VER/$BEAT-$BEAT_VER$SYSTEM_NAME_FOR_INDEX/g" /tmp/beat.template.json
205 +          # give the template a name with the system name appended.
206 +          curl -v $CURL_G -XPUT -H "Content-Type: application/json" $HTTP$ADDR$ESPATH/_template/$BEAT-$BEAT_VER$SYSTEM_NAME_FOR_INDEX -d@/tmp/beat.template.json
207 +       else
208 +          # apply a higher order to this template in case there are templates with system names
209 +          # which should be applied first
210 +          sed -i "s/\"order\": 1/\"order\": 2/g" /tmp/beat.template.json
211 +          curl -v $CURL_G -XPUT -H "Content-Type: application/json" $HTTP$ADDR$ESPATH/_template/$BEAT-$BEAT_VER -d@/tmp/beat.template.json
212 +       fi
213      else
214         echo "logstash not configured, not exporting template, should be done for us."
215      fi
216 diff --git a/stable/metricbeat/templates/daemonset.yaml b/stable/metricbeat/templates/daemonset.yaml
217 index 1ae3a34..947e501 100644
218 --- a/stable/metricbeat/templates/daemonset.yaml
219 +++ b/stable/metricbeat/templates/daemonset.yaml
220 @@ -59,7 +59,24 @@ spec:
221        {{- end }}
222        {{- end }}
223        {{- end }}
224 -
225 +      ## make system name and index parms visible
226 +      {{- if .Values.systemNameForIndex}}
227 +      {{  $systemNameNoSpecial := regexReplaceAll "[^A-Za-z0-9-]+" .Values.systemNameForIndex "" }}
228 +      {{  $systemNameFormatted := $systemNameNoSpecial | lower | trunc 200 }}
229 +        - name: SYSTEM_NAME_FOR_INDEX
230 +          value: {{ printf "-%s" $systemNameFormatted | quote }}
231 +        - name: INDEX_PATTERN
232 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}-*"
233 +        - name: INDEX_NAME
234 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}"
235 +      {{- else }}
236 +        - name: SYSTEM_NAME_FOR_INDEX
237 +          value: "unset"
238 +        - name: INDEX_PATTERN
239 +          value: "{{ .Values.indexNamePrefix }}-*"
240 +        - name: INDEX_NAME
241 +          value: "{{ .Values.indexNamePrefix }}"
242 +      {{- end }}
243        containers:
244        - name: {{ .Chart.Name }}
245          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
246 @@ -94,6 +111,24 @@ spec:
247        {{- end }}
248        {{- end }}
249        {{- end }}
250 +      ## make system name and index parms visible
251 +      {{- if .Values.systemNameForIndex}}
252 +      {{  $systemNameNoSpecial := regexReplaceAll "[^A-Za-z0-9-]+" .Values.systemNameForIndex "" }}
253 +      {{  $systemNameFormatted := $systemNameNoSpecial | lower | trunc 200 }}
254 +        - name: SYSTEM_NAME_FOR_INDEX
255 +          value: {{ printf "-%s" $systemNameFormatted | quote }}
256 +        - name: INDEX_PATTERN
257 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}-*"
258 +        - name: INDEX_NAME
259 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}"
260 +      {{- else }}
261 +        - name: SYSTEM_NAME_FOR_INDEX
262 +          value: "unset"
263 +        - name: INDEX_PATTERN
264 +          value: "{{ .Values.indexNamePrefix }}-*"
265 +        - name: INDEX_NAME
266 +          value: "{{ .Values.indexNamePrefix }}"
267 +      {{- end }}
268  {{- if .Values.extraEnv }}
269  {{ toYaml .Values.extraEnv | indent 8 }}
270  {{- end }}
271 diff --git a/stable/metricbeat/templates/deployment.yaml b/stable/metricbeat/templates/deployment.yaml
272 index 47ada04..d1d08e3 100644
273 --- a/stable/metricbeat/templates/deployment.yaml
274 +++ b/stable/metricbeat/templates/deployment.yaml
275 @@ -55,6 +55,24 @@ spec:
276            valueFrom:
277              fieldRef:
278                fieldPath: spec.nodeName
279 +      ## make system name and index parms visible
280 +      {{- if .Values.systemNameForIndex}}
281 +      {{  $systemNameNoSpecial := regexReplaceAll "[^A-Za-z0-9-]+" .Values.systemNameForIndex "" }}
282 +      {{  $systemNameFormatted := $systemNameNoSpecial | lower | trunc 200 }}
283 +        - name: SYSTEM_NAME_FOR_INDEX
284 +          value: {{ printf "-%s" $systemNameFormatted | quote }}
285 +        - name: INDEX_PATTERN
286 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}-*"
287 +        - name: INDEX_NAME
288 +          value: "{{ .Values.indexNamePrefix }}-{{$systemNameFormatted}}"
289 +      {{- else }}
290 +        - name: SYSTEM_NAME_FOR_INDEX
291 +          value: "unset"
292 +        - name: INDEX_PATTERN
293 +          value: "{{ .Values.indexNamePrefix }}-*"
294 +        - name: INDEX_NAME
295 +          value: "{{ .Values.indexNamePrefix }}"
296 +      {{- end }}
297  {{- if .Values.extraEnv }}
298  {{ toYaml .Values.extraEnv | indent 8 }}
299  {{- end }}
300 diff --git a/stable/metricbeat/values.yaml b/stable/metricbeat/values.yaml
301 index c8f758c..b59c428 100644
302 --- a/stable/metricbeat/values.yaml
303 +++ b/stable/metricbeat/values.yaml
304 @@ -130,6 +130,10 @@ extraEnv:
305  #  - name: test2
306  #    value: "test2"
307  
308 +# Will be used in index name
309 +systemNameForIndex: ""
310 +indexNamePrefix: metricbeat-%{[agent.version]}
311 +
312  # Add additional volumes and mounts, for example to read other log files on the host
313  extraVolumes: []
314    # - hostPath:
315 -- 
316 1.8.3.1
317