3 # Copyright 2019 Minsait - Indra S.A.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # Author: Jose Manuel Palacios (jmpalacios@minsait.com)
17 # Author: Jose Antonio Martinez (jamartinezv@minsait.com)
19 # Script to generate new charts for kube-prometheus-stack
20 HERE
=$
(dirname $
(readlink
-f ${BASH_SOURCE[0]}))
21 source $HERE/versions_monitoring
25 V_OPERATOR
=$PROMETHEUS_OPERATOR
28 CHARTS_DIR
="$HERE/helm_charts"
35 rm -rf kube-prometheus-stack
> /dev
/null
2>&1
36 rm kube-prometheus-stack
* > /dev
/null
2>&1
38 echo "Fetching prometheus-community/kube-prometheus-stack..."
39 helm fetch
--version=$V_OPERATOR prometheus-community
/kube-prometheus-stack
40 tar xvf kube-prometheus-stack-
$V_OPERATOR.tgz
> /dev
/null
2>&1
44 # Patching Grafana dashboards
45 cd $CHARTS_DIR/kube-prometheus-stack
/templates
/grafana
/dashboards-1.14
46 # Replace kubelet dashboard (use singlestat panel instead of stat): Stat panel is available in Grafana 7.0+
47 cp $WORK_DIR/kubelet.yaml .
48 for f
in $
(find .
-name '*.yaml*');
50 # Set the correct datasource in all dashboards
51 linenumber
=`cat -n $f | grep -A8 '"name": "datasource"' | grep regex | awk '{print $1}'`
52 sed -e "$linenumber s/\"regex\": \"\"/\"regex\": \"Prometheus\"/" -i $f
53 # Use a fix interval instead of rate_interval variable: $__rate_interval is available in Grafana 7.2+
54 sed -e "s/\$__rate_interval/5m/g" -i $f