diff --git a/README.md b/README.md index eefaf8c..4173671 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ pip install discord-ext-prometheus | Name | Documentation | Labels | |--------------------------------|-----------------------------------------------|-----------------------------------| | `discord_connected` | Determines if the bot is connected to Discord | `shard` | -| `discord_latency` | Latency to Discord | `shard` | +| `discord_latency_seconds` | Latency to Discord | `shard` | | `discord_event_on_interaction` | Amount of interactions called by users | `shard`, `interaction`, `command` | | `discord_event_on_command` | Amount of commands called by users | `shard`, `command` | | `discord_stat_total_guilds` | Amount of guild this bot is a member of | None | diff --git a/discord/ext/prometheus/prometheus_cog.py b/discord/ext/prometheus/prometheus_cog.py index b33d0c7..0633ace 100644 --- a/discord/ext/prometheus/prometheus_cog.py +++ b/discord/ext/prometheus/prometheus_cog.py @@ -13,9 +13,9 @@ ["shard"], ) LATENCY_GAUGE = Gauge( - METRIC_PREFIX + 'latency', - 'latency to Discord', - ['shard'], + METRIC_PREFIX + "latency", + "latency to Discord", + ["shard"], unit="seconds", ) ON_INTERACTION_COUNTER = Counter( diff --git a/grafana/dashboard.json b/grafana/dashboard.json index 98174e0..18460c3 100644 --- a/grafana/dashboard.json +++ b/grafana/dashboard.json @@ -1,53 +1,4 @@ { - "__inputs": [ - { - "name": "DS_PROMETHEUS", - "label": "Prometheus", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": {}, - "__requires": [ - { - "type": "panel", - "id": "bargauge", - "name": "Bar gauge", - "version": "" - }, - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "9.2.2" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "state-timeline", - "name": "State timeline", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], "annotations": { "list": [ { @@ -70,18 +21,19 @@ } ] }, - "description": "", + "description": "This is a dashboard for the discord-ext-prometheus Python library.", "editable": true, "fiscalYearStartMonth": 0, + "gnetId": 17670, "graphTooltip": 1, - "id": null, + "id": 7, "links": [], "liveNow": false, "panels": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "description": "Since last reboot", "fieldConfig": { @@ -98,6 +50,10 @@ { "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] } @@ -113,8 +69,10 @@ "id": 57, "options": { "displayMode": "basic", + "maxVizHeight": 300, "minVizHeight": 10, "minVizWidth": 0, + "namePlacement": "auto", "orientation": "horizontal", "reduceOptions": { "calcs": [ @@ -124,14 +82,16 @@ "values": false }, "showUnfilled": true, - "text": {} + "sizing": "auto", + "text": {}, + "valueMode": "color" }, - "pluginVersion": "9.2.2", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "discord_event_on_command_total{job=~\"$job\"}", @@ -143,7 +103,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "exemplar": false, @@ -156,7 +116,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "discord_event_on_interaction_total{job=~\"$job\", command=\"None\"}", @@ -172,7 +132,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "description": "", "fieldConfig": { @@ -182,7 +142,10 @@ }, "custom": { "align": "auto", - "displayMode": "color-background", + "cellOptions": { + "mode": "gradient", + "type": "color-background" + }, "filterable": false, "inspect": false, "minWidth": 50 @@ -255,8 +218,51 @@ } }, { - "id": "custom.width", - "value": 192 + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Channels" + }, + "properties": [ + { + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Users" + }, + "properties": [ + { + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Guilds" + }, + "properties": [ + { + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Commands" + }, + "properties": [ + { + "id": "custom.width" } ] } @@ -270,7 +276,9 @@ }, "id": 42, "options": { + "cellHeight": "sm", "footer": { + "countRows": false, "enablePagination": false, "fields": [ "Value #A (lastNotNull)", @@ -285,19 +293,14 @@ }, "frameIndex": 0, "showHeader": true, - "sortBy": [ - { - "desc": true, - "displayName": "job" - } - ] + "sortBy": [] }, - "pluginVersion": "9.2.2", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "exemplar": false, @@ -311,7 +314,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "exemplar": false, @@ -326,7 +329,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "exemplar": false, @@ -341,7 +344,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "exemplar": false, @@ -356,7 +359,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "exemplar": false, @@ -436,11 +439,12 @@ "excludeByName": { "job": false }, + "includeByName": {}, "indexByName": {}, "renameByName": { "Value": "Users", "Value #A (lastNotNull)": "Users", - "Value #B (lastNotNull)": "Guild", + "Value #B (lastNotNull)": "Guilds", "Value #C (lastNotNull)": "Channels", "Value #D (lastNotNull)": "Commands", "Value #E (last)": "Uptime", @@ -455,7 +459,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "description": "", "fieldConfig": { @@ -466,6 +470,12 @@ }, "custom": { "fillOpacity": 80, + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, "lineWidth": 0, "spanNulls": true }, @@ -529,7 +539,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "exemplar": false, @@ -543,7 +553,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "exemplar": false, @@ -561,7 +571,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "fieldConfig": { "defaults": { @@ -569,6 +579,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -582,6 +593,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -639,7 +651,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "discord_stat_total_guilds{job=~\"$job\"}", @@ -654,7 +666,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "fieldConfig": { "defaults": { @@ -663,6 +675,7 @@ "seriesBy": "last" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -676,6 +689,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -731,10 +745,10 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", - "expr": "discord_latency{job=~\"$job\", shard=~\"[0-9]+\"}", + "expr": "discord_latency_seconds{job=~\"$job\", shard=~\"[0-9]+\"}", "legendFormat": "{{job}} : {{shard}}", "range": true, "refId": "A" @@ -742,10 +756,10 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", - "expr": "discord_latency{job=~\"$job\", shard=\"None\"}", + "expr": "discord_latency_seconds{job=~\"$job\", shard=\"None\"}", "hide": false, "legendFormat": "{{job}}", "range": true, @@ -758,7 +772,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "description": "", "fieldConfig": { @@ -767,19 +781,21 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", - "fillOpacity": 2, + "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -836,7 +852,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "round(sum(rate(discord_event_on_command_total{job=~\"$job\"}[1m])) by (job, command) * 45)", @@ -847,7 +863,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "round(sum(rate(discord_event_on_interaction_total{job=~\"$job\", command=~\"None\"}[1m])) by (job, interaction) * 45)", @@ -859,7 +875,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "round(sum(rate(discord_event_on_interaction_total{job=~\"$job\", command!=\"None\"}[1m])) by (job, command) * 45)", @@ -875,7 +891,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "fieldConfig": { "defaults": { @@ -883,6 +899,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -896,6 +913,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -953,7 +971,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "discord_stat_total_channels{job=~\"$job\"}", @@ -968,7 +986,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "fieldConfig": { "defaults": { @@ -976,6 +994,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -989,6 +1008,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -1043,7 +1063,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "rate(process_cpu_seconds_total{job=~\"$job\"}[1m])", @@ -1058,7 +1078,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "fieldConfig": { "defaults": { @@ -1066,19 +1086,21 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", - "fillOpacity": 2, + "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -1177,7 +1199,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "round(max(rate(logging_total{job=~\"$job\"}[1m])) by (level) * 45)", @@ -1193,7 +1215,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "fieldConfig": { "defaults": { @@ -1201,6 +1223,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -1214,6 +1237,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -1271,7 +1295,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "discord_stat_total_users{job=~\"$job\"}", @@ -1286,7 +1310,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "fieldConfig": { "defaults": { @@ -1295,6 +1319,7 @@ "seriesBy": "last" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", @@ -1308,6 +1333,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -1363,7 +1389,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "editorMode": "code", "expr": "scrape_duration_seconds{job=~\"$job\"}", @@ -1377,8 +1403,7 @@ } ], "refresh": "5s", - "schemaVersion": 37, - "style": "dark", + "schemaVersion": 39, "tags": [ "Discord" ], @@ -1386,16 +1411,20 @@ "list": [ { "allValue": "", - "current": {}, + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "edj9pxm9uzmrkc" }, "definition": "label_values(discord_connected, job)", - "description": "The Discord bot", + "description": "The Prometheus job", "hide": 0, "includeAll": true, - "label": "Bot", + "label": "Job", "multi": false, "name": "job", "options": [], @@ -1419,6 +1448,6 @@ "timezone": "", "title": "Discord Bot", "uid": "TGkTuzD4z", - "version": 95, + "version": 5, "weekStart": "" } \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 62718f2..c5497e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "discord-ext-prometheus" -version = "0.1.5" +version = "0.2.0" authors = [{ name = "Apollo-Roboto", email = "Apollo_Roboto@outlook.com" }] description = "An extension for the discord.py library that enables Prometheus metrics" readme = "README.md"