Skip to content

Commit

Permalink
fix: Remove namespace dependency
Browse files Browse the repository at this point in the history
To improve usage in non-k8s environments
  • Loading branch information
adinhodovic committed Jul 11, 2024
1 parent 7078af9 commit 4685515
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
9 changes: 5 additions & 4 deletions dashboards/django-overview.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ local tbQueryOptions = tablePanel.queryOptions;
query.withDatasourceFromVariable(datasourceVariable) +
query.withSort(1) +
query.generalOptions.withLabel('Namespace') +
query.selectionOptions.withMulti(false) +
query.selectionOptions.withIncludeAll(false) +
query.selectionOptions.withMulti(true) +
// Custom AllValue for non K8s environments where namespace is not set
query.selectionOptions.withIncludeAll(true, '.*') +
query.refresh.onLoad() +
query.refresh.onTime(),

Expand Down Expand Up @@ -371,7 +372,7 @@ local tbQueryOptions = tablePanel.queryOptions;
local migrationsAppliedQuery = |||
max (
django_migrations_applied_total {
namespace="$namespace",
namespace=~"$namespace",
job=~"$job"
}
) by (namespace, job)
Expand All @@ -397,7 +398,7 @@ local tbQueryOptions = tablePanel.queryOptions;
local migrationsUnAppliedQuery = |||
max (
django_migrations_unapplied_total {
namespace="$namespace",
namespace=~"$namespace",
job=~"$job"
}
) by (namespace, job)
Expand Down
5 changes: 3 additions & 2 deletions dashboards/django-requests-by-view.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ local tsOverride = tsStandardOptions.override;
query.withDatasourceFromVariable(datasourceVariable) +
query.withSort(1) +
query.generalOptions.withLabel('Namespace') +
query.selectionOptions.withMulti(false) +
query.selectionOptions.withIncludeAll(false) +
query.selectionOptions.withMulti(true) +
// Custom AllValue for non K8s environments where namespace is not set
query.selectionOptions.withIncludeAll(true, '.*') +
query.refresh.onLoad() +
query.refresh.onTime(),

Expand Down
13 changes: 7 additions & 6 deletions dashboards/django-requests-overview.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ local tbOverride = tbStandardOptions.override;
query.withDatasourceFromVariable(datasourceVariable) +
query.withSort(1) +
query.generalOptions.withLabel('Namespace') +
query.selectionOptions.withMulti(false) +
query.selectionOptions.withIncludeAll(false) +
query.selectionOptions.withMulti(true) +
// Custom AllValue for non K8s environments where namespace is not set
query.selectionOptions.withIncludeAll(true, '.*') +
query.refresh.onLoad() +
query.refresh.onTime(),

Expand Down Expand Up @@ -425,7 +426,7 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withTitle('Go To View') +
tbPanelOptions.link.withType('dashboard') +
tbPanelOptions.link.withUrl(
'/d/%s/django-requests-by-view?var-namespace=${__data.fields.Namespace}&var-job=${__data.fields.Job}&var-view=${__data.fields.View}' % $._config.requestsByViewDashboardUid
'/d/%s/django-requests-by-view?var-job=${__data.fields.Job}&var-view=${__data.fields.View}' % $._config.requestsByViewDashboardUid
) +
tbPanelOptions.link.withTargetBlank(true)
)
Expand Down Expand Up @@ -571,7 +572,7 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withTitle('Go To View') +
tbPanelOptions.link.withType('dashboard') +
tbPanelOptions.link.withUrl(
'/d/%s/django-requests-by-view?var-namespace=${__data.fields.Namespace}&var-job=${__data.fields.Job}&var-view=${__data.fields.View}' % $._config.requestsByViewDashboardUid
'/d/%s/django-requests-by-view?var-job=${__data.fields.Job}&var-view=${__data.fields.View}' % $._config.requestsByViewDashboardUid
) +
tbPanelOptions.link.withTargetBlank(true)
)
Expand Down Expand Up @@ -641,7 +642,7 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withTitle('Go To View') +
tbPanelOptions.link.withType('dashboard') +
tbPanelOptions.link.withUrl(
'/d/%s/django-requests-by-view?var-namespace=${__data.fields.Namespace}&var-job=${__data.fields.Job}&var-view=${__data.fields.View}' % $._config.requestsByViewDashboardUid
'/d/%s/django-requests-by-view?var-job=${__data.fields.Job}&var-view=${__data.fields.View}' % $._config.requestsByViewDashboardUid
) +
tbPanelOptions.link.withTargetBlank(true)
)
Expand Down Expand Up @@ -768,7 +769,7 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withTitle('Go To View') +
tbPanelOptions.link.withType('dashboard') +
tbPanelOptions.link.withUrl(
'/d/%s/django-requests-by-view?var-namespace=${__data.fields.Namespace}&var-job=${__data.fields.Job}&var-view=${__data.fields.View}' % $._config.requestsByViewDashboardUid
'/d/%s/django-requests-by-view?var-job=${__data.fields.Job}&var-view=${__data.fields.View}' % $._config.requestsByViewDashboardUid
) +
tbPanelOptions.link.withTargetBlank(true)
)
Expand Down
9 changes: 5 additions & 4 deletions dashboards_out/django-overview.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
"type": "prometheus",
"uid": "$datasource"
},
"expr": "max (\n django_migrations_applied_total {\n namespace=\"$namespace\",\n job=~\"$job\"\n }\n) by (namespace, job)\n"
"expr": "max (\n django_migrations_applied_total {\n namespace=~\"$namespace\",\n job=~\"$job\"\n }\n) by (namespace, job)\n"
}
],
"title": "Migrations Applied",
Expand Down Expand Up @@ -416,7 +416,7 @@
"type": "prometheus",
"uid": "$datasource"
},
"expr": "max (\n django_migrations_unapplied_total {\n namespace=\"$namespace\",\n job=~\"$job\"\n }\n) by (namespace, job)\n"
"expr": "max (\n django_migrations_unapplied_total {\n namespace=~\"$namespace\",\n job=~\"$job\"\n }\n) by (namespace, job)\n"
}
],
"title": "Migrations Unapplied",
Expand Down Expand Up @@ -702,13 +702,14 @@
"type": "datasource"
},
{
"allValue": ".*",
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"includeAll": false,
"includeAll": true,
"label": "Namespace",
"multi": false,
"multi": true,
"name": "namespace",
"query": "label_values(django_http_responses_total_by_status_view_method_total{}, namespace)",
"refresh": 2,
Expand Down
5 changes: 3 additions & 2 deletions dashboards_out/django-requests-by-view.json
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,14 @@
"type": "datasource"
},
{
"allValue": ".*",
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"includeAll": false,
"includeAll": true,
"label": "Namespace",
"multi": false,
"multi": true,
"name": "namespace",
"query": "label_values(django_http_responses_total_by_status_view_method_total{}, namespace)",
"refresh": 2,
Expand Down
13 changes: 7 additions & 6 deletions dashboards_out/django-requests-overview.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
"targetBlank": true,
"title": "Go To View",
"type": "dashboard",
"url": "/d/django-requests-by-view-jkwq/django-requests-by-view?var-namespace=${__data.fields.Namespace}&var-job=${__data.fields.Job}&var-view=${__data.fields.View}"
"url": "/d/django-requests-by-view-jkwq/django-requests-by-view?var-job=${__data.fields.Job}&var-view=${__data.fields.View}"
}
]
}
Expand Down Expand Up @@ -629,7 +629,7 @@
"targetBlank": true,
"title": "Go To View",
"type": "dashboard",
"url": "/d/django-requests-by-view-jkwq/django-requests-by-view?var-namespace=${__data.fields.Namespace}&var-job=${__data.fields.Job}&var-view=${__data.fields.View}"
"url": "/d/django-requests-by-view-jkwq/django-requests-by-view?var-job=${__data.fields.Job}&var-view=${__data.fields.View}"
}
]
}
Expand Down Expand Up @@ -756,7 +756,7 @@
"targetBlank": true,
"title": "Go To View",
"type": "dashboard",
"url": "/d/django-requests-by-view-jkwq/django-requests-by-view?var-namespace=${__data.fields.Namespace}&var-job=${__data.fields.Job}&var-view=${__data.fields.View}"
"url": "/d/django-requests-by-view-jkwq/django-requests-by-view?var-job=${__data.fields.Job}&var-view=${__data.fields.View}"
}
]
}
Expand Down Expand Up @@ -903,7 +903,7 @@
"targetBlank": true,
"title": "Go To View",
"type": "dashboard",
"url": "/d/django-requests-by-view-jkwq/django-requests-by-view?var-namespace=${__data.fields.Namespace}&var-job=${__data.fields.Job}&var-view=${__data.fields.View}"
"url": "/d/django-requests-by-view-jkwq/django-requests-by-view?var-job=${__data.fields.Job}&var-view=${__data.fields.View}"
}
]
}
Expand Down Expand Up @@ -1042,13 +1042,14 @@
"type": "datasource"
},
{
"allValue": ".*",
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"includeAll": false,
"includeAll": true,
"label": "Namespace",
"multi": false,
"multi": true,
"name": "namespace",
"query": "label_values(django_http_responses_total_by_status_view_method_total{}, namespace)",
"refresh": 2,
Expand Down

0 comments on commit 4685515

Please sign in to comment.