blob: 77ccbd1b88fc37de63eb0088a2bf75770f03855e [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
garciadeblasbae51f62023-03-28 18:27:20 +020033kind: ConfigMap
34metadata:
35 name: prom
garciadeblas3a1db652022-09-30 12:00:27 +020036data:
garciadeblasbae51f62023-03-28 18:27:20 +020037 osm_metric_rules.yml: |
garciadeblas3a1db652022-09-30 12:00:27 +020038 groups:
garciadeblasbae51f62023-03-28 18:27:20 +020039 - name: osm_metric_rules
garciadeblas3a1db652022-09-30 12:00:27 +020040 rules:
41 - record: vm_status_extended
aguilardcb7dc672022-11-30 13:00:32 +010042 expr: (last_over_time(vm_status[1m]) * on (vm_id, vim_id) group_left(ns_id, vnf_id, vdu_id, project_id, job, vdu_name, vnf_member_index) last_over_time(ns_topology[1m])) or (last_over_time(ns_topology[1m]) * -1)
garciadeblas3a1db652022-09-30 12:00:27 +020043 labels:
44 job: osm_prometheus
45 - record: vnf_status
46 expr: (0 * (count (vm_status_extended==0) by (ns_id, vnf_id)>=0)) or (min by (ns_id, vnf_id) (vm_status_extended))
47 labels:
48 job: osm_prometheus
49 - record: ns_status
50 expr: (0 * (count (vm_status_extended==0) by (ns_id)>=0)) or (min by (ns_id) (vm_status_extended))
51 labels:
52 job: osm_prometheus
garciadeblasbae51f62023-03-28 18:27:20 +020053 osm_alert_rules.yml: |
54 groups:
55 - name: osm_alert_rules
56 rules:
57 - alert: vdu_down
58 expr: vm_status_extended != 1
59 for: 3m
60 annotations:
61 summary: "VDU {{ $labels.vm_id }} in VIM {{ $labels.vim_id }} is down"
62 description: "VDU {{ $labels.vm_id }} in VIM {{ $labels.vim_id }} has been down for more than 3 minutes. NS instance id is {{ $labels.ns_id }}"
garciadeblas3a1db652022-09-30 12:00:27 +020063 prometheus.yml: |
64 # Copyright 2018 The Prometheus Authors
65 # Copyright 2018 Whitestack
66 # Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U.
67 #
68 # Licensed under the Apache License, Version 2.0 (the "License");
69 # you may not use this file except in compliance with the License.
70 # You may obtain a copy of the License at
71 #
72 # http://www.apache.org/licenses/LICENSE-2.0
73 #
74 # Unless required by applicable law or agreed to in writing, software
75 # distributed under the License is distributed on an "AS IS" BASIS,
76 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77 # See the License for the specific language governing permissions and
78 # limitations under the License.
79
80 # my global config
81 global:
82 scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
83 evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
84 # scrape_timeout is set to the global default (10s).
85
86 # Alertmanager configuration
87 alerting:
88 alertmanagers:
89 - static_configs:
90 - targets:
garciadeblasbae51f62023-03-28 18:27:20 +020091 - alertmanager:9093
garciadeblas3a1db652022-09-30 12:00:27 +020092
93 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
94 rule_files:
garciadeblasbae51f62023-03-28 18:27:20 +020095 - "osm_metric_rules.yml"
96 - "osm_alert_rules.yml"
garciadeblas3a1db652022-09-30 12:00:27 +020097
98 # A scrape configuration containing exactly one endpoint to scrape:
99 # Here it's Prometheus itself.
100 scrape_configs:
garciadeblasbef284e2022-11-18 00:55:44 +0100101 - job_name: 'mon_exporter'
102 static_configs:
103 - targets: ['mon:8000']
garciadeblas3a1db652022-09-30 12:00:27 +0200104 - job_name: pushgateway
105 honor_labels: true
106 scrape_interval: 30s
107 static_configs:
108 - targets:
109 - pushgateway-prometheus-pushgateway:9091
garciadeblas3a1db652022-09-30 12:00:27 +0200110---
111apiVersion: apps/v1
112kind: StatefulSet
113metadata:
114 name: prometheus
115 labels:
116 app: prometheus
117spec:
118 replicas: 1
119 serviceName: prometheus
120 selector:
121 matchLabels:
122 app: prometheus
123 template:
124 metadata:
125 labels:
126 app: prometheus
127 spec:
128 initContainers:
129 - name: prometheus-init-config
130 image: busybox
131 command: ["/bin/sh", "-c"]
garciadeblasbae51f62023-03-28 18:27:20 +0200132 args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /config/prometheus.yml /etc/prometheus; fi; cp /config/osm_metric_rules.yml /config/osm_alert_rules.yml /etc/prometheus']
garciadeblas3a1db652022-09-30 12:00:27 +0200133 volumeMounts:
134 - name: prom-config
135 mountPath: /etc/prometheus
136 - name: prom-config-base
137 mountPath: /config
138 containers:
139 - name: prometheus
140 image: prom/prometheus:v2.28.1
141 args:
142 - --config.file=/etc/prometheus/prometheus.yml
143 - --web.enable-lifecycle
144 ports:
145 - containerPort: 9090
146 protocol: TCP
147 volumeMounts:
148 - name: prom-config
149 mountPath: /etc/prometheus
150 - name: prom-db
151 mountPath: /prometheus
152 - name: prometheus-config-sidecar
garciadeblas89c5f552022-11-24 20:16:57 +0100153 image: opensourcemano/prometheus:13
garciadeblas3a1db652022-09-30 12:00:27 +0200154 env:
155 - name: MONGODB_URL
156 value: mongodb://mongodb-k8s:27017/?replicaSet=rs0
157 - name: PROMETHEUS_CONFIG_FILE
158 value: /etc/prometheus/prometheus.yml
159 - name: PROMETHEUS_BASE_CONFIG_FILE
160 value: /etc/prometheus_base/prometheus.yml
161 - name: TARGET_DATABASE
162 value: osm
163 - name: PROMETHEUS_URL
164 value: http://prometheus:9090
165 volumeMounts:
166 - name: prom-config
167 mountPath: /etc/prometheus
168 - name: prom-config-base
169 mountPath: /etc/prometheus_base
170 volumes:
171 - name: prom-db
172 emptyDir: {}
173 - name: prom-config
174 emptyDir: {}
175 - name: prom-config-base
176 configMap:
177 name: prom