diff --git a/README.md b/README.md index d539fec..eb0cf1b 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ If you don't have a device for live measurements, only the power price metrics w ![Grafana dashboard without pulse](grafana/dashboard-without-pulse.png) +These metrics can also be used for a [monthly overview dashboard](grafana/dashboard-monthly.json): + +![Grafana monthly overview dashboard](grafana/dashboard-monthly.png) + #### Next day prices The Tibber API provides power prices for the current and the next day, but storing future data can't be done easily in Prometheus. To be able to show future power prices, this exporter also has a JSON service which can be queried to get this data. In Grafana this can be used with the [JSON API datasource plugin](https://grafana.com/grafana/plugins/marcusolsson-json-datasource/). @@ -55,7 +59,7 @@ cd docker-compose TIBBER_TOKEN=... docker compose up ``` -Then go to http://localhost:3000/ and find the dashboards in the General folder. +Then go to http://localhost:3000/ and find the dashboards from the menu. ### Kubernetes diff --git a/charts/tibber-exporter/Chart.yaml b/charts/tibber-exporter/Chart.yaml index 3ab1b71..5622695 100644 --- a/charts/tibber-exporter/Chart.yaml +++ b/charts/tibber-exporter/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: tibber-exporter -version: 3.3.1 +version: 3.4.0 description: Tibber exporter type: application keywords: @@ -28,3 +28,5 @@ annotations: url: https://raw.githubusercontent.com/terjesannum/tibber-exporter/master/grafana/dashboard-without-pulse.png - title: Prices dashboard url: https://raw.githubusercontent.com/terjesannum/tibber-exporter/master/grafana/dashboard-prices.png + - title: Monthly overview + url: https://raw.githubusercontent.com/terjesannum/tibber-exporter/master/grafana/dashboard-monthly.png diff --git a/charts/tibber-exporter/README.md b/charts/tibber-exporter/README.md index aaae139..93890bd 100644 --- a/charts/tibber-exporter/README.md +++ b/charts/tibber-exporter/README.md @@ -8,6 +8,8 @@ If you don't have Tibber Pulse, you still get price and daily consumption/cost m ![Grafana dashboard](https://raw.githubusercontent.com/terjesannum/tibber-exporter/master/grafana/dashboard-without-pulse.png) -![Grafana dashboard](https://raw.githubusercontent.com/terjesannum/tibber-exporter/master/grafana/dashboard-prices.png) +![Grafana prices dashboard](https://raw.githubusercontent.com/terjesannum/tibber-exporter/master/grafana/dashboard-prices.png) + +![Grafana monthly overview dashboard](https://raw.githubusercontent.com/terjesannum/tibber-exporter/master/grafana/dashboard-monthly.png) See [https://github.com/terjesannum/tibber-exporter](https://github.com/terjesannum/tibber-exporter) for more information. diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index f8c2330..5f7f329 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -31,6 +31,7 @@ services: - ../grafana/dashboard.json:/dashboard.json - ../grafana/dashboard-without-pulse.json:/dashboard-without-pulse.json - ../grafana/dashboard-prices.json:/dashboard-prices.json + - ../grafana/dashboard-monthly.json:/dashboard-monthly.json - ./grafana.sh:/grafana.sh - grafana_data:/var/lib/grafana ports: diff --git a/docker-compose/grafana.sh b/docker-compose/grafana.sh index 36edc6d..430423b 100755 --- a/docker-compose/grafana.sh +++ b/docker-compose/grafana.sh @@ -6,4 +6,5 @@ mkdir -p /var/lib/grafana/dashboards cat /dashboard.json | sed -e 's/${DS_PROMETHEUS}/1/;s/now-7d/now-6h/;s/\"refresh\": \"1m\"/\"refresh\": \"5s\"/' > /var/lib/grafana/dashboards/dashboard.json cat /dashboard-without-pulse.json | sed -e 's/${DS_PROMETHEUS}/1/' > /var/lib/grafana/dashboards/dashboard-without-pulse.json cat /dashboard-prices.json | sed -e 's/${DS_TIBBER-EXPORTER}/2/' > /var/lib/grafana/dashboards/dashboard-prices.json +cat /dashboard-monthly.json | sed -e 's/${DS_PROMETHEUS}/1/' > /var/lib/grafana/dashboards/dashboard-monthly.json /run.sh diff --git a/grafana/dashboard-monthly.json b/grafana/dashboard-monthly.json new file mode 100644 index 0000000..0eaceb1 --- /dev/null +++ b/grafana/dashboard-monthly.json @@ -0,0 +1,449 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "barchart", + "name": "Bar chart", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "10.1.4" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + } + ], + "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": 0, + "id": null, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "right", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "kWh" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 5, + "options": { + "barRadius": 0, + "barWidth": 0.95, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "text": { + "valueSize": 12 + }, + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xField": "Field", + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "label_replace(\n quantile_over_time(0.9,tibber_power_consumption_previous_day{home_id=\"$home\"}[1d] offset -1d) + ignoring(year, month) group_right\n count_values without() (\"year\", year(timestamp(\n count_values without() (\"month\", month(timestamp(\n quantile_over_time(0.9,tibber_power_consumption_previous_day{home_id=\"$home\"}[1d] offset -1d)\n )))\n ))) * 0,\n \"zero\",\n \"0\",\n \"month\",\n \"^[0-9]$\"\n)", + "instant": false, + "interval": "1d", + "legendFormat": "{{year}}-{{zero}}{{month}}", + "range": true, + "refId": "A" + } + ], + "title": "Consumption", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "seriesToRows", + "reducers": [ + "sum" + ] + } + }, + { + "id": "sortBy", + "options": { + "fields": {}, + "sort": [ + { + "field": "Field" + } + ] + } + } + ], + "type": "barchart" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "right", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "kr" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 7, + "options": { + "barRadius": 0, + "barWidth": 0.95, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "text": { + "valueSize": 12 + }, + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xField": "Field", + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "label_replace(\n quantile_over_time(0.9,tibber_power_cost_previous_day{home_id=\"$home\"}[1d] offset -1d) + ignoring(year, month) group_right\n count_values without() (\"year\", year(timestamp(\n count_values without() (\"month\", month(timestamp(\n quantile_over_time(0.9,tibber_power_cost_previous_day{home_id=\"$home\"}[1d] offset -1d)\n )))\n ))) * 0,\n \"zero\",\n \"0\",\n \"month\",\n \"^[0-9]$\"\n)", + "instant": false, + "interval": "1d", + "legendFormat": "{{year}}-{{zero}}{{month}}", + "range": true, + "refId": "A" + } + ], + "title": "Cost", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "seriesToRows", + "reducers": [ + "sum" + ] + } + }, + { + "id": "sortBy", + "options": { + "fields": {}, + "sort": [ + { + "field": "Field" + } + ] + } + } + ], + "type": "barchart" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "right", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "kr" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 8, + "options": { + "barRadius": 0, + "barWidth": 0.95, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "text": { + "valueSize": 12 + }, + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xField": "Field", + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "label_replace(\n avg_over_time(tibber_power_price{home_id=\"$home\",type=\"total\"}[1d]) + ignoring(year, month) group_right\n count_values without() (\"year\", year(timestamp(\n count_values without() (\"month\", month(timestamp(\n avg_over_time(tibber_power_price{home_id=\"$home\",type=\"total\"}[1d])\n )))\n ))) * 0,\n \"zero\",\n \"0\",\n \"month\",\n \"^[0-9]$\"\n)", + "instant": false, + "interval": "1d", + "legendFormat": "{{year}}-{{zero}}{{month}}", + "range": true, + "refId": "A" + } + ], + "title": "Average price", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "seriesToRows", + "reducers": [ + "mean" + ] + } + }, + { + "id": "sortBy", + "options": { + "fields": {}, + "sort": [ + { + "field": "Field" + } + ] + } + } + ], + "type": "barchart" + } + ], + "refresh": "", + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "definition": "tibber_home_info", + "hide": 0, + "includeAll": false, + "label": "Home", + "multi": false, + "name": "home", + "options": [], + "query": { + "query": "tibber_home_info", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "/.*home_id=\"(?[^\"]+)(?:.*name=\"(?[^\"]+))?/", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-1y", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Tibber monthly", + "uid": "f6c4587e-9af5-4cad-85e0-0387c2ca4d2f", + "version": 10, + "weekStart": "" +} diff --git a/grafana/dashboard-monthly.png b/grafana/dashboard-monthly.png new file mode 100644 index 0000000..0897af8 Binary files /dev/null and b/grafana/dashboard-monthly.png differ