From 043a1b6ffa9779b577e220cfe22aa92d8c146ac0 Mon Sep 17 00:00:00 2001 From: Bart van der Braak Date: Tue, 26 Nov 2024 17:16:21 +0100 Subject: [PATCH] Add Prometheus metrics to Buildbot --- Dockerfile | 11 ++++++++ buildbot/config/setup.py | 59 +++++++++++++++++++++++----------------- docker-compose.yml | 11 +++++++- prometheus.yml | 7 +++++ provision/local/main.tf | 49 +++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 26 deletions(-) create mode 100644 Dockerfile create mode 100644 prometheus.yml create mode 100644 provision/local/main.tf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..031e625 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +# Use the published buildbot/buildbot-master image as the base +FROM buildbot/buildbot-master:master + +# Install buildbot-prometheus in the existing virtual environment +RUN /buildbot_venv/bin/pip3 install buildbot-prometheus + +# Set the working directory to where the buildbot files are expected +WORKDIR /buildbot + +# Keep the existing command to start buildbot +CMD ["dumb-init", "/usr/src/buildbot/start_buildbot.sh"] diff --git a/buildbot/config/setup.py b/buildbot/config/setup.py index 2aefd08..fc15bd1 100644 --- a/buildbot/config/setup.py +++ b/buildbot/config/setup.py @@ -85,6 +85,12 @@ def setup() -> Dict[str, Any]: else: c["services"] = [] + c["services"].append( + buildbot.plugins.reporters.Prometheus( + port=int(os.environ.get("BUILDBOT_PROMETHEUS_PORT", default=9100)) + ) + ) + ####### PROJECT IDENTITY # the 'title' string will appear at the top of this buildbot installation's @@ -99,31 +105,41 @@ def setup() -> Dict[str, Any]: # buildbot cannot figure out without some help. c["buildbotURL"] = os.environ.get("BUILDBOT_WEB_URL", "http://localhost:8010/") - # Minimalistic config to activate new web UI - c["www"] = dict( - port=os.environ.get("BUILDBOT_WEB_PORT", 8010), - plugins=dict(waterfall_view={}, console_view={}, grid_view={}), - theme={ - "bb-sidebar-background-color": "#1F2226", # Eerie Black 2 - "bb-sidebar-header-background-color": "#202327", # Eerie Black - "bb-sidebar-header-text-color": "#9fa3a8", # Dim Gray (Lighter gray for text) - "bb-sidebar-title-text-color": "#9fa3a8", # Dim Gray (Titles) - "bb-sidebar-footer-background-color": "#292d32", # Jet - "bb-sidebar-button-text-color": "#9fa3a8", # Dim Gray (Button text) - "bb-sidebar-button-hover-background-color": "#292d32", # Jet (Button hover background) - "bb-sidebar-button-hover-text-color": "#3dabf5", # Light blue for hover text - "bb-sidebar-button-current-background-color": "#292d32", # Jet (Current button background) - "bb-sidebar-button-current-text-color": "#3dabf5", # Light blue for current button text - "bb-sidebar-stripe-hover-color": "#3695D5", # Celestial Blue - "bb-sidebar-stripe-current-color": "#084F7E", # Indigo Dye - }, + # Initialize + c["www"] = {} + + # Port + c["www"]["port"] = os.environ.get("BUILDBOT_WEB_PORT", 8010) + + # Plugins + c["www"]["plugins"] = dict( + waterfall_view={}, + console_view={}, + grid_view={}, ) + # Theme + c["www"]["theme"] = { + "bb-sidebar-background-color": "#1F2226", # Eerie Black 2 + "bb-sidebar-header-background-color": "#202327", # Eerie Black + "bb-sidebar-header-text-color": "#9fa3a8", # Dim Gray (Lighter gray for text) + "bb-sidebar-title-text-color": "#9fa3a8", # Dim Gray (Titles) + "bb-sidebar-footer-background-color": "#292d32", # Jet + "bb-sidebar-button-text-color": "#9fa3a8", # Dim Gray (Button text) + "bb-sidebar-button-hover-background-color": "#292d32", # Jet (Button hover background) + "bb-sidebar-button-hover-text-color": "#3dabf5", # Light blue for hover text + "bb-sidebar-button-current-background-color": "#292d32", # Jet (Current button background) + "bb-sidebar-button-current-text-color": "#3dabf5", # Light blue for current button text + "bb-sidebar-stripe-hover-color": "#3695D5", # Celestial Blue + "bb-sidebar-stripe-current-color": "#084F7E", # Indigo Dye + } + # Database c["db"] = { "db_url": os.environ.get("BUILDBOT_DB_URL", "sqlite://").format(**os.environ) } + # Share usage data c["buildbotNetUsageData"] = None # Authentication @@ -132,13 +148,6 @@ def setup() -> Dict[str, Any]: # Authorization c["www"]["authz"] = conf.auth.fetch_authorization(environment) - # Disable UI - does not work - c["www"]["plugins"] = { - "waterfall_view": False, - "console_view": False, - "grid_view": False, - } - # UI Defaults c["www"]["ui_default_config"] = { "Grid.fullChanges": True, diff --git a/docker-compose.yml b/docker-compose.yml index b2dfb0b..fa67f08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,8 @@ services: buildbot-master: - image: 'buildbot/buildbot-master:${BUILDBOT_IMAGE_TAG:-v4.1.0}' + # image: 'buildbot/buildbot-master:${BUILDBOT_IMAGE_TAG:-v4.1.0}' + build: + context: . env_file: .env hostname: buildbot-master restart: unless-stopped @@ -16,6 +18,7 @@ services: - 'POSTGRES_USER=${POSTGRES_USER:-buildbot}' - 'POSTGRES_DB=${POSTGRES_DB:-buildbot}' - 'BUILDBOT_DB_URL=postgresql+psycopg2://{POSTGRES_USER}:{POSTGRES_PASSWORD}@postgresql/{POSTGRES_DB}' + - 'BUILDBOT_PROMETHEUS_PORT=9100' healthcheck: test: - CMD @@ -72,6 +75,12 @@ services: retries: 10 networks: buildbot: null + prometheus: + image: prom/prometheus + volumes: + - './prometheus.yml:/etc/prometheus/prometheus.yml' + ports: + - '9090:9090' volumes: buildbot-db: {} networks: diff --git a/prometheus.yml b/prometheus.yml new file mode 100644 index 0000000..eba9cea --- /dev/null +++ b/prometheus.yml @@ -0,0 +1,7 @@ +global: + scrape_interval: 60s +scrape_configs: + - job_name: buildbot + static_configs: + - targets: + - buildbot-master:9100 \ No newline at end of file diff --git a/provision/local/main.tf b/provision/local/main.tf new file mode 100644 index 0000000..e9355dd --- /dev/null +++ b/provision/local/main.tf @@ -0,0 +1,49 @@ +terraform { + required_providers { + libvirt = { + source = "dmacvicar/libvirt" + } + } +} + +provider "libvirt" { + uri = "qemu:///system" +} + +resource "libvirt_volume" "win11-ltsc-cloudbase-init" { + name = "win11-ltsc-cloudbase-init.qcow2" + pool = "default" # List storage pools using virsh pool-list + source = "win11-ltsc-original.qcow2" + format = "qcow2" +} + +resource "libvirt_domain" "win11-ltsc-cloudbase-init" { + name = "win11-ltsc-cloudbase-init" + memory = "8192" + vcpu = 4 + + network_interface { + network_name = "default" # List networks with virsh net-list + } + + disk { + volume_id = "${libvirt_volume.win11-ltsc-cloudbase-init.id}" + } + + console { + type = "pty" + target_type = "serial" + target_port = "0" + } + + graphics { + type = "spice" + listen_type = "address" + autoport = true + } +} + +# Output Server IP +output "ip" { + value = "${libvirt_domain.centos7.network_interface.0.addresses.0}" +} \ No newline at end of file