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 //GF_<SectionName>_<KeyName>__FILE
AddEnvVar("GF_AUTH_ANONYMOUS_ENABLED", "true"); 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] //[auth]
//disable_login_form = true //disable_login_form = true

View File

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

View File

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