fixes dashboard permissions

This commit is contained in:
benbierens 2023-08-13 08:27:30 +02:00
parent 485af03367
commit 75228c815d
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 143 additions and 129 deletions

View File

@ -20,7 +20,11 @@ namespace DistTestCore.Metrics
//GF_<SectionName>_<KeyName>__FILE
AddEnvVar("GF_AUTH_ANONYMOUS_ENABLED", "true");
AddEnvVar("GF_AUTH_DISABLE_LOGIN_FORM", "true");
AddEnvVar("GF_AUTH_ANONYMOUS_ORG_NAME", "Main Org.");
AddEnvVar("GF_AUTH_ANONYMOUS_ORG_ROLE", "Editor");
//AddEnvVar("GF_AUTH_DISABLE_LOGIN_FORM", "true");
//AddEnvVar("GF_FEATURE_TOGGLES_ENABLE", "publicDashboards");
//[auth]
//disable_login_form = true

View File

@ -1,138 +1,134 @@
{
"dashboard": {
"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": [
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "prometheus",
"uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb"
"type": "grafana",
"uid": "-- Grafana --"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
"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": "c89eaad3-9184-429f-ac94-8ba0b1824dbb"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"overrides": []
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb"
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb"
},
"editorMode": "builder",
"expr": "codexApiDownloads_total",
"instant": false,
"range": true,
"refId": "A"
}
],
"title": "Codex API Downloads",
"type": "timeseries"
}
],
"refresh": "10s",
"schemaVersion": 38,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Codex",
"uid": null,
"version": 2,
"weekStart": ""
"editorMode": "builder",
"expr": "codexApiDownloads_total",
"instant": false,
"range": true,
"refId": "A"
}
],
"title": "Codex API Downloads",
"type": "timeseries"
}
],
"refresh": "10s",
"schemaVersion": 38,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"message": "Default Codex Dashboard",
"overwrite": false
}
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Codex",
"uid": null,
"version": 2,
"weekStart": ""
}

View File

@ -2,6 +2,7 @@
using DistTestCore.Metrics;
using KubernetesWorkflow;
using Logging;
using Newtonsoft.Json;
using System.Reflection;
using System.Text;
@ -51,8 +52,9 @@ namespace DistTestCore
});
var response2 = http.HttpPostString("dashboards/db", GetDashboardJson());
var jsonResponse = JsonConvert.DeserializeObject<GrafanaPostDashboardResponse>(response2);
var grafanaUrl = c.Host + ":" + c.Port;
var grafanaUrl = c.Host + ":" + c.Port + jsonResponse.url;
System.Diagnostics.Process.Start("C:\\Users\\Ben\\AppData\\Local\\Programs\\Opera\\opera.exe", grafanaUrl);
LogEnd("Metrics server started.");
@ -76,6 +78,16 @@ namespace DistTestCore
public string httpMethod { get; set; } = string.Empty;
}
public class GrafanaPostDashboardResponse
{
public int id { get; set; }
public string slug { get; set; } = string.Empty;
public string status { get; set; } = string.Empty;
public string uid { get; set; } = string.Empty;
public string url { get; set; } = string.Empty;
public int version { get; set; }
}
private string GetDashboardJson()
{
var assembly = Assembly.GetExecutingAssembly();
@ -86,7 +98,9 @@ namespace DistTestCore
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
return reader.ReadToEnd();
var dashboard = reader.ReadToEnd();
return $"{{\"dashboard\": {dashboard} ,\"message\": \"Default Codex Dashboard\",\"overwrite\": false}}";
}
}