Skip to content

Commit

Permalink
fix: set labels and legends on dashboard
Browse files Browse the repository at this point in the history
Sets the legends on the dashboard in the query options instead of using
transformations. This guarantees that the legends and labels remain
consistent after changing the time range.
  • Loading branch information
luissimas committed Jul 31, 2024
1 parent 643c104 commit 883df58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 77 deletions.
85 changes: 8 additions & 77 deletions dashboards/Zettelkasten-VictoriaMetrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -684,28 +684,14 @@
"expr": "total_note_count",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
"legendFormat": "Note count",
"query": "from(bucket: v.defaultBucket)\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"total\")\n |> filter(fn: (r) => r[\"_field\"] == \"note_count\")",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Notes",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {},
"includeByName": {},
"indexByName": {},
"renameByName": {
"note_count": "Note count",
"total_note_count": "Note count"
}
}
}
],
"type": "timeseries"
},
{
Expand Down Expand Up @@ -796,28 +782,14 @@
"expr": "total_word_count",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
"legendFormat": "Word count",
"query": "from(bucket: v.defaultBucket)\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"total\")\n |> filter(fn: (r) => r[\"_field\"] == \"word_count\")",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Words",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {},
"includeByName": {},
"indexByName": {},
"renameByName": {
"total_word_count": "Word count",
"word_count": "Word count"
}
}
}
],
"type": "timeseries"
},
{
Expand Down Expand Up @@ -909,28 +881,14 @@
"expr": "total_link_count",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
"legendFormat": "Link count",
"query": "from(bucket: v.defaultBucket)\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"total\")\n |> filter(fn: (r) => r[\"_field\"] == \"link_count\")",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Links",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {},
"includeByName": {},
"indexByName": {},
"renameByName": {
"link_count": "Link count",
"total_link_count": "Link count"
}
}
}
],
"type": "timeseries"
},
{
Expand Down Expand Up @@ -1022,28 +980,14 @@
"expr": "total_word_count / 212",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
"legendFormat": "Reading time",
"query": "from(bucket: v.defaultBucket)\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"total\")\n |> filter(fn: (r) => r[\"_field\"] == \"word_count\")\n |> map(fn: (r) => ({r with _value: r._value / uint(v: 212)}))",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Reading time",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {},
"includeByName": {},
"indexByName": {},
"renameByName": {
"total_word_count / 212": "Reading time",
"word_count": "Reading time"
}
}
}
],
"type": "timeseries"
},
{
Expand Down Expand Up @@ -1135,28 +1079,14 @@
"expr": "sum(notes_link_count[$__range]) / count(notes_link_count[$__range])",
"fullMetaSearch": false,
"includeNullMetadata": false,
"legendFormat": "__auto",
"legendFormat": "Link count",
"query": "from(bucket: v.defaultBucket)\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"notes\" and r[\"_field\"] == \"link_count\")\n |> group(columns: [\"__time\"])\n |> aggregateWindow(\n every: v.windowPeriod,\n fn: (column, tables=<-) => tables |> mean(),\n column: \"name\",\n createEmpty: false\n)",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Average link count",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {},
"includeByName": {},
"indexByName": {},
"renameByName": {
"Value": "Average link count",
"sum(notes_link_count[2592000s]) / count(notes_link_count[2592000s])": "Average link count"
}
}
}
],
"type": "timeseries"
},
{
Expand Down Expand Up @@ -1248,7 +1178,7 @@
"expr": "sum(notes_word_count[$__range]) / count(notes_word_count[$__range])",
"fullMetaSearch": false,
"includeNullMetadata": false,
"legendFormat": "__auto",
"legendFormat": "Word count",
"query": "from(bucket: v.defaultBucket)\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"notes\" and r[\"_field\"] == \"word_count\")\n |> group(columns: [\"__time\"])\n |> aggregateWindow(\n every: v.windowPeriod,\n fn: (column, tables=<-) => tables |> mean(),\n column: \"name\",\n createEmpty: false\n)",
"range": true,
"refId": "A",
Expand All @@ -1265,6 +1195,7 @@
"indexByName": {},
"renameByName": {
"Value": "Average word count",
"sum(notes_word_count[2332800s]) / count(notes_word_count[2332800s])": "Average word count",
"sum(notes_word_count[2592000s]) / count(notes_word_count[2592000s])": "Average word count"
}
}
Expand Down Expand Up @@ -1306,6 +1237,6 @@
"timezone": "browser",
"title": "Zettelkasten",
"uid": "fdoghlpqzr5kwe",
"version": 2,
"version": 4,
"weekStart": ""
}
Binary file modified docs/assets/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 883df58

Please sign in to comment.