blob: 56aca67d805e2929192122cb630e5c1dc679a0ac [file] [log] [blame]
garciadeblas3a1db652022-09-30 12:00:27 +02001#######################################################################################
2# Copyright ETSI Contributors and Others.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#######################################################################################
17
18apiVersion: v1
19kind: Service
20metadata:
21 name: prometheus
22spec:
23 ports:
24 - nodePort: 9091
25 port: 9090
26 protocol: TCP
27 targetPort: 9090
28 selector:
29 app: prometheus
30 type: NodePort
31---
32apiVersion: v1
33data:
34 osm_rules.yml: |
35 groups:
36 - name: osm_rules
37 rules:
38 - record: vm_status_extended
39 expr: (last_over_time(vm_status[1m]) * on (vm_id, vim_id) group_left(ns_id, vnf_id, vdu_id, project_id, job) last_over_time(ns_topology[1m])) or (last_over_time(ns_topology[1m]) * -1)
40 labels:
41 job: osm_prometheus
42 - record: vnf_status
43 expr: (0 * (count (vm_status_extended==0) by (ns_id, vnf_id)>=0)) or (min by (ns_id, vnf_id) (vm_status_extended))
44 labels:
45 job: osm_prometheus
46 - record: ns_status
47 expr: (0 * (count (vm_status_extended==0) by (ns_id)>=0)) or (min by (ns_id) (vm_status_extended))
48 labels:
49 job: osm_prometheus
50 prometheus.yml: |
51 # Copyright 2018 The Prometheus Authors
52 # Copyright 2018 Whitestack
53 # Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U.
54 #
55 # Licensed under the Apache License, Version 2.0 (the "License");
56 # you may not use this file except in compliance with the License.
57 # You may obtain a copy of the License at
58 #
59 # http://www.apache.org/licenses/LICENSE-2.0
60 #
61 # Unless required by applicable law or agreed to in writing, software
62 # distributed under the License is distributed on an "AS IS" BASIS,
63 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64 # See the License for the specific language governing permissions and
65 # limitations under the License.
66
67 # my global config
68 global:
69 scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
70 evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
71 # scrape_timeout is set to the global default (10s).
72
73 # Alertmanager configuration
74 alerting:
75 alertmanagers:
76 - static_configs:
77 - targets:
78 # - alertmanager:9093
79
80 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
81 rule_files:
82 - "osm_rules.yml"
83 # - "second_rules.yml"
84
85 # A scrape configuration containing exactly one endpoint to scrape:
86 # Here it's Prometheus itself.
87 scrape_configs:
88 - job_name: pushgateway
89 honor_labels: true
90 scrape_interval: 30s
91 static_configs:
92 - targets:
93 - pushgateway-prometheus-pushgateway:9091
94kind: ConfigMap
95metadata:
96 name: prom
97---
98apiVersion: apps/v1
99kind: StatefulSet
100metadata:
101 name: prometheus
102 labels:
103 app: prometheus
104spec:
105 replicas: 1
106 serviceName: prometheus
107 selector:
108 matchLabels:
109 app: prometheus
110 template:
111 metadata:
112 labels:
113 app: prometheus
114 spec:
115 initContainers:
116 - name: prometheus-init-config
117 image: busybox
118 command: ["/bin/sh", "-c"]
119 args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /config/prometheus.yml /etc/prometheus; fi; cp /config/osm_rules.yml /etc/prometheus']
120 volumeMounts:
121 - name: prom-config
122 mountPath: /etc/prometheus
123 - name: prom-config-base
124 mountPath: /config
125 containers:
126 - name: prometheus
127 image: prom/prometheus:v2.28.1
128 args:
129 - --config.file=/etc/prometheus/prometheus.yml
130 - --web.enable-lifecycle
131 ports:
132 - containerPort: 9090
133 protocol: TCP
134 volumeMounts:
135 - name: prom-config
136 mountPath: /etc/prometheus
137 - name: prom-db
138 mountPath: /prometheus
139 - name: prometheus-config-sidecar
140 image: opensourcemano/prometheus:12
141 env:
142 - name: MONGODB_URL
143 value: mongodb://mongodb-k8s:27017/?replicaSet=rs0
144 - name: PROMETHEUS_CONFIG_FILE
145 value: /etc/prometheus/prometheus.yml
146 - name: PROMETHEUS_BASE_CONFIG_FILE
147 value: /etc/prometheus_base/prometheus.yml
148 - name: TARGET_DATABASE
149 value: osm
150 - name: PROMETHEUS_URL
151 value: http://prometheus:9090
152 volumeMounts:
153 - name: prom-config
154 mountPath: /etc/prometheus
155 - name: prom-config-base
156 mountPath: /etc/prometheus_base
157 volumes:
158 - name: prom-db
159 emptyDir: {}
160 - name: prom-config
161 emptyDir: {}
162 - name: prom-config-base
163 configMap:
164 name: prom