Prepare installer and pods for Rel TWELVE
[osm/devops.git] / installers / docker / osm_pods / prometheus.yaml
1 # Copyright 2021 Whitestack, LLC
2 # *************************************************************
3
4 # This file is part of OSM Monitoring module
5 # All Rights Reserved to Whitestack, LLC
6
7 # Licensed under the Apache License, Version 2.0 (the "License"); you may
8 # not use this file except in compliance with the License. You may obtain
9 # a copy of the License at
10
11 #         http://www.apache.org/licenses/LICENSE-2.0
12
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 # License for the specific language governing permissions and limitations
17 # under the License.
18
19 # For those usages not covered by the Apache License, Version 2.0 please
20 # contact: fbravo@whitestack.com or glavado@whitestack.com
21 ##
22
23 apiVersion: v1
24 kind: Service
25 metadata:
26   name: prometheus
27 spec:
28   ports:
29   - nodePort: 9091
30     port: 9090
31     protocol: TCP
32     targetPort: 9090
33   selector:
34     app: prometheus
35   type: NodePort
36 ---
37 apiVersion: v1
38 data:
39   prometheus.yml: |
40     # Copyright 2018 The Prometheus Authors
41     # Copyright 2018 Whitestack
42     # Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U.
43     #
44     # Licensed under the Apache License, Version 2.0 (the "License");
45     # you may not use this file except in compliance with the License.
46     # You may obtain a copy of the License at
47     #
48     # http://www.apache.org/licenses/LICENSE-2.0
49     #
50     # Unless required by applicable law or agreed to in writing, software
51     # distributed under the License is distributed on an "AS IS" BASIS,
52     # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53     # See the License for the specific language governing permissions and
54     # limitations under the License.
55
56     # my global config
57     global:
58       scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
59       evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
60       # scrape_timeout is set to the global default (10s).
61
62     # Alertmanager configuration
63     alerting:
64       alertmanagers:
65       - static_configs:
66         - targets:
67           # - alertmanager:9093
68
69     # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
70     rule_files:
71       # - "first_rules.yml"
72       # - "second_rules.yml"
73
74     # A scrape configuration containing exactly one endpoint to scrape:
75     # Here it's Prometheus itself.
76     scrape_configs:
77       # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
78       - job_name: 'mon_exporter'
79
80         # metrics_path defaults to '/metrics'
81         # scheme defaults to 'http'.
82
83         static_configs:
84         - targets: ['mon:8000']
85 kind: ConfigMap
86 metadata:
87   name: prom
88 ---
89 apiVersion: apps/v1
90 kind: StatefulSet
91 metadata:
92   name: prometheus
93   labels:
94     app: prometheus
95 spec:
96   replicas: 1
97   serviceName: prometheus
98   selector:
99     matchLabels:
100       app: prometheus
101   template:
102     metadata:
103       labels:
104         app: prometheus
105     spec:
106       initContainers:
107       - name: prometheus-init-config
108         image: busybox
109         command: ["/bin/sh", "-c"]
110         args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /etc/prometheus_init/prometheus.yml /etc/prometheus; fi']
111         volumeMounts:
112           - name: prom-config
113             mountPath: /etc/prometheus
114           - name: init-prom-config
115             mountPath: /etc/prometheus_init
116       containers:
117       - name: prometheus
118         image: prom/prometheus:v2.28.1
119         args:
120         - --config.file=/etc/prometheus/prometheus.yml
121         - --web.enable-lifecycle
122         ports:
123         - containerPort: 9090
124           protocol: TCP
125         volumeMounts:
126         - name: prom-config
127           mountPath: /etc/prometheus
128         - name: prom-db
129           mountPath: /prometheus
130       - name: prometheus-config-sidecar
131         image: opensourcemano/prometheus:12
132         env:
133         - name: MONGODB_URL
134           value: mongodb://mongodb-k8s:27017/?replicaSet=rs0
135         - name: PROMETHEUS_CONFIG_FILE
136           value: /etc/prometheus/prometheus.yml
137         - name: TARGET_DATABASE
138           value: osm
139         - name: PROMETHEUS_URL
140           value: http://prometheus:9090
141         volumeMounts:
142         - name: prom-config
143           mountPath: /etc/prometheus
144       volumes:
145       - emptyDir: {}
146         name: prom-db
147       - name: prom-config
148         emptyDir: {}
149       - name: init-prom-config
150         configMap:
151           name: prom