Skip to content

Commit 34d06ac

Browse files
committed
feat(dashboard): make prometheus and loki datasource less hardcoded
1 parent 132a3c5 commit 34d06ac

File tree

1 file changed

+51
-23
lines changed

1 file changed

+51
-23
lines changed

etc/dashboards/fastapi-observability.json

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{
3131
"datasource": {
3232
"type": "prometheus",
33-
"uid": "prometheus"
33+
"uid": "${DS_PROMETHEUS}"
3434
},
3535
"fieldConfig": {
3636
"defaults": {
@@ -76,7 +76,7 @@
7676
{
7777
"datasource": {
7878
"type": "prometheus",
79-
"uid": "prometheus"
79+
"uid": "${DS_PROMETHEUS}"
8080
},
8181
"editorMode": "code",
8282
"exemplar": true,
@@ -112,7 +112,7 @@
112112
{
113113
"datasource": {
114114
"type": "prometheus",
115-
"uid": "prometheus"
115+
"uid": "${DS_PROMETHEUS}"
116116
},
117117
"fieldConfig": {
118118
"defaults": {
@@ -158,7 +158,7 @@
158158
{
159159
"datasource": {
160160
"type": "prometheus",
161-
"uid": "prometheus"
161+
"uid": "${DS_PROMETHEUS}"
162162
},
163163
"editorMode": "code",
164164
"exemplar": true,
@@ -202,7 +202,7 @@
202202
{
203203
"datasource": {
204204
"type": "prometheus",
205-
"uid": "prometheus"
205+
"uid": "${DS_PROMETHEUS}"
206206
},
207207
"fieldConfig": {
208208
"defaults": {
@@ -262,7 +262,7 @@
262262
{
263263
"datasource": {
264264
"type": "prometheus",
265-
"uid": "prometheus"
265+
"uid": "${DS_PROMETHEUS}"
266266
},
267267
"exemplar": true,
268268
"expr": "fastapi_requests_duration_seconds_sum{app_name=\"$app_name\"} / fastapi_requests_duration_seconds_count{app_name=\"$app_name\"}",
@@ -277,7 +277,7 @@
277277
{
278278
"datasource": {
279279
"type": "prometheus",
280-
"uid": "prometheus"
280+
"uid": "${DS_PROMETHEUS}"
281281
},
282282
"fieldConfig": {
283283
"defaults": {
@@ -329,7 +329,7 @@
329329
{
330330
"datasource": {
331331
"type": "prometheus",
332-
"uid": "prometheus"
332+
"uid": "${DS_PROMETHEUS}"
333333
},
334334
"editorMode": "code",
335335
"exemplar": false,
@@ -348,7 +348,7 @@
348348
{
349349
"datasource": {
350350
"type": "prometheus",
351-
"uid": "prometheus"
351+
"uid": "${DS_PROMETHEUS}"
352352
},
353353
"fieldConfig": {
354354
"defaults": {
@@ -431,7 +431,7 @@
431431
{
432432
"datasource": {
433433
"type": "prometheus",
434-
"uid": "prometheus"
434+
"uid": "${DS_PROMETHEUS}"
435435
},
436436
"exemplar": true,
437437
"expr": "sum by(path) (fastapi_responses_total{app_name=\"$app_name\", status_code=~\"2.*\", path!=\"/metrics\"}) / sum by(path) (fastapi_responses_total{app_name=\"$app_name\", path!=\"/metrics\"})",
@@ -446,7 +446,7 @@
446446
{
447447
"datasource": {
448448
"type": "prometheus",
449-
"uid": "prometheus"
449+
"uid": "${DS_PROMETHEUS}"
450450
},
451451
"fieldConfig": {
452452
"defaults": {
@@ -529,7 +529,7 @@
529529
{
530530
"datasource": {
531531
"type": "prometheus",
532-
"uid": "prometheus"
532+
"uid": "${DS_PROMETHEUS}"
533533
},
534534
"exemplar": true,
535535
"expr": "sum by(path) (fastapi_responses_total{app_name=\"$app_name\", status_code=~\"5.*\", path!=\"/metrics\"}) / sum by(path) (fastapi_responses_total{app_name=\"$app_name\", path!=\"/metrics\"})",
@@ -544,7 +544,7 @@
544544
{
545545
"datasource": {
546546
"type": "prometheus",
547-
"uid": "prometheus"
547+
"uid": "${DS_PROMETHEUS}"
548548
},
549549
"fieldConfig": {
550550
"defaults": {
@@ -626,7 +626,7 @@
626626
{
627627
"datasource": {
628628
"type": "prometheus",
629-
"uid": "prometheus"
629+
"uid": "${DS_PROMETHEUS}"
630630
},
631631
"exemplar": true,
632632
"expr": "histogram_quantile(.99,sum(rate(fastapi_requests_duration_seconds_bucket{app_name=\"$app_name\", path!=\"/metrics\"}[1m])) by(path, le))",
@@ -641,7 +641,7 @@
641641
{
642642
"datasource": {
643643
"type": "prometheus",
644-
"uid": "prometheus"
644+
"uid": "${DS_PROMETHEUS}"
645645
},
646646
"fieldConfig": {
647647
"defaults": {
@@ -722,7 +722,7 @@
722722
{
723723
"datasource": {
724724
"type": "prometheus",
725-
"uid": "prometheus"
725+
"uid": "${DS_PROMETHEUS}"
726726
},
727727
"exemplar": true,
728728
"expr": "fastapi_requests_in_progress{app_name=\"$app_name\", path!=\"/metrics\"}",
@@ -737,7 +737,7 @@
737737
{
738738
"datasource": {
739739
"type": "prometheus",
740-
"uid": "prometheus"
740+
"uid": "${DS_PROMETHEUS}"
741741
},
742742
"fieldConfig": {
743743
"defaults": {
@@ -819,7 +819,7 @@
819819
{
820820
"datasource": {
821821
"type": "prometheus",
822-
"uid": "prometheus"
822+
"uid": "${DS_PROMETHEUS}"
823823
},
824824
"exemplar": true,
825825
"expr": "rate(fastapi_requests_total{app_name=\"$app_name\"}[1m])",
@@ -834,7 +834,7 @@
834834
{
835835
"datasource": {
836836
"type": "loki",
837-
"uid": "loki"
837+
"uid": "${DS_LOKI}"
838838
},
839839
"fieldConfig": {
840840
"defaults": {
@@ -961,7 +961,7 @@
961961
{
962962
"datasource": {
963963
"type": "loki",
964-
"uid": "loki"
964+
"uid": "${DS_LOKI}"
965965
},
966966
"expr": "sum by(type) (rate({compose_service=~\"app-.*\"} | pattern `<date> <time> <type> <logger> <code> [<_>=<trace_id> <_>=<span_id> <_>=<service_name>] - <msg>` | type != \"\" |= \"$log_keyword\" [1m]))",
967967
"legendFormat": "{{type}}",
@@ -974,7 +974,7 @@
974974
{
975975
"datasource": {
976976
"type": "loki",
977-
"uid": "loki"
977+
"uid": "${DS_LOKI}"
978978
},
979979
"fieldConfig": {
980980
"defaults": {},
@@ -1003,7 +1003,7 @@
10031003
{
10041004
"datasource": {
10051005
"type": "loki",
1006-
"uid": "loki"
1006+
"uid": "${DS_LOKI}"
10071007
},
10081008
"expr": "{compose_service=~\"app-.*\"} | pattern `<date> <time> <type> <logger> <code> [<_>=<trace_id> <_>=<span_id> <_>=<service_name>] - <msg>` | line_format \"{{.compose_service}}\\t{{.type}}\\t trace_id={{.trace_id}}\\t {{.msg}}\" |= \"$log_keyword\"",
10091009
"hide": false,
@@ -1020,14 +1020,42 @@
10201020
"tags": [],
10211021
"templating": {
10221022
"list": [
1023+
{
1024+
"current": {
1025+
"text": "Prometheus",
1026+
"value": "prometheus"
1027+
},
1028+
"includeAll": false,
1029+
"label": "Metrics Datasource",
1030+
"name": "DS_PROMETHEUS",
1031+
"options": [],
1032+
"query": "prometheus",
1033+
"refresh": 1,
1034+
"regex": "",
1035+
"type": "datasource"
1036+
},
1037+
{
1038+
"current": {
1039+
"text": "Loki",
1040+
"value": "loki"
1041+
},
1042+
"includeAll": false,
1043+
"label": "Logs Datasource",
1044+
"name": "DS_LOKI",
1045+
"options": [],
1046+
"query": "loki",
1047+
"refresh": 1,
1048+
"regex": "",
1049+
"type": "datasource"
1050+
},
10231051
{
10241052
"current": {
10251053
"text": "app-a",
10261054
"value": "app-a"
10271055
},
10281056
"datasource": {
10291057
"type": "prometheus",
1030-
"uid": "prometheus"
1058+
"uid": "${DS_PROMETHEUS}"
10311059
},
10321060
"definition": "label_values(fastapi_app_info{}, app_name)",
10331061
"includeAll": false,

0 commit comments

Comments
 (0)