Repository: Only-Smiles/DevOps-2025
Pull request #163: 147 high cpu usage and basis for monitoring
Author: login: chrisaftzidis
Created: 2025-04-11T11:18:21Z | Merged: 2025-04-11T11:59:18Z

Added a limit in the docker compose file to the cpu usage of prometheus. Minor improvements to dashboard but I can't put all visualisations in until it's up and running


Diff:
diff --git a/dev-compose.yml b/dev-compose.yml
index e6c7ec1..11935c9 100644
--- a/dev-compose.yml
+++ b/dev-compose.yml
@@ -46,11 +46,14 @@ services:
     container_name: prometheus
     volumes:
       - ./prometheus.yml:/etc/prometheus/prometheus.yml
-    ports:
-      - "9090:9090"
+    expose: 
+      - "9090"
     networks:
       - main
-
+    deploy:
+      resources:
+        limits:
+          cpus: '0.2'
 
   grafana:
     image: grafana/grafana:11.5.2
diff --git a/images/Dockerfile.test b/images/Dockerfile.test
index 23ba788..239df6e 100644
--- a/images/Dockerfile.test
+++ b/images/Dockerfile.test
@@ -2,10 +2,10 @@ FROM python:3.13-alpine
 
 # Install Firefox and required tools using apk
 RUN apk add --no-cache \
-    firefox-esr=128.8.0-r0 \
+    firefox-esr='128.9.0-r0' \
     tar=1.35-r2 \
     wget=1.25.0-r0 \
-# Download and install the latest geckodriver (recommended version for Firefox 136.0.1)
+    # Download and install the latest geckodriver (recommended version for Firefox 136.0.1)
     && wget -nv https://github.com/mozilla/geckodriver/releases/download/v0.36.0/geckodriver-v0.36.0-linux64.tar.gz && \
     tar -xzf geckodriver-v0.36.0-linux64.tar.gz && \
     mv geckodriver /usr/local/bin/ && \
diff --git a/remote_files/compose.yml b/remote_files/compose.yml
index 55af335..6f31a2e 100644
--- a/remote_files/compose.yml
+++ b/remote_files/compose.yml
@@ -43,10 +43,14 @@ services:
     container_name: prometheus
     volumes:
       - ./prometheus.yml:/etc/prometheus/prometheus.yml
-    ports:
-      - "9090:9090"
+    expose:
+      - "9090"
     networks:
       - main
+    deploy:
+      resources:
+        limits:
+          cpus: '0.2'
 
   grafana:
     image: grafana/grafana:11.5.2
diff --git a/remote_files/grafana/dashboards/dashboard-minitwit.json b/remote_files/grafana/dashboards/dashboard-minitwit.json
index e1a58bf..2d55ad2 100644
--- a/remote_files/grafana/dashboards/dashboard-minitwit.json
+++ b/remote_files/grafana/dashboards/dashboard-minitwit.json
@@ -18,31 +18,55 @@
     "editable": true,
     "fiscalYearStartMonth": 0,
     "graphTooltip": 0,
-    "id": 1,
+    "id": 2,
     "links": [],
     "panels": [
         {
-            "datasource": "Prometheus",
+            "datasource": {
+                "type": "prometheus",
+                "uid": "PBFA97CFB590B2093"
+            },
             "fieldConfig": {
                 "defaults": {
                     "color": {
-                        "mode": "thresholds"
+                        "mode": "palette-classic"
                     },
                     "custom": {
-                        "fillOpacity": 70,
+                        "axisBorderShow": false,
+                        "axisCenteredZero": false,
+                        "axisColorMode": "text",
+                        "axisLabel": "",
+                        "axisPlacement": "auto",
+                        "barAlignment": 0,
+                        "barWidthFactor": 0.6,
+                        "drawStyle": "line",
+                        "fillOpacity": 0,
+                        "gradientMode": "none",
                         "hideFrom": {
                             "legend": false,
                             "tooltip": false,
                             "viz": false
                         },
                         "insertNulls": false,
-                        "lineWidth": 0,
-                        "spanNulls": false
+                        "lineInterpolation": "linear",
+                        "lineWidth": 1,
+                        "pointSize": 5,
+                        "scaleDistribution": {
+                            "type": "linear"
+                        },
+                        "showPoints": "auto",
+                        "spanNulls": false,
+                        "stacking": {
+                            "group": "A",
+                            "mode": "none"
+                        },
+                        "thresholdsStyle": {
+                            "mode": "off"
+                        }
                     },
-                    "displayName": "minitwit",
                     "mappings": [],
                     "thresholds": {
-                        "mode": "percentage",
+                        "mode": "absolute",
                         "steps": [
                             {
                                 "color": "green",
@@ -63,17 +87,14 @@
                 "x": 0,
                 "y": 0
             },
-            "id": 2,
+            "id": 3,
             "options": {
-                "alignValue": "center",
                 "legend": {
+                    "calcs": [],
                     "displayMode": "list",
                     "placement": "bottom",
                     "showLegend": true
                 },
-                "mergeValues": true,
-                "rowHeight": 1,
-                "showValue": "auto",
                 "tooltip": {
                     "hideZeros": false,
                     "mode": "single",
@@ -83,20 +104,15 @@
             "pluginVersion": "11.5.2",
             "targets": [
                 {
-                    "disableTextWrap": false,
-                    "editorMode": "builder",
-                    "exemplar": false,
-                    "expr": "up{instance=\"minitwit:4567\"}",
-                    "fullMetaSearch": false,
-                    "includeNullMetadata": true,
+                    "editorMode": "code",
+                    "expr": "100* (sum(http_server_requests_total) by (code)/ on() group_left() sum(http_server_requests_total))",
                     "legendFormat": "__auto",
                     "range": true,
-                    "refId": "A",
-                    "useBackend": false
+                    "refId": "A"
                 }
             ],
-            "title": "Website Uptime",
-            "type": "state-timeline"
+            "title": "Return Codes [%]",
+            "type": "timeseries"
         },
         {
             "datasource": "Prometheus",
@@ -206,6 +222,83 @@
             ],
             "title": "Cumulative Requests",
             "type": "timeseries"
+        },
+        {
+            "datasource": "Prometheus",
+            "fieldConfig": {
+                "defaults": {
+                    "color": {
+                        "mode": "thresholds"
+                    },
+                    "custom": {
+                        "fillOpacity": 70,
+                        "hideFrom": {
+                            "legend": false,
+                            "tooltip": false,
+                            "viz": false
+                        },
+                        "insertNulls": false,
+                        "lineWidth": 0,
+                        "spanNulls": false
+                    },
+                    "displayName": "minitwit",
+                    "mappings": [],
+                    "thresholds": {
+                        "mode": "percentage",
+                        "steps": [
+                            {
+                                "color": "green",
+                                "value": null
+                            },
+                            {
+                                "color": "red",
+                                "value": 80
+                            }
+                        ]
+                    }
+                },
+                "overrides": []
+            },
+            "gridPos": {
+                "h": 8,
+                "w": 12,
+                "x": 0,
+                "y": 8
+            },
+            "id": 2,
+            "options": {
+                "alignValue": "center",
+                "legend": {
+                    "displayMode": "list",
+                    "placement": "bottom",
+                    "showLegend": true
+                },
+                "mergeValues": true,
+                "rowHeight": 1,
+                "showValue": "auto",
+                "tooltip": {
+                    "hideZeros": false,
+                    "mode": "single",
+                    "sort": "none"
+                }
+            },
+            "pluginVersion": "11.5.2",
+            "targets": [
+                {
+                    "disableTextWrap": false,
+                    "editorMode": "builder",
+                    "exemplar": false,
+                    "expr": "up{instance=\"minitwit:4567\"}",
+                    "fullMetaSearch": false,
+                    "includeNullMetadata": true,
+                    "legendFormat": "__auto",
+                    "range": true,
+                    "refId": "A",
+                    "useBackend": false
+                }
+            ],
+            "title": "Website Uptime",
+            "type": "state-timeline"
         }
     ],
     "preload": false,
@@ -216,13 +309,13 @@
         "list": []
     },
     "time": {
-        "from": "2025-03-21T05:31:03.761Z",
-        "to": "2025-03-21T07:22:11.943Z"
+        "from": "now-15m",
+        "to": "now"
     },
     "timepicker": {},
     "timezone": "browser",
     "title": "Minitwit System",
     "uid": "eeghjjvdaqcjkd",
-    "version": 7,
+    "version": 6,
     "weekStart": ""
 }
\ No newline at end of file


Reviews:
user: login: DumbDane
state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-04-11T11:41:54Z
user: login: DumbDane
body: lgtm
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-11T11:59:06Z

Review comments:
diff_hunk: @@ -46,11 +46,13 @@ services:
     container_name: prometheus
     volumes:
       - ./prometheus.yml:/etc/prometheus/prometheus.yml
-    ports:
-      - "9090:9090"
+    expose: ["9090"]
path: dev-compose.yml
user: login: DumbDane
body: nitpick, can we move this to it's own line
expose:
  - "9090"
created_at: 2025-04-11T11:40:01Z
author_association: COLLABORATOR
diff_hunk: @@ -43,10 +43,13 @@ services:
     container_name: prometheus
     volumes:
       - ./prometheus.yml:/etc/prometheus/prometheus.yml
-    ports:
-      - "9090:9090"
+    expose: [ "9090" ]
path: remote_files/compose.yml
user: login: DumbDane
body: same as above
created_at: 2025-04-11T11:41:31Z
author_association: COLLABORATOR

PR comments:
user: login: sonarqubecloud[bot]
created_at: 2025-04-11T11:44:40Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=Only-Smiles_DevOps-2025&pullRequest=163) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=Only-Smiles_DevOps-2025&pullRequest=163&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=Only-Smiles_DevOps-2025&pullRequest=163&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=Only-Smiles_DevOps-2025&pullRequest=163&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=Only-Smiles_DevOps-2025&pullRequest=163&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=Only-Smiles_DevOps-2025&pullRequest=163&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=Only-Smiles_DevOps-2025&pullRequest=163)


author_association: NONE