Add prometheus to deployment and integrate with open5gs mme, amf and smf metrics server

This commit is contained in:
herlesupreeth
2022-11-22 10:22:09 +01:00
parent e1c3804668
commit b5dfab1da3
11 changed files with 205 additions and 2 deletions

5
.env
View File

@@ -112,4 +112,7 @@ SMSC_IP=172.22.0.33
SRS_UE_IP=172.22.0.34
# SCP
SCP_IP=172.22.0.30
SCP_IP=172.22.0.35
# METRICS
METRICS_IP=172.22.0.36

View File

@@ -33,6 +33,9 @@ amf:
network_name:
full: Open5GS
amf_name: open5gs-amf0
metrics:
- addr: AMF_IP
port: 9091
scp:
sbi:

View File

@@ -288,6 +288,7 @@ services:
- "8805/udp"
- "2123/udp"
- "7777/tcp"
- "9091/tcp"
networks:
default:
ipv4_address: ${SMF_IP}
@@ -346,6 +347,7 @@ services:
expose:
- "38412/sctp"
- "7777/tcp"
- "9091/tcp"
# ports:
# - "38412:38412/sctp"
networks:
@@ -379,6 +381,7 @@ services:
- "5868/sctp"
- "36412/sctp"
- "2123/udp"
- "9091/tcp"
# ports:
# - "36412:36412/sctp"
networks:
@@ -638,6 +641,23 @@ services:
networks:
default:
ipv4_address: ${OSMOHLR_IP}
metrics:
build: ./metrics
image: docker_metrics
container_name: metrics
env_file:
- .env
volumes:
- ./metrics:/mnt/metrics
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
expose:
- "9090/tcp"
ports:
- "9090:9090/tcp"
networks:
default:
ipv4_address: ${METRICS_IP}
networks:
default:
ipam:

38
metrics/Dockerfile Normal file
View File

@@ -0,0 +1,38 @@
# BSD 2-Clause License
# Copyright (c) 2020, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM ubuntu:focal
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y wget && \
wget -q https://github.com/prometheus/prometheus/releases/download/v2.40.2/prometheus-2.40.2.linux-amd64.tar.gz && \
tar xvfz prometheus-2.40.2.linux-amd64.tar.gz
WORKDIR prometheus-2.40.2.linux-amd64
CMD /mnt/metrics/metrics_init.sh

40
metrics/metrics_init.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
# BSD 2-Clause License
# Copyright (c) 2020, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Sync docker time
#ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
mkdir -p /config
cp /mnt/metrics/prometheus.yml /config/
sed -i 's|AMF_IP|'$AMF_IP'|g' /config/prometheus.yml
sed -i 's|SMF_IP|'$SMF_IP'|g' /config/prometheus.yml
sed -i 's|MME_IP|'$MME_IP'|g' /config/prometheus.yml
./prometheus --config.file=/config/prometheus.yml

16
metrics/prometheus.yml Normal file
View File

@@ -0,0 +1,16 @@
global:
scrape_interval: 5s
external_labels:
monitor: 'open5gs-monitor'
scrape_configs:
- job_name: 'amf'
static_configs:
- targets: ['AMF_IP:9091']
- job_name: 'smf'
static_configs:
- targets: ['SMF_IP:9091']
- job_name: 'mme'
static_configs:
- targets: ['MME_IP:9091']

View File

@@ -39,6 +39,9 @@ mme:
network_name:
full: Open5GS
mme_name: open5gs-mme0
metrics:
- addr: MME_IP
port: 9091
sgwc:
gtpc:

View File

@@ -2,7 +2,7 @@
# BSD 2-Clause License
# Copyright (c) 2020, miaoski
# Copyright (c) 2020, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without

View File

@@ -287,6 +287,7 @@ services:
- "8805/udp"
- "2123/udp"
- "7777/tcp"
- "9091/tcp"
networks:
default:
ipv4_address: ${SMF_IP}
@@ -345,6 +346,7 @@ services:
expose:
- "38412/sctp"
- "7777/tcp"
- "9091/tcp"
# ports:
# - "38412:38412/sctp"
networks:
@@ -358,6 +360,7 @@ services:
- sgwu
- smf
- upf
- osmomsc
container_name: mme
env_file:
- .env
@@ -377,6 +380,7 @@ services:
- "5868/sctp"
- "36412/sctp"
- "2123/udp"
- "9091/tcp"
# ports:
# - "36412:36412/sctp"
networks:
@@ -406,6 +410,60 @@ services:
networks:
default:
ipv4_address: ${PCRF_IP}
osmomsc:
build: ./osmomsc
image: docker_osmomsc
container_name: osmomsc
volumes:
- ./osmomsc:/mnt/osmomsc
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
env_file:
- .env
environment:
- COMPONENT_NAME=osmomsc-1
depends_on:
- osmohlr
expose:
- "29118/sctp"
- "2775/tcp"
networks:
default:
ipv4_address: ${OSMOMSC_IP}
osmohlr:
build: ./osmohlr
image: docker_osmohlr
container_name: osmohlr
volumes:
- ./osmohlr:/mnt/osmohlr
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
env_file:
- .env
environment:
- COMPONENT_NAME=osmohlr-1
expose:
- "4222/tcp"
networks:
default:
ipv4_address: ${OSMOHLR_IP}
metrics:
build: ./metrics
image: docker_metrics
container_name: metrics
env_file:
- .env
volumes:
- ./metrics:/mnt/metrics
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
expose:
- "9090/tcp"
ports:
- "9090:9090/tcp"
networks:
default:
ipv4_address: ${METRICS_IP}
networks:
default:
ipam:

View File

@@ -157,6 +157,7 @@ services:
- "8805/udp"
- "2123/udp"
- "7777/tcp"
- "9091/tcp"
networks:
default:
ipv4_address: ${SMF_IP}
@@ -215,6 +216,7 @@ services:
expose:
- "38412/sctp"
- "7777/tcp"
- "9091/tcp"
# ports:
# - "38412:38412/sctp"
networks:
@@ -283,6 +285,23 @@ services:
networks:
default:
ipv4_address: ${NSSF_IP}
metrics:
build: ./metrics
image: docker_metrics
container_name: metrics
env_file:
- .env
volumes:
- ./metrics:/mnt/metrics
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
expose:
- "9090/tcp"
ports:
- "9090:9090/tcp"
networks:
default:
ipv4_address: ${METRICS_IP}
networks:
default:
ipam:

View File

@@ -36,6 +36,9 @@ smf:
p-cscf:
- PCSCF_IP
mtu: 1400
metrics:
- addr: SMF_IP
port: 9091
scp:
sbi: