From 331bfbe562067744debccdb57118fd38bafba0a3 Mon Sep 17 00:00:00 2001 From: Josef Date: Tue, 16 Apr 2024 20:02:03 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20script=20not=20working=20in=20docker=20co?= =?UTF-8?q?ntainer,=20added=20debug=20option,=20lint=20=E2=80=A6=20(#24)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Josef Hofer --- .github/workflows/rolling.yaml | 17 +- Dockerfile | 3 +- examples/prometheus.md | 10 + examples/simple-grafana-dash.json | 1149 +++++++++++++++++++++++++++++ intel-gpu-exporter.py | 189 +++-- 5 files changed, 1305 insertions(+), 63 deletions(-) create mode 100644 examples/prometheus.md create mode 100644 examples/simple-grafana-dash.json diff --git a/.github/workflows/rolling.yaml b/.github/workflows/rolling.yaml index 10ee5c8..5d62336 100644 --- a/.github/workflows/rolling.yaml +++ b/.github/workflows/rolling.yaml @@ -1,9 +1,8 @@ ---- name: rolling on: push: - branches: ["main"] + branches: ["main", "dev"] jobs: build: @@ -26,7 +25,8 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and Push + - name: Build and Push (main) + if: github.ref == 'refs/heads/main' uses: docker/build-push-action@v5 with: context: . @@ -35,3 +35,14 @@ jobs: push: true tags: | ghcr.io/${{ github.repository }}:rolling + + - name: Build and Push (dev) + if: github.ref == 'refs/heads/dev' + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: | + ghcr.io/${{ github.repository }}:rolling-dev diff --git a/Dockerfile b/Dockerfile index 61f8d44..d66971c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,8 @@ ENV \ PIP_ROOT_USER_ACTION=ignore \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ - PIP_BREAK_SYSTEM_PACKAGES=1 + PIP_BREAK_SYSTEM_PACKAGES=1 \ + IS_DOCKER=True WORKDIR /app diff --git a/examples/prometheus.md b/examples/prometheus.md new file mode 100644 index 0000000..d9c8c82 --- /dev/null +++ b/examples/prometheus.md @@ -0,0 +1,10 @@ +# Prometheus config example + +```yaml +scrape_configs: + - job_name: "intel-gpu_exporter" + scrape_interval: 5s ## Change this to the same value as REFRESH_PERIOD_MS (or remove this line) + static_configs: + - targets: + - "cloud.host.example.local:8080" +``` diff --git a/examples/simple-grafana-dash.json b/examples/simple-grafana-dash.json new file mode 100644 index 0000000..df86649 --- /dev/null +++ b/examples/simple-grafana-dash.json @@ -0,0 +1,1149 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 2, + "id": 15, + "links": [ + { + "asDropdown": true, + "icon": "external link", + "includeVars": false, + "keepTime": false, + "tags": [ + "transcoding_user" + ], + "targetBlank": false, + "title": "Services", + "tooltip": "", + "type": "dashboards", + "url": "" + } + ], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_render_3d_0_busy{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_render_3d_0_sema{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_render_3d_0_wait{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "C" + } + ], + "title": "Render 3D", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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 + } + ] + }, + "unit": "percent" + }, + "overrides": [ + { + "__systemRef": "hideSeriesFrom", + "matcher": { + "id": "byNames", + "options": { + "mode": "exclude", + "names": [ + "igpu_engines_blitter_0_busy" + ], + "prefix": "All except:", + "readOnly": true + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": false, + "tooltip": false, + "viz": true + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 7, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_blitter_0_busy{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_blitter_0_sema{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_blitter_0_wait{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "C" + } + ], + "title": "Blitter", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 8 + }, + "id": 8, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_video_0_busy{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_video_0_sema{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_video_0_wait{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "C" + } + ], + "title": "Video", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 8 + }, + "id": 9, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_video_enhance_0_busy{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_video_enhance_0_sema{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_engines_video_enhance_0_wait{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "C" + } + ], + "title": "Video enhance", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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 + } + ] + }, + "unit": "rotmhz" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 16 + }, + "id": 10, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_frequency_actual{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_frequency_requested{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B" + } + ], + "title": "Frequency", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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 + } + ] + }, + "unit": "MiBs" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 16 + }, + "id": 11, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_imc_bandwidth_reads{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_imc_bandwidth_writes{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B" + } + ], + "title": "Bandwith", + "type": "timeseries" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 4, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "watt" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 25 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_power_package{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_power_gpu{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B" + } + ], + "title": "iGPU Power", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "igpu_rc6" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "igpu_interrupts" + }, + "properties": [ + { + "id": "unit", + "value": "recps" + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 12, + "y": 25 + }, + "id": 3, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_rc6{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_interrupts{instance=~\"${Instance}\"}", + "hide": false, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "C" + } + ], + "title": "R6 & Interrupts ", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green" + }, + { + "color": "orange", + "value": 70 + }, + { + "color": "red", + "value": 85 + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 20, + "y": 25 + }, + "id": 12, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "editorMode": "code", + "expr": "igpu_period{instance=~\"${Instance}\"}", + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Period", + "type": "stat" + } + ], + "title": "Misc", + "type": "row" + } + ], + "refresh": "5s", + "schemaVersion": 39, + "tags": [ + "igpu", + "intel", + "transcoding" + ], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "cloud.host.jhofer.local:8081", + "value": "cloud.host.jhofer.local:8081" + }, + "datasource": { + "type": "prometheus", + "uid": "f9422c25-b9ee-4376-8bd2-6a67029728ce" + }, + "definition": "label_values({job=\"intel-gpu_exporter\"},instance)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "Instance", + "options": [], + "query": { + "qryType": 1, + "query": "label_values({job=\"intel-gpu_exporter\"},instance)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-12h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Intel iGPU", + "uid": "ddittat0n2i9se", + "version": 9, + "weekStart": "" +} diff --git a/intel-gpu-exporter.py b/intel-gpu-exporter.py index 6132233..6acc40e 100644 --- a/intel-gpu-exporter.py +++ b/intel-gpu-exporter.py @@ -5,53 +5,102 @@ import json import logging -igpu_engines_blitter_0_busy = Gauge('igpu_engines_blitter_0_busy', 'Blitter 0 busy utilisation %') -igpu_engines_blitter_0_sema = Gauge('igpu_engines_blitter_0_sema', 'Blitter 0 sema utilisation %') -igpu_engines_blitter_0_wait = Gauge('igpu_engines_blitter_0_wait', 'Blitter 0 wait utilisation %') +igpu_engines_blitter_0_busy = Gauge( + "igpu_engines_blitter_0_busy", "Blitter 0 busy utilisation %" +) +igpu_engines_blitter_0_sema = Gauge( + "igpu_engines_blitter_0_sema", "Blitter 0 sema utilisation %" +) +igpu_engines_blitter_0_wait = Gauge( + "igpu_engines_blitter_0_wait", "Blitter 0 wait utilisation %" +) + +igpu_engines_render_3d_0_busy = Gauge( + "igpu_engines_render_3d_0_busy", "Render 3D 0 busy utilisation %" +) +igpu_engines_render_3d_0_sema = Gauge( + "igpu_engines_render_3d_0_sema", "Render 3D 0 sema utilisation %" +) +igpu_engines_render_3d_0_wait = Gauge( + "igpu_engines_render_3d_0_wait", "Render 3D 0 wait utilisation %" +) + +igpu_engines_video_0_busy = Gauge( + "igpu_engines_video_0_busy", "Video 0 busy utilisation %" +) +igpu_engines_video_0_sema = Gauge( + "igpu_engines_video_0_sema", "Video 0 sema utilisation %" +) +igpu_engines_video_0_wait = Gauge( + "igpu_engines_video_0_wait", "Video 0 wait utilisation %" +) + +igpu_engines_video_enhance_0_busy = Gauge( + "igpu_engines_video_enhance_0_busy", "Video Enhance 0 busy utilisation %" +) +igpu_engines_video_enhance_0_sema = Gauge( + "igpu_engines_video_enhance_0_sema", "Video Enhance 0 sema utilisation %" +) +igpu_engines_video_enhance_0_wait = Gauge( + "igpu_engines_video_enhance_0_wait", "Video Enhance 0 wait utilisation %" +) + +igpu_frequency_actual = Gauge("igpu_frequency_actual", "Frequency actual MHz") +igpu_frequency_requested = Gauge("igpu_frequency_requested", "Frequency requested MHz") + +igpu_imc_bandwidth_reads = Gauge("igpu_imc_bandwidth_reads", "IMC reads MiB/s") +igpu_imc_bandwidth_writes = Gauge("igpu_imc_bandwidth_writes", "IMC writes MiB/s") + +igpu_interrupts = Gauge("igpu_interrupts", "Interrupts/s") + +igpu_period = Gauge("igpu_period", "Period ms") + +igpu_power_gpu = Gauge("igpu_power_gpu", "GPU power W") +igpu_power_package = Gauge("igpu_power_package", "Package power W") + +igpu_rc6 = Gauge("igpu_rc6", "RC6 %") -igpu_engines_render_3d_0_busy = Gauge('igpu_engines_render_3d_0_busy', 'Render 3D 0 busy utilisation %') -igpu_engines_render_3d_0_sema = Gauge('igpu_engines_render_3d_0_sema', 'Render 3D 0 sema utilisation %') -igpu_engines_render_3d_0_wait = Gauge('igpu_engines_render_3d_0_wait', 'Render 3D 0 wait utilisation %') - -igpu_engines_video_0_busy = Gauge('igpu_engines_video_0_busy', 'Video 0 busy utilisation %') -igpu_engines_video_0_sema = Gauge('igpu_engines_video_0_sema', 'Video 0 sema utilisation %') -igpu_engines_video_0_wait = Gauge('igpu_engines_video_0_wait', 'Video 0 wait utilisation %') - -igpu_engines_video_enhance_0_busy = Gauge('igpu_engines_video_enhance_0_busy', 'Video Enhance 0 busy utilisation %') -igpu_engines_video_enhance_0_sema = Gauge('igpu_engines_video_enhance_0_sema', 'Video Enhance 0 sema utilisation %') -igpu_engines_video_enhance_0_wait = Gauge('igpu_engines_video_enhance_0_wait', 'Video Enhance 0 wait utilisation %') - -igpu_frequency_actual = Gauge('igpu_frequency_actual', 'Frequency actual MHz') -igpu_frequency_requested = Gauge('igpu_frequency_requested', 'Frequency requested MHz') - -igpu_imc_bandwidth_reads = Gauge('igpu_imc_bandwidth_reads', 'IMC reads MiB/s') -igpu_imc_bandwidth_writes = Gauge('igpu_imc_bandwidth_writes', 'IMC writes MiB/s') - -igpu_interrupts = Gauge('igpu_interrupts', 'Interrupts/s') - -igpu_period = Gauge('igpu_period', 'Period ms') - -igpu_power_gpu = Gauge('igpu_power_gpu', 'GPU power W') -igpu_power_package = Gauge('igpu_power_package', 'Package power W') - -igpu_rc6 = Gauge('igpu_rc6', 'RC6 %') def update(data): - igpu_engines_blitter_0_busy.set(data.get("engines", {}).get("Blitter/0", {}).get("busy", 0.0)) - igpu_engines_blitter_0_sema.set(data.get("engines", {}).get("Blitter/0", {}).get("sema", 0.0)) - igpu_engines_blitter_0_wait.set(data.get("engines", {}).get("Blitter/0", {}).get("wait", 0.0)) - - igpu_engines_render_3d_0_busy.set(data.get("engines", {}).get("Render/3D/0", {}).get("busy", 0.0)) - igpu_engines_render_3d_0_sema.set(data.get("engines", {}).get("Render/3D/0", {}).get("sema", 0.0)) - igpu_engines_render_3d_0_wait.set(data.get("engines", {}).get("Render/3D/0", {}).get("wait", 0.0)) - - igpu_engines_video_0_busy.set(data.get("engines", {}).get("Video/0", {}).get("busy", 0.0)) - igpu_engines_video_0_sema.set(data.get("engines", {}).get("Video/0", {}).get("sema", 0.0)) - igpu_engines_video_0_wait.set(data.get("engines", {}).get("Video/0", {}).get("wait", 0.0)) - - igpu_engines_video_enhance_0_busy.set(data.get("engines", {}).get("VideoEnhance/0", {}).get("busy", 0.0)) - igpu_engines_video_enhance_0_sema.set(data.get("engines", {}).get("VideoEnhance/0", {}).get("sema", 0.0)) - igpu_engines_video_enhance_0_wait.set(data.get("engines", {}).get("VideoEnhance/0", {}).get("wait", 0.0)) + igpu_engines_blitter_0_busy.set( + data.get("engines", {}).get("Blitter/0", {}).get("busy", 0.0) + ) + igpu_engines_blitter_0_sema.set( + data.get("engines", {}).get("Blitter/0", {}).get("sema", 0.0) + ) + igpu_engines_blitter_0_wait.set( + data.get("engines", {}).get("Blitter/0", {}).get("wait", 0.0) + ) + + igpu_engines_render_3d_0_busy.set( + data.get("engines", {}).get("Render/3D/0", {}).get("busy", 0.0) + ) + igpu_engines_render_3d_0_sema.set( + data.get("engines", {}).get("Render/3D/0", {}).get("sema", 0.0) + ) + igpu_engines_render_3d_0_wait.set( + data.get("engines", {}).get("Render/3D/0", {}).get("wait", 0.0) + ) + + igpu_engines_video_0_busy.set( + data.get("engines", {}).get("Video/0", {}).get("busy", 0.0) + ) + igpu_engines_video_0_sema.set( + data.get("engines", {}).get("Video/0", {}).get("sema", 0.0) + ) + igpu_engines_video_0_wait.set( + data.get("engines", {}).get("Video/0", {}).get("wait", 0.0) + ) + + igpu_engines_video_enhance_0_busy.set( + data.get("engines", {}).get("VideoEnhance/0", {}).get("busy", 0.0) + ) + igpu_engines_video_enhance_0_sema.set( + data.get("engines", {}).get("VideoEnhance/0", {}).get("sema", 0.0) + ) + igpu_engines_video_enhance_0_wait.set( + data.get("engines", {}).get("VideoEnhance/0", {}).get("wait", 0.0) + ) igpu_frequency_actual.set(data.get("frequency", {}).get("actual", 0)) igpu_frequency_requested.set(data.get("frequency", {}).get("requested", 0)) @@ -68,28 +117,50 @@ def update(data): igpu_rc6.set(data.get("rc6", {}).get("value", 0)) -if __name__ == '__main__': - logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) - start_http_server(8080) - period = os.getenv("REFRESH_PERIOD_MS", 10000) +if __name__ == "__main__": + if os.getenv("DEBUG", False): + debug = logging.DEBUG + else: + debug = logging.INFO + logging.basicConfig(format="%(asctime)s - %(message)s", level=debug) - cmd = 'intel_gpu_top -J -s {}'.format(int(period)) - process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + start_http_server(8080) - logging.info('Started ' + cmd) - output = '' + period = os.getenv("REFRESH_PERIOD_MS", 10000) - while process.poll() is None: - read = process.stdout.readline() - output+=read.decode('utf-8') - if read == b'},\n': - update(json.loads(output[:-2])) - output = '' + cmd = "intel_gpu_top -J -s {}".format(int(period)) + process = subprocess.Popen( + cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + + logging.info("Started " + cmd) + output = "" + + if os.getenv("IS_DOCKER", False): + for line in process.stdout: + line = line.decode("utf-8").strip() + output += line + + try: + data = json.loads(output) + logging.debug(data) + update(data) + output = "" + except json.JSONDecodeError: + continue + else: + while process.poll() is None: + read = process.stdout.readline() + output += read.decode("utf-8") + logging.debug(output) + if read == b"},\n": + update(json.loads(output[:-2])) + output = "" process.kill() if process.returncode != 0: - logging.error("Error: " + process.stderr.read().decode('utf-8')) + logging.error("Error: " + process.stderr.read().decode("utf-8")) logging.info("Finished")