From 8c30544be79616e08ea6a02764002df2163cd655 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 7 Dec 2025 13:50:51 -0600 Subject: [PATCH] attempt loki dashboard --- k8s/loki/Chart.lock | 6 + k8s/monitoring/templates/loki-dashboard.yaml | 183 +++++++++++++++++++ k8s/webrtc-be/.helmignore | 1 + scripts/deploy.sh | 72 ++++++++ scripts/helm-update-monitoring-stg | 2 + 5 files changed, 264 insertions(+) create mode 100644 k8s/loki/Chart.lock create mode 100644 k8s/monitoring/templates/loki-dashboard.yaml create mode 100644 k8s/webrtc-be/.helmignore create mode 100755 scripts/deploy.sh create mode 100755 scripts/helm-update-monitoring-stg diff --git a/k8s/loki/Chart.lock b/k8s/loki/Chart.lock new file mode 100644 index 0000000..dda93fc --- /dev/null +++ b/k8s/loki/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: loki + repository: https://grafana.github.io/helm-charts + version: 5.42.0 +digest: sha256:34be6df7db0ab68667bf53c60f1a4788e02f2865d979fba2bca35ff362dc7d1b +generated: "2025-12-06T18:43:16.062019-06:00" diff --git a/k8s/monitoring/templates/loki-dashboard.yaml b/k8s/monitoring/templates/loki-dashboard.yaml new file mode 100644 index 0000000..2790fba --- /dev/null +++ b/k8s/monitoring/templates/loki-dashboard.yaml @@ -0,0 +1,183 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: loki-verification-dashboard + labels: + grafana_dashboard: "1" +data: + loki-verification.json: | + { + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "editorMode": "builder", + "expr": "sum(count_over_time({job=~\".+\"}[1m]))", + "legendFormat": "", + "queryType": "range", + "refId": "A" + } + ], + "title": "Log Volume", + "type": "timeseries" + }, + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "gridPos": { + "h": 16, + "w": 24, + "x": 0, + "y": 8 + }, + "id": 1, + "options": { + "dedupStrategy": "none", + "enableLogDetails": true, + "prettifyLogMessage": false, + "showCommonLabels": false, + "showLabels": false, + "showTime": true, + "sortOrder": "Descending", + "wrapLogMessage": false + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "editorMode": "builder", + "expr": "{job=~\".+\"}", + "queryType": "range", + "refId": "A" + } + ], + "title": "Logs", + "type": "logs" + } + ], + "refresh": "", + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Loki Verification", + "uid": "loki-verification", + "version": 0, + "weekStart": "" + } diff --git a/k8s/webrtc-be/.helmignore b/k8s/webrtc-be/.helmignore new file mode 100644 index 0000000..5132498 --- /dev/null +++ b/k8s/webrtc-be/.helmignore @@ -0,0 +1 @@ +templates/alerts.yaml diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..57b8ac8 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,72 @@ +#!/bin/bash +set -e + +ENVIRONMENT=$1 + +if [ -z "$ENVIRONMENT" ]; then + echo "Usage: $0 " + exit 1 +fi + +if [ "$ENVIRONMENT" == "staging" ]; then + echo "Deploying to STAGING..." + + # Source activation script + if [ -f ~/bin/activate_stg ]; then + source ~/bin/activate_stg + else + echo "Error: ~/bin/activate_stg not found." + exit 1 + fi + + # Set BITBUCKET_BRANCH + export BITBUCKET_BRANCH=$(git rev-parse --abbrev-ref HEAD) + if [ -z "$BITBUCKET_BRANCH" ]; then + export BITBUCKET_BRANCH="develop" + fi + echo "Using branch: $BITBUCKET_BRANCH" + + # Template argocd/base/applications.yaml + echo "Templating k8s/argocd/base/applications.yaml..." + envsubst < k8s/argocd/base/applications.yaml > k8s/argocd/base/applications.yaml.tmp + mv k8s/argocd/base/applications.yaml.tmp k8s/argocd/base/applications.yaml + + # Apply Kustomize + echo "Applying Kustomize for staging..." + kubectl -n argocd apply -k k8s/argocd/overlays/staging + + # Rollout restarts + echo "Restarting coturn deployments..." + kubectl -n coturn rollout restart deployment/coturn + kubectl -n coturn rollout status -w deployment/coturn + kubectl -n coturn-dns rollout restart deployment/coturn-dns + kubectl -n coturn-dns rollout status -w deployment/coturn-dns + +elif [ "$ENVIRONMENT" == "production" ]; then + echo "Deploying to PRODUCTION..." + + # Source activation script + if [ -f ~/bin/activate_prd ]; then + source ~/bin/activate_prd + else + echo "Error: ~/bin/activate_prd not found." + exit 1 + fi + + # Apply Kustomize + echo "Applying Kustomize for production..." + kubectl -n argocd apply -k k8s/argocd/overlays/production + + # Rollout restarts + echo "Restarting coturn deployments..." + kubectl -n coturn rollout restart deployment/coturn + kubectl -n coturn rollout status -w deployment/coturn + kubectl -n coturn-dns rollout restart deployment/coturn-dns + kubectl -n coturn-dns rollout status -w deployment/coturn-dns + +else + echo "Invalid environment: $ENVIRONMENT. Must be 'staging' or 'production'." + exit 1 +fi + +echo "Deployment complete!" diff --git a/scripts/helm-update-monitoring-stg b/scripts/helm-update-monitoring-stg new file mode 100755 index 0000000..f2c0fa9 --- /dev/null +++ b/scripts/helm-update-monitoring-stg @@ -0,0 +1,2 @@ +# run in k8s/monitoring folder +helm upgrade monitoring . --namespace monitoring -f values-staging.yaml