From 5f6da8f3109d8e62908db26767ae73d0aade3806 Mon Sep 17 00:00:00 2001 From: b3c3ll Date: Thu, 24 Oct 2024 09:18:34 +0000 Subject: [PATCH] Using Grafana image instead of building it --- .env | 6 ++- 4g-external-ims-deploy.yaml | 17 ++++++-- 4g-volte-deploy.yaml | 15 +++++-- deploy-all.yaml | 15 +++++-- grafana/Dockerfile | 39 ----------------- .../{ => dashboards}/open5gs_dashboard.json | 0 .../{ => dashboards}/open5gs_dashboard.yml | 2 +- grafana/datasources/prometheus_open5gs.yml | 9 ++++ grafana/grafana_init.sh | 43 ------------------- grafana/prometheus_open5gs.yml | 6 --- sa-deploy.yaml | 17 ++++++-- sa-vonr-deploy.yaml | 15 +++++-- 12 files changed, 76 insertions(+), 108 deletions(-) delete mode 100644 grafana/Dockerfile rename grafana/{ => dashboards}/open5gs_dashboard.json (100%) rename grafana/{ => dashboards}/open5gs_dashboard.yml (78%) create mode 100644 grafana/datasources/prometheus_open5gs.yml delete mode 100755 grafana/grafana_init.sh delete mode 100644 grafana/prometheus_open5gs.yml diff --git a/.env b/.env index 38d5f288..f5a79bbf 100644 --- a/.env +++ b/.env @@ -129,12 +129,14 @@ SRS_GNB_IP=172.22.0.37 # GRAFANA GRAFANA_IP=172.22.0.39 +GRAFANA_USERNAME=open5gs +GRAFANA_PASSWORD=open5gs # UE IPv4 Subnet Range for APN=internet -UE_IPV4_INTERNET=192.168.100.0/24 +UE_IPV4_INTERNET=192.168.200.0/24 # UE IPv4 Subnet Range for APN=ims -UE_IPV4_IMS=192.168.101.0/24 +UE_IPV4_IMS=192.168.201.0/24 # Maximum Number of UEs MAX_NUM_UE=1024 diff --git a/4g-external-ims-deploy.yaml b/4g-external-ims-deploy.yaml index a8131860..48375c88 100644 --- a/4g-external-ims-deploy.yaml +++ b/4g-external-ims-deploy.yaml @@ -1,4 +1,3 @@ -version: '3' services: mongo: image: mongo:6.0 @@ -320,15 +319,23 @@ services: default: ipv4_address: ${METRICS_IP} grafana: - build: ./grafana - image: docker_grafana + image: grafana/grafana:10.1.5 container_name: grafana env_file: - .env volumes: + - grafana_data:/var/lib/grafana + - ./grafana/:/etc/grafana/provisioning/ - ./grafana:/mnt/grafana - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro + environment: + - GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME} + - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD} + #- GF_INSTALL_PLUGINS=${GRAFANA_INSTALL_PLUGINS} + - GF_PATHS_PROVISIONING=/etc/grafana/provisioning + - GF_PATHS_DATA=/var/lib/grafana + - METRICS_IP=${METRICS_IP} expose: - "3000/tcp" ports: @@ -342,5 +349,7 @@ networks: config: - subnet: ${TEST_NETWORK} volumes: + grafana_data: + name: grafana_data mongodbdata: {} - dbdata: {} + dbdata: {} \ No newline at end of file diff --git a/4g-volte-deploy.yaml b/4g-volte-deploy.yaml index ba3fb833..d8d09747 100644 --- a/4g-volte-deploy.yaml +++ b/4g-volte-deploy.yaml @@ -1,4 +1,3 @@ -version: '3' services: mongo: image: mongo:6.0 @@ -456,15 +455,23 @@ services: default: ipv4_address: ${METRICS_IP} grafana: - build: ./grafana - image: docker_grafana + image: grafana/grafana:10.1.5 container_name: grafana env_file: - .env volumes: + - grafana_data:/var/lib/grafana + - ./grafana/:/etc/grafana/provisioning/ - ./grafana:/mnt/grafana - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro + environment: + - GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME} + - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD} + #- GF_INSTALL_PLUGINS=${GRAFANA_INSTALL_PLUGINS} + - GF_PATHS_PROVISIONING=/etc/grafana/provisioning + - GF_PATHS_DATA=/var/lib/grafana + - METRICS_IP=${METRICS_IP} expose: - "3000/tcp" ports: @@ -478,5 +485,7 @@ networks: config: - subnet: ${TEST_NETWORK} volumes: + grafana_data: + name: grafana_data mongodbdata: {} dbdata: {} diff --git a/deploy-all.yaml b/deploy-all.yaml index 2d0cf28e..d922fa79 100644 --- a/deploy-all.yaml +++ b/deploy-all.yaml @@ -1,4 +1,3 @@ -version: '3' services: mongo: image: mongo:6.0 @@ -664,15 +663,23 @@ services: default: ipv4_address: ${METRICS_IP} grafana: - build: ./grafana - image: docker_grafana + image: grafana/grafana:10.1.5 container_name: grafana env_file: - .env volumes: + - grafana_data:/var/lib/grafana + - ./grafana/:/etc/grafana/provisioning/ - ./grafana:/mnt/grafana - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro + environment: + - GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME} + - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD} + #- GF_INSTALL_PLUGINS=${GRAFANA_INSTALL_PLUGINS} + - GF_PATHS_PROVISIONING=/etc/grafana/provisioning + - GF_PATHS_DATA=/var/lib/grafana + - METRICS_IP=${METRICS_IP} expose: - "3000/tcp" ports: @@ -686,5 +693,7 @@ networks: config: - subnet: ${TEST_NETWORK} volumes: + grafana_data: + name: grafana_data mongodbdata: {} dbdata: {} diff --git a/grafana/Dockerfile b/grafana/Dockerfile deleted file mode 100644 index c404910d..00000000 --- a/grafana/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# 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:jammy - -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get update && \ - apt-get install -y --no-install-recommends apt-transport-https software-properties-common wget && \ - mkdir -p /etc/apt/keyrings/ && \ - wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | tee /etc/apt/keyrings/grafana.gpg && \ - echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee -a /etc/apt/sources.list.d/grafana.list && \ - apt-get update && \ - apt-get install -y --no-install-recommends grafana - -CMD /mnt/grafana/grafana_init.sh diff --git a/grafana/open5gs_dashboard.json b/grafana/dashboards/open5gs_dashboard.json similarity index 100% rename from grafana/open5gs_dashboard.json rename to grafana/dashboards/open5gs_dashboard.json diff --git a/grafana/open5gs_dashboard.yml b/grafana/dashboards/open5gs_dashboard.yml similarity index 78% rename from grafana/open5gs_dashboard.yml rename to grafana/dashboards/open5gs_dashboard.yml index 1baef472..8bf7ffce 100644 --- a/grafana/open5gs_dashboard.yml +++ b/grafana/dashboards/open5gs_dashboard.yml @@ -5,4 +5,4 @@ providers: folder: Services # The folder where to place the dashboards type: file options: - path: /var/lib/grafana/dashboards + path: /etc/grafana/provisioning/dashboards diff --git a/grafana/datasources/prometheus_open5gs.yml b/grafana/datasources/prometheus_open5gs.yml new file mode 100644 index 00000000..03b3ac55 --- /dev/null +++ b/grafana/datasources/prometheus_open5gs.yml @@ -0,0 +1,9 @@ +apiVersion: 1 + +datasources: + - name: Open5Gs + type: prometheus + access: proxy + url: http://${METRICS_IP}:9090 + disableDeletion: false + editable: true \ No newline at end of file diff --git a/grafana/grafana_init.sh b/grafana/grafana_init.sh deleted file mode 100755 index 31ddbc3f..00000000 --- a/grafana/grafana_init.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/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 - -export GRAFANA_WORK_DIR=/usr/share/grafana - -cd $GRAFANA_WORK_DIR - -cp /mnt/grafana/prometheus_open5gs.yml ./conf/provisioning/datasources -cp /mnt/grafana/open5gs_dashboard.yml ./conf/provisioning/dashboards -mkdir -p /var/lib/grafana/dashboards -cp /mnt/grafana/open5gs_dashboard.json /var/lib/grafana/dashboards - -sed -i 's|METRICS_IP|'$METRICS_IP'|g' ./conf/provisioning/datasources/prometheus_open5gs.yml - -./bin/grafana server -homepath $GRAFANA_WORK_DIR diff --git a/grafana/prometheus_open5gs.yml b/grafana/prometheus_open5gs.yml deleted file mode 100644 index 646369f9..00000000 --- a/grafana/prometheus_open5gs.yml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: 1 - -datasources: - - name: Open5Gs - type: prometheus - url: http://METRICS_IP:9090 diff --git a/sa-deploy.yaml b/sa-deploy.yaml index ecef706d..6b3139e2 100644 --- a/sa-deploy.yaml +++ b/sa-deploy.yaml @@ -1,4 +1,3 @@ -version: '3' services: mongo: image: mongo:6.0 @@ -305,15 +304,23 @@ services: default: ipv4_address: ${METRICS_IP} grafana: - build: ./grafana - image: docker_grafana + image: grafana/grafana:10.1.5 container_name: grafana env_file: - .env volumes: + - grafana_data:/var/lib/grafana + - ./grafana/:/etc/grafana/provisioning/ - ./grafana:/mnt/grafana - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro + environment: + - GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME} + - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD} + #- GF_INSTALL_PLUGINS=${GRAFANA_INSTALL_PLUGINS} + - GF_PATHS_PROVISIONING=/etc/grafana/provisioning + - GF_PATHS_DATA=/var/lib/grafana + - METRICS_IP=${METRICS_IP} expose: - "3000/tcp" ports: @@ -327,4 +334,6 @@ networks: config: - subnet: ${TEST_NETWORK} volumes: - mongodbdata: {} + grafana_data: + name: grafana_data + mongodbdata: {} \ No newline at end of file diff --git a/sa-vonr-deploy.yaml b/sa-vonr-deploy.yaml index 814880b6..ec234401 100644 --- a/sa-vonr-deploy.yaml +++ b/sa-vonr-deploy.yaml @@ -1,4 +1,3 @@ -version: '3' services: mongo: image: mongo:6.0 @@ -490,15 +489,23 @@ services: default: ipv4_address: ${SMSC_IP} grafana: - build: ./grafana - image: docker_grafana + image: grafana/grafana:10.1.5 container_name: grafana env_file: - .env volumes: + - grafana_data:/var/lib/grafana + - ./grafana/:/etc/grafana/provisioning/ - ./grafana:/mnt/grafana - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro + environment: + - GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME} + - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD} + #- GF_INSTALL_PLUGINS=${GRAFANA_INSTALL_PLUGINS} + - GF_PATHS_PROVISIONING=/etc/grafana/provisioning + - GF_PATHS_DATA=/var/lib/grafana + - METRICS_IP=${METRICS_IP} expose: - "3000/tcp" ports: @@ -512,5 +519,7 @@ networks: config: - subnet: ${TEST_NETWORK} volumes: + grafana_data: + name: grafana_data mongodbdata: {} dbdata: {}