From 5f1b9bf8d46f450c4c88f950a9e965a1037fe7d6 Mon Sep 17 00:00:00 2001 From: benbierens Date: Thu, 10 Aug 2023 14:31:08 +0200 Subject: [PATCH 01/14] lines up test type names --- CodexNetDeployer/Configuration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodexNetDeployer/Configuration.cs b/CodexNetDeployer/Configuration.cs index 955084a..dbcc8bf 100644 --- a/CodexNetDeployer/Configuration.cs +++ b/CodexNetDeployer/Configuration.cs @@ -49,7 +49,7 @@ namespace CodexNetDeployer [Uniform("teststype-podlabel", "ttpl", "TESTSTYPE-PODLABEL", false, "Each kubernetes pod will be created with a label 'teststype' with value 'continuous'. " + "set this option to override the label value.")] - public string TestsTypePodLabel { get; set; } = "continuous"; + public string TestsTypePodLabel { get; set; } = "continuous-tests"; public TestRunnerLocation RunnerLocation { get; set; } = TestRunnerLocation.InternalToCluster; From fff02656b72890cc4055b66d7bf8a620b3ec9d52 Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 11 Aug 2023 08:39:51 +0200 Subject: [PATCH 02/14] automatically determine runner location --- CodexNetDeployer/Configuration.cs | 3 -- CodexNetDeployer/Deployer.cs | 1 - CodexNetDeployer/Program.cs | 6 --- CodexNetDownloader/Configuration.cs | 3 -- CodexNetDownloader/Program.cs | 7 +-- ContinuousTests/CodexAccessFactory.cs | 2 +- ContinuousTests/Configuration.cs | 8 +-- ContinuousTests/ContinuousTestRunner.cs | 4 +- ContinuousTests/K8sFactory.cs | 3 +- ContinuousTests/NodeRunner.cs | 2 +- ContinuousTests/SingleTestRun.cs | 4 +- DistTestCore/Configuration.cs | 67 +++++++++++++++++++++---- 12 files changed, 67 insertions(+), 43 deletions(-) diff --git a/CodexNetDeployer/Configuration.cs b/CodexNetDeployer/Configuration.cs index dbcc8bf..ee7ac7e 100644 --- a/CodexNetDeployer/Configuration.cs +++ b/CodexNetDeployer/Configuration.cs @@ -1,5 +1,4 @@ using ArgsUniform; -using DistTestCore; using DistTestCore.Codex; namespace CodexNetDeployer @@ -51,8 +50,6 @@ namespace CodexNetDeployer "set this option to override the label value.")] public string TestsTypePodLabel { get; set; } = "continuous-tests"; - public TestRunnerLocation RunnerLocation { get; set; } = TestRunnerLocation.InternalToCluster; - public List Validate() { var errors = new List(); diff --git a/CodexNetDeployer/Deployer.cs b/CodexNetDeployer/Deployer.cs index a5e174e..feb750e 100644 --- a/CodexNetDeployer/Deployer.cs +++ b/CodexNetDeployer/Deployer.cs @@ -68,7 +68,6 @@ namespace CodexNetDeployer logDebug: false, dataFilesPath: "notUsed", codexLogLevel: config.CodexLogLevel, - runnerLocation: config.RunnerLocation, k8sNamespacePrefix: config.KubeNamespace ); diff --git a/CodexNetDeployer/Program.cs b/CodexNetDeployer/Program.cs index d96b25f..9c1ecbf 100644 --- a/CodexNetDeployer/Program.cs +++ b/CodexNetDeployer/Program.cs @@ -1,6 +1,5 @@ using ArgsUniform; using CodexNetDeployer; -using DistTestCore; using DistTestCore.Codex; using DistTestCore.Marketplace; using DistTestCore.Metrics; @@ -17,11 +16,6 @@ public class Program var uniformArgs = new ArgsUniform(PrintHelp, args); var config = uniformArgs.Parse(true); - if (args.Any(a => a == "--external")) - { - config.RunnerLocation = TestRunnerLocation.ExternalToCluster; - } - var errors = config.Validate(); if (errors.Any()) { diff --git a/CodexNetDownloader/Configuration.cs b/CodexNetDownloader/Configuration.cs index 008dfbf..a42136a 100644 --- a/CodexNetDownloader/Configuration.cs +++ b/CodexNetDownloader/Configuration.cs @@ -1,5 +1,4 @@ using ArgsUniform; -using DistTestCore; using DistTestCore.Codex; namespace CodexNetDownloader @@ -16,7 +15,5 @@ namespace CodexNetDownloader public string KubeConfigFile { get; set; } = "null"; public CodexDeployment CodexDeployment { get; set; } = null!; - - public TestRunnerLocation RunnerLocation { get; set; } = TestRunnerLocation.InternalToCluster; } } diff --git a/CodexNetDownloader/Program.cs b/CodexNetDownloader/Program.cs index 195e96b..5744e71 100644 --- a/CodexNetDownloader/Program.cs +++ b/CodexNetDownloader/Program.cs @@ -15,17 +15,12 @@ public class Program var uniformArgs = new ArgsUniform(PrintHelp, args); var config = uniformArgs.Parse(true); - if (args.Any(a => a == "--external")) - { - config.RunnerLocation = TestRunnerLocation.ExternalToCluster; - } - config.CodexDeployment = ParseCodexDeploymentJson(config.CodexDeploymentJson); if (!Directory.Exists(config.OutputPath)) Directory.CreateDirectory(config.OutputPath); var k8sFactory = new K8sFactory(); - var lifecycle = k8sFactory.CreateTestLifecycle(config.KubeConfigFile, config.OutputPath, "dataPath", config.CodexDeployment.Metadata.KubeNamespace, new DefaultTimeSet(), new NullLog(), config.RunnerLocation); + var lifecycle = k8sFactory.CreateTestLifecycle(config.KubeConfigFile, config.OutputPath, "dataPath", config.CodexDeployment.Metadata.KubeNamespace, new DefaultTimeSet(), new NullLog()); foreach (var container in config.CodexDeployment.CodexContainers) { diff --git a/ContinuousTests/CodexAccessFactory.cs b/ContinuousTests/CodexAccessFactory.cs index a149017..78e9069 100644 --- a/ContinuousTests/CodexAccessFactory.cs +++ b/ContinuousTests/CodexAccessFactory.cs @@ -12,7 +12,7 @@ namespace ContinuousTests return containers.Select(container => { var address = container.ClusterExternalAddress; - if (config.RunnerLocation == TestRunnerLocation.InternalToCluster) address = container.ClusterInternalAddress; + if (config.RunnerLocation == RunnerLocation.InternalToCluster) address = container.ClusterInternalAddress; return new CodexAccess(log, container, timeSet, address); }).ToArray(); } diff --git a/ContinuousTests/Configuration.cs b/ContinuousTests/Configuration.cs index b0cebbd..da1eaeb 100644 --- a/ContinuousTests/Configuration.cs +++ b/ContinuousTests/Configuration.cs @@ -30,7 +30,7 @@ namespace ContinuousTests public CodexDeployment CodexDeployment { get; set; } = null!; - public TestRunnerLocation RunnerLocation { get; set; } = TestRunnerLocation.InternalToCluster; + public RunnerLocation RunnerLocation { get; set; } } public class ConfigLoader @@ -42,10 +42,7 @@ namespace ContinuousTests var result = uniformArgs.Parse(true); result.CodexDeployment = ParseCodexDeploymentJson(result.CodexDeploymentJson); - if (args.Any(a => a == "--external")) - { - result.RunnerLocation = TestRunnerLocation.ExternalToCluster; - } + result.RunnerLocation = RunnerLocationUtils.DetermineRunnerLocation(result.CodexDeployment.CodexContainers.First()); return result; } @@ -63,7 +60,6 @@ namespace ContinuousTests Console.WriteLine("ContinuousTests will run a set of tests against a codex deployment given a codex-deployment.json file." + nl + "The tests will run in an endless loop unless otherwise specified, using the test-specific timing values." + nl); - Console.WriteLine("ContinuousTests assumes you are running this tool from *inside* the Kubernetes cluster. " + "If you are not running this from a container inside the cluster, add the argument '--external'." + nl); } diff --git a/ContinuousTests/ContinuousTestRunner.cs b/ContinuousTests/ContinuousTestRunner.cs index 35ff486..533d146 100644 --- a/ContinuousTests/ContinuousTestRunner.cs +++ b/ContinuousTests/ContinuousTestRunner.cs @@ -60,7 +60,7 @@ namespace ContinuousTests if (string.IsNullOrEmpty(test.CustomK8sNamespace)) return; log.Log($"Clearing namespace '{test.CustomK8sNamespace}'..."); - var lifecycle = k8SFactory.CreateTestLifecycle(config.KubeConfigFile, config.LogPath, config.DataPath, test.CustomK8sNamespace, new DefaultTimeSet(), log, config.RunnerLocation); + var lifecycle = k8SFactory.CreateTestLifecycle(config.KubeConfigFile, config.LogPath, config.DataPath, test.CustomK8sNamespace, new DefaultTimeSet(), log); lifecycle.WorkflowCreator.CreateWorkflow().DeleteTestResources(); } @@ -71,7 +71,7 @@ namespace ContinuousTests var path = Path.Combine(config.LogPath, "containers"); if (!Directory.Exists(path)) Directory.CreateDirectory(path); - var lifecycle = k8SFactory.CreateTestLifecycle(config.KubeConfigFile, config.LogPath, config.DataPath, config.CodexDeployment.Metadata.KubeNamespace, new DefaultTimeSet(), new NullLog(), config.RunnerLocation); + var lifecycle = k8SFactory.CreateTestLifecycle(config.KubeConfigFile, config.LogPath, config.DataPath, config.CodexDeployment.Metadata.KubeNamespace, new DefaultTimeSet(), new NullLog()); var downloader = new ContinuousLogDownloader(lifecycle, config.CodexDeployment, path, cancelToken); taskFactory.Run(downloader.Run); diff --git a/ContinuousTests/K8sFactory.cs b/ContinuousTests/K8sFactory.cs index ff9b7e9..6ac661e 100644 --- a/ContinuousTests/K8sFactory.cs +++ b/ContinuousTests/K8sFactory.cs @@ -6,7 +6,7 @@ namespace ContinuousTests { public class K8sFactory { - public TestLifecycle CreateTestLifecycle(string kubeConfigFile, string logPath, string dataFilePath, string customNamespace, ITimeSet timeSet, BaseLog log, TestRunnerLocation runnerLocation) + public TestLifecycle CreateTestLifecycle(string kubeConfigFile, string logPath, string dataFilePath, string customNamespace, ITimeSet timeSet, BaseLog log) { var kubeConfig = GetKubeConfig(kubeConfigFile); var lifecycleConfig = new DistTestCore.Configuration @@ -16,7 +16,6 @@ namespace ContinuousTests logDebug: false, dataFilesPath: dataFilePath, codexLogLevel: CodexLogLevel.Debug, - runnerLocation: runnerLocation, k8sNamespacePrefix: customNamespace ); diff --git a/ContinuousTests/NodeRunner.cs b/ContinuousTests/NodeRunner.cs index 4bb335e..5b79bf5 100644 --- a/ContinuousTests/NodeRunner.cs +++ b/ContinuousTests/NodeRunner.cs @@ -91,7 +91,7 @@ namespace ContinuousTests private TestLifecycle CreateTestLifecycle() { - return k8SFactory.CreateTestLifecycle(config.KubeConfigFile, config.LogPath, config.DataPath, customNamespace, timeSet, log, config.RunnerLocation); + return k8SFactory.CreateTestLifecycle(config.KubeConfigFile, config.LogPath, config.DataPath, customNamespace, timeSet, log); } } } diff --git a/ContinuousTests/SingleTestRun.cs b/ContinuousTests/SingleTestRun.cs index cff325e..bbc4888 100644 --- a/ContinuousTests/SingleTestRun.cs +++ b/ContinuousTests/SingleTestRun.cs @@ -138,7 +138,7 @@ namespace ContinuousTests private void DownloadClusterLogs() { var k8sFactory = new K8sFactory(); - var lifecycle = k8sFactory.CreateTestLifecycle(config.KubeConfigFile, config.LogPath, "dataPath", config.CodexDeployment.Metadata.KubeNamespace, new DefaultTimeSet(), new NullLog(), config.RunnerLocation); + var lifecycle = k8sFactory.CreateTestLifecycle(config.KubeConfigFile, config.LogPath, "dataPath", config.CodexDeployment.Metadata.KubeNamespace, new DefaultTimeSet(), new NullLog()); foreach (var container in config.CodexDeployment.CodexContainers) { @@ -221,7 +221,7 @@ namespace ContinuousTests private DistTestCore.Configuration CreateFileManagerConfiguration() { return new DistTestCore.Configuration(null, string.Empty, false, dataFolder, - CodexLogLevel.Error, config.RunnerLocation, string.Empty); + CodexLogLevel.Error, string.Empty); } } } diff --git a/DistTestCore/Configuration.cs b/DistTestCore/Configuration.cs index daccad6..23dcdb1 100644 --- a/DistTestCore/Configuration.cs +++ b/DistTestCore/Configuration.cs @@ -1,5 +1,6 @@ using DistTestCore.Codex; using KubernetesWorkflow; +using System.Net.NetworkInformation; using Utils; namespace DistTestCore @@ -11,7 +12,6 @@ namespace DistTestCore private readonly bool logDebug; private readonly string dataFilesPath; private readonly CodexLogLevel codexLogLevel; - private readonly TestRunnerLocation runnerLocation; private readonly string k8sNamespacePrefix; public Configuration() @@ -21,18 +21,16 @@ namespace DistTestCore logDebug = GetEnvVarOrDefault("LOGDEBUG", "false").ToLowerInvariant() == "true"; dataFilesPath = GetEnvVarOrDefault("DATAFILEPATH", "TestDataFiles"); codexLogLevel = ParseEnum.Parse(GetEnvVarOrDefault("LOGLEVEL", nameof(CodexLogLevel.Trace))); - runnerLocation = ParseEnum.Parse(GetEnvVarOrDefault("RUNNERLOCATION", nameof(TestRunnerLocation.ExternalToCluster))); k8sNamespacePrefix = "ct-"; } - public Configuration(string? kubeConfigFile, string logPath, bool logDebug, string dataFilesPath, CodexLogLevel codexLogLevel, TestRunnerLocation runnerLocation, string k8sNamespacePrefix) + public Configuration(string? kubeConfigFile, string logPath, bool logDebug, string dataFilesPath, CodexLogLevel codexLogLevel, string k8sNamespacePrefix) { this.kubeConfigFile = kubeConfigFile; this.logPath = logPath; this.logDebug = logDebug; this.dataFilesPath = dataFilesPath; this.codexLogLevel = codexLogLevel; - this.runnerLocation = runnerLocation; this.k8sNamespacePrefix = k8sNamespacePrefix; } @@ -61,14 +59,16 @@ namespace DistTestCore return codexLogLevel; } - public TestRunnerLocation GetTestRunnerLocation() - { - return runnerLocation; - } + private RunnerLocation? runnerLocation = null; public Address GetAddress(RunningContainer container) { - if (GetTestRunnerLocation() == TestRunnerLocation.InternalToCluster) + if (runnerLocation == null) + { + runnerLocation = RunnerLocationUtils.DetermineRunnerLocation(container); + } + + if (runnerLocation == RunnerLocation.InternalToCluster) { return container.ClusterInternalAddress; } @@ -90,9 +90,56 @@ namespace DistTestCore } } - public enum TestRunnerLocation + public enum RunnerLocation { ExternalToCluster, InternalToCluster, } + + public class RunnerLocationUtils + { + private static bool alreadyDidThat = false; + + public static RunnerLocation DetermineRunnerLocation(RunningContainer container) + { + // We want to be sure we don't ping more often than strictly necessary. + // If we have already determined the location during this application + // lifetime, don't do it again. + if (alreadyDidThat) throw new Exception("We already did that."); + alreadyDidThat = true; + + if (PingHost(container.ClusterInternalAddress)) + { + return RunnerLocation.InternalToCluster; + } + if (PingHost(container.ClusterExternalAddress)) + { + return RunnerLocation.ExternalToCluster; + } + + throw new Exception("Unable to determine runner location."); + } + + private static string Format(Address host) + { + return host.Host + .Replace("http://", "") + .Replace("https://", ""); + } + + private static bool PingHost(Address host) + { + try + { + using var pinger = new Ping(); + PingReply reply = pinger.Send(Format(host)); + return reply.Status == IPStatus.Success; + } + catch (PingException) + { + } + + return false; + } + } } From 5d92b9992606bc5de2e8a94dbc6207ec48f6ead3 Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 11 Aug 2023 09:09:03 +0200 Subject: [PATCH 03/14] Determine runner location by pinging pod IP. --- DistTestCore/Configuration.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/DistTestCore/Configuration.cs b/DistTestCore/Configuration.cs index 23dcdb1..84fb766 100644 --- a/DistTestCore/Configuration.cs +++ b/DistTestCore/Configuration.cs @@ -13,6 +13,7 @@ namespace DistTestCore private readonly string dataFilesPath; private readonly CodexLogLevel codexLogLevel; private readonly string k8sNamespacePrefix; + private RunnerLocation? runnerLocation = null; public Configuration() { @@ -59,8 +60,6 @@ namespace DistTestCore return codexLogLevel; } - private RunnerLocation? runnerLocation = null; - public Address GetAddress(RunningContainer container) { if (runnerLocation == null) @@ -96,7 +95,7 @@ namespace DistTestCore InternalToCluster, } - public class RunnerLocationUtils + public static class RunnerLocationUtils { private static bool alreadyDidThat = false; @@ -108,11 +107,11 @@ namespace DistTestCore if (alreadyDidThat) throw new Exception("We already did that."); alreadyDidThat = true; - if (PingHost(container.ClusterInternalAddress)) + if (PingHost(container.Pod.PodInfo.Ip)) { return RunnerLocation.InternalToCluster; } - if (PingHost(container.ClusterExternalAddress)) + if (PingHost(Format(container.ClusterExternalAddress))) { return RunnerLocation.ExternalToCluster; } @@ -127,12 +126,12 @@ namespace DistTestCore .Replace("https://", ""); } - private static bool PingHost(Address host) + private static bool PingHost(string host) { try { using var pinger = new Ping(); - PingReply reply = pinger.Send(Format(host)); + PingReply reply = pinger.Send(host); return reply.Status == IPStatus.Success; } catch (PingException) From 9037ddab6ea15fcb080094355146e316fdc34d5c Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 11 Aug 2023 09:37:30 +0200 Subject: [PATCH 04/14] initial setup of a grafana container --- .../Metrics/GrafanaContainerRecipe.cs | 19 +++++++++++++++++++ DistTestCore/PrometheusStarter.cs | 4 ++++ KubernetesWorkflow/ContainerRecipeFactory.cs | 7 +++++++ KubernetesWorkflow/RecipeComponentFactory.cs | 5 +++++ 4 files changed, 35 insertions(+) create mode 100644 DistTestCore/Metrics/GrafanaContainerRecipe.cs diff --git a/DistTestCore/Metrics/GrafanaContainerRecipe.cs b/DistTestCore/Metrics/GrafanaContainerRecipe.cs new file mode 100644 index 0000000..5e52965 --- /dev/null +++ b/DistTestCore/Metrics/GrafanaContainerRecipe.cs @@ -0,0 +1,19 @@ +using KubernetesWorkflow; + +namespace DistTestCore.Metrics +{ + public class GrafanaContainerRecipe : ContainerRecipeFactory + { + public override string AppName => "grafana"; + public override string Image => "grafana/grafana-oss:10.0.3"; + + protected override void Initialize(StartupConfig startupConfig) + { + //var config = startupConfig.Get(); + + //AddExposedPortAndVar("PROM_PORT"); + AddExposedPort(3000); + //AddEnvVar("PROM_CONFIG", config.PrometheusConfigBase64); + } + } +} diff --git a/DistTestCore/PrometheusStarter.cs b/DistTestCore/PrometheusStarter.cs index 1804b77..862907d 100644 --- a/DistTestCore/PrometheusStarter.cs +++ b/DistTestCore/PrometheusStarter.cs @@ -22,6 +22,10 @@ namespace DistTestCore var runningContainers = workflow.Start(1, Location.Unspecified, new PrometheusContainerRecipe(), startupConfig); if (runningContainers.Containers.Length != 1) throw new InvalidOperationException("Expected only 1 Prometheus container to be created."); + workflow = lifecycle.WorkflowCreator.CreateWorkflow(); + var grafanaContainers = workflow.Start(1, Location.Unspecified, new GrafanaContainerRecipe(), startupConfig); + if (grafanaContainers.Containers.Length != 1) throw new InvalidOperationException("should be 1"); + LogEnd("Metrics server started."); return runningContainers; diff --git a/KubernetesWorkflow/ContainerRecipeFactory.cs b/KubernetesWorkflow/ContainerRecipeFactory.cs index 470bd42..36fff5b 100644 --- a/KubernetesWorkflow/ContainerRecipeFactory.cs +++ b/KubernetesWorkflow/ContainerRecipeFactory.cs @@ -40,6 +40,13 @@ return p; } + protected Port AddExposedPort(int number, string tag = "") + { + var p = factory.CreatePort(number, tag); + exposedPorts.Add(p); + return p; + } + protected Port AddInternalPort(string tag = "") { var p = factory.CreatePort(tag); diff --git a/KubernetesWorkflow/RecipeComponentFactory.cs b/KubernetesWorkflow/RecipeComponentFactory.cs index cf1f67b..9644515 100644 --- a/KubernetesWorkflow/RecipeComponentFactory.cs +++ b/KubernetesWorkflow/RecipeComponentFactory.cs @@ -7,6 +7,11 @@ namespace KubernetesWorkflow { private NumberSource portNumberSource = new NumberSource(8080); + public Port CreatePort(int number, string tag) + { + return new Port(number, tag); + } + public Port CreatePort(string tag) { return new Port(portNumberSource.GetNextNumber(), tag); From 79908b8a54768a073375957a03dad67a56f207fd Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 11 Aug 2023 10:16:19 +0200 Subject: [PATCH 05/14] disables grafana auth --- DistTestCore/Metrics/GrafanaContainerRecipe.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DistTestCore/Metrics/GrafanaContainerRecipe.cs b/DistTestCore/Metrics/GrafanaContainerRecipe.cs index 5e52965..12af581 100644 --- a/DistTestCore/Metrics/GrafanaContainerRecipe.cs +++ b/DistTestCore/Metrics/GrafanaContainerRecipe.cs @@ -14,6 +14,16 @@ namespace DistTestCore.Metrics //AddExposedPortAndVar("PROM_PORT"); AddExposedPort(3000); //AddEnvVar("PROM_CONFIG", config.PrometheusConfigBase64); + + // [auth.anonymous] + // enabled = true + //GF____FILE + + AddEnvVar("GF_AUTH_ANONYMOUS_ENABLED", "true"); + AddEnvVar("GF_AUTH_DISABLE_LOGIN_FORM", "true"); + + //[auth] + //disable_login_form = true } } } From 2acb669c3120199ab7a1c8d425c99723a3ffbcfc Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 11 Aug 2023 11:06:40 +0200 Subject: [PATCH 06/14] automatically adds prometheus as datasource --- DistTestCore/Http.cs | 4 +- .../Metrics/GrafanaContainerRecipe.cs | 4 +- DistTestCore/PrometheusStarter.cs | 91 +++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) diff --git a/DistTestCore/Http.cs b/DistTestCore/Http.cs index 391dbc7..866a640 100644 --- a/DistTestCore/Http.cs +++ b/DistTestCore/Http.cs @@ -1,4 +1,5 @@ -using Logging; +using IdentityModel.Client; +using Logging; using Newtonsoft.Json; using System.Net.Http.Headers; using System.Net.Http.Json; @@ -59,6 +60,7 @@ namespace DistTestCore var url = GetUrl() + route; using var content = JsonContent.Create(body); Log(url, JsonConvert.SerializeObject(body)); + client.SetBasicAuthentication("admin", "admin"); var result = Time.Wait(client.PostAsync(url, content)); var str = Time.Wait(result.Content.ReadAsStringAsync()); Log(url, str); diff --git a/DistTestCore/Metrics/GrafanaContainerRecipe.cs b/DistTestCore/Metrics/GrafanaContainerRecipe.cs index 12af581..b873fa8 100644 --- a/DistTestCore/Metrics/GrafanaContainerRecipe.cs +++ b/DistTestCore/Metrics/GrafanaContainerRecipe.cs @@ -19,8 +19,8 @@ namespace DistTestCore.Metrics // enabled = true //GF____FILE - AddEnvVar("GF_AUTH_ANONYMOUS_ENABLED", "true"); - AddEnvVar("GF_AUTH_DISABLE_LOGIN_FORM", "true"); + //AddEnvVar("GF_AUTH_ANONYMOUS_ENABLED", "true"); + //AddEnvVar("GF_AUTH_DISABLE_LOGIN_FORM", "true"); //[auth] //disable_login_form = true diff --git a/DistTestCore/PrometheusStarter.cs b/DistTestCore/PrometheusStarter.cs index 862907d..4e27952 100644 --- a/DistTestCore/PrometheusStarter.cs +++ b/DistTestCore/PrometheusStarter.cs @@ -1,7 +1,14 @@ using DistTestCore.Codex; using DistTestCore.Metrics; using KubernetesWorkflow; +using Logging; +using System; +using System.Diagnostics; +using System.Net.Http.Headers; using System.Text; +using Utils; +using static System.Net.Mime.MediaTypeNames; +using static System.Net.WebRequestMethods; namespace DistTestCore { @@ -22,15 +29,99 @@ namespace DistTestCore var runningContainers = workflow.Start(1, Location.Unspecified, new PrometheusContainerRecipe(), startupConfig); if (runningContainers.Containers.Length != 1) throw new InvalidOperationException("Expected only 1 Prometheus container to be created."); + var pc = runningContainers.Containers.First().ClusterExternalAddress; + var prometheusUrl = pc.Host + ":" + pc.Port; + workflow = lifecycle.WorkflowCreator.CreateWorkflow(); var grafanaContainers = workflow.Start(1, Location.Unspecified, new GrafanaContainerRecipe(), startupConfig); if (grafanaContainers.Containers.Length != 1) throw new InvalidOperationException("should be 1"); + Thread.Sleep(3000); + + var c = grafanaContainers.Containers.First().ClusterExternalAddress; + + + + //{ + // //setup reusable http client + // HttpClient client = new HttpClient(); + // Uri baseUri = new Uri(c.Host + ":" + c.Port); + // client.BaseAddress = baseUri; + // client.DefaultRequestHeaders.Clear(); + // client.DefaultRequestHeaders.ConnectionClose = true; + + // //Post body content + // var values = new List>(); + // values.Add(new KeyValuePair("grant_type", "client_credentials")); + // var content = new FormUrlEncodedContent(values); + + // var authenticationString = $"admin:admin"; + // var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(authenticationString)); + + // var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/oauth2/token"); + // requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString); + // requestMessage.Content = content; + + // //make the request + // var responsea = Time.Wait(client.SendAsync(requestMessage)); + // responsea.EnsureSuccessStatusCode(); + // string responseBody = Time.Wait(responsea.Content.ReadAsStringAsync()); + // Console.WriteLine(responseBody); + + //} + + //POST / api / datasources HTTP / 1.1 + //Accept: application / json + //Content - Type: application / json + //Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk + + var http = new Http(new NullLog(), new DefaultTimeSet(), c, "api/"); + var response = http.HttpPostJson("datasources", new GrafanaDataSource + { + name = "CodexPrometheus", + type = "prometheus", + url = prometheusUrl, + access = "proxy", + basicAuth = false, + jsonData = new GrafanaDataSourceJsonData + { + httpMethod = "POST" + } + }); + + + // [{ "id":1,"uid":"c89eaad3-9184-429f-ac94-8ba0b1824dbb","orgId":1, + // "name":"Prometheus","type":"prometheus","typeName":"Prometheus", + // "typeLogoUrl":"public/app/plugins/datasource/prometheus/img/prometheus_logo.svg", + // "access":"proxy","url":"http://kubernetes.docker.internal:31234","user":"","database":"", + // "basicAuth":false,"isDefault":true,"jsonData":{ "httpMethod":"POST"},"readOnly":false}] + + + var grafanaUrl = c.Host + ":" + c.Port; + System.Diagnostics.Process.Start("C:\\Users\\Ben\\AppData\\Local\\Programs\\Opera\\opera.exe", grafanaUrl); + LogEnd("Metrics server started."); + + return runningContainers; } + public class GrafanaDataSource + { + public string name { get; set; } = string.Empty; + public string type { get; set; } = string.Empty; + public string url { get; set; } = string.Empty; + public string access { get; set; } = string.Empty; + public bool basicAuth { get; set; } + public GrafanaDataSourceJsonData jsonData { get; set; } = new(); + } + + public class GrafanaDataSourceJsonData + { + public string httpMethod { get; set; } = string.Empty; + } + private string GeneratePrometheusConfig(RunningContainer[] nodes) { var config = ""; From 485af03367c345096d316aae0059973585cb5dc0 Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 11 Aug 2023 12:38:26 +0200 Subject: [PATCH 07/14] very wip: automatic grafana dashboard --- DistTestCore/DistTestCore.csproj | 8 + DistTestCore/Http.cs | 17 +++ .../Metrics/GrafanaContainerRecipe.cs | 4 +- DistTestCore/Metrics/dashboard.json | 138 ++++++++++++++++++ DistTestCore/PrometheusStarter.cs | 68 +++------ 5 files changed, 183 insertions(+), 52 deletions(-) create mode 100644 DistTestCore/Metrics/dashboard.json diff --git a/DistTestCore/DistTestCore.csproj b/DistTestCore/DistTestCore.csproj index 512d692..94a2271 100644 --- a/DistTestCore/DistTestCore.csproj +++ b/DistTestCore/DistTestCore.csproj @@ -10,6 +10,14 @@ Arm64 + + + + + + Never + + diff --git a/DistTestCore/Http.cs b/DistTestCore/Http.cs index 866a640..1239fd7 100644 --- a/DistTestCore/Http.cs +++ b/DistTestCore/Http.cs @@ -68,6 +68,23 @@ namespace DistTestCore }, $"HTTP-POST-JSON: {route}"); } + public string HttpPostString(string route, string body) + { + return Retry(() => + { + using var client = GetClient(); + var url = GetUrl() + route; + Log(url, body); + client.SetBasicAuthentication("admin", "admin"); + var content = new StringContent(body); + content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); + var result = Time.Wait(client.PostAsync(url, content)); + var str = Time.Wait(result.Content.ReadAsStringAsync()); + Log(url, str); + return str; + }, $"HTTP-POST-STRING: {route}"); + } + public string HttpPostStream(string route, Stream stream) { return Retry(() => diff --git a/DistTestCore/Metrics/GrafanaContainerRecipe.cs b/DistTestCore/Metrics/GrafanaContainerRecipe.cs index b873fa8..12af581 100644 --- a/DistTestCore/Metrics/GrafanaContainerRecipe.cs +++ b/DistTestCore/Metrics/GrafanaContainerRecipe.cs @@ -19,8 +19,8 @@ namespace DistTestCore.Metrics // enabled = true //GF____FILE - //AddEnvVar("GF_AUTH_ANONYMOUS_ENABLED", "true"); - //AddEnvVar("GF_AUTH_DISABLE_LOGIN_FORM", "true"); + AddEnvVar("GF_AUTH_ANONYMOUS_ENABLED", "true"); + AddEnvVar("GF_AUTH_DISABLE_LOGIN_FORM", "true"); //[auth] //disable_login_form = true diff --git a/DistTestCore/Metrics/dashboard.json b/DistTestCore/Metrics/dashboard.json new file mode 100644 index 0000000..59b6bbb --- /dev/null +++ b/DistTestCore/Metrics/dashboard.json @@ -0,0 +1,138 @@ +{ + "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": [ + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "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" + }, + "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": "" + }, + "message": "Default Codex Dashboard", + "overwrite": false +} diff --git a/DistTestCore/PrometheusStarter.cs b/DistTestCore/PrometheusStarter.cs index 4e27952..d58ba6d 100644 --- a/DistTestCore/PrometheusStarter.cs +++ b/DistTestCore/PrometheusStarter.cs @@ -2,13 +2,8 @@ using DistTestCore.Metrics; using KubernetesWorkflow; using Logging; -using System; -using System.Diagnostics; -using System.Net.Http.Headers; +using System.Reflection; using System.Text; -using Utils; -using static System.Net.Mime.MediaTypeNames; -using static System.Net.WebRequestMethods; namespace DistTestCore { @@ -40,44 +35,10 @@ namespace DistTestCore var c = grafanaContainers.Containers.First().ClusterExternalAddress; - - - //{ - // //setup reusable http client - // HttpClient client = new HttpClient(); - // Uri baseUri = new Uri(c.Host + ":" + c.Port); - // client.BaseAddress = baseUri; - // client.DefaultRequestHeaders.Clear(); - // client.DefaultRequestHeaders.ConnectionClose = true; - - // //Post body content - // var values = new List>(); - // values.Add(new KeyValuePair("grant_type", "client_credentials")); - // var content = new FormUrlEncodedContent(values); - - // var authenticationString = $"admin:admin"; - // var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(authenticationString)); - - // var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/oauth2/token"); - // requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString); - // requestMessage.Content = content; - - // //make the request - // var responsea = Time.Wait(client.SendAsync(requestMessage)); - // responsea.EnsureSuccessStatusCode(); - // string responseBody = Time.Wait(responsea.Content.ReadAsStringAsync()); - // Console.WriteLine(responseBody); - - //} - - //POST / api / datasources HTTP / 1.1 - //Accept: application / json - //Content - Type: application / json - //Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk - var http = new Http(new NullLog(), new DefaultTimeSet(), c, "api/"); var response = http.HttpPostJson("datasources", new GrafanaDataSource { + uid = "c89eaad3-9184-429f-ac94-8ba0b1824dbb", name = "CodexPrometheus", type = "prometheus", url = prometheusUrl, @@ -89,26 +50,19 @@ namespace DistTestCore } }); - - // [{ "id":1,"uid":"c89eaad3-9184-429f-ac94-8ba0b1824dbb","orgId":1, - // "name":"Prometheus","type":"prometheus","typeName":"Prometheus", - // "typeLogoUrl":"public/app/plugins/datasource/prometheus/img/prometheus_logo.svg", - // "access":"proxy","url":"http://kubernetes.docker.internal:31234","user":"","database":"", - // "basicAuth":false,"isDefault":true,"jsonData":{ "httpMethod":"POST"},"readOnly":false}] - + var response2 = http.HttpPostString("dashboards/db", GetDashboardJson()); var grafanaUrl = c.Host + ":" + c.Port; System.Diagnostics.Process.Start("C:\\Users\\Ben\\AppData\\Local\\Programs\\Opera\\opera.exe", grafanaUrl); LogEnd("Metrics server started."); - - return runningContainers; } public class GrafanaDataSource { + public string uid { get; set; } = string.Empty; public string name { get; set; } = string.Empty; public string type { get; set; } = string.Empty; public string url { get; set; } = string.Empty; @@ -122,6 +76,20 @@ namespace DistTestCore public string httpMethod { get; set; } = string.Empty; } + private string GetDashboardJson() + { + var assembly = Assembly.GetExecutingAssembly(); + var resourceName = "DistTestCore.Metrics.dashboard.json"; + + //var names = assembly.GetManifestResourceNames(); + + using (Stream stream = assembly.GetManifestResourceStream(resourceName)) + using (StreamReader reader = new StreamReader(stream)) + { + return reader.ReadToEnd(); + } + } + private string GeneratePrometheusConfig(RunningContainer[] nodes) { var config = ""; From 75228c815dfb1576cf195cff9565c0e5b018e047 Mon Sep 17 00:00:00 2001 From: benbierens Date: Sun, 13 Aug 2023 08:27:30 +0200 Subject: [PATCH 08/14] fixes dashboard permissions --- .../Metrics/GrafanaContainerRecipe.cs | 6 +- DistTestCore/Metrics/dashboard.json | 248 +++++++++--------- DistTestCore/PrometheusStarter.cs | 18 +- 3 files changed, 143 insertions(+), 129 deletions(-) diff --git a/DistTestCore/Metrics/GrafanaContainerRecipe.cs b/DistTestCore/Metrics/GrafanaContainerRecipe.cs index 12af581..272001e 100644 --- a/DistTestCore/Metrics/GrafanaContainerRecipe.cs +++ b/DistTestCore/Metrics/GrafanaContainerRecipe.cs @@ -20,7 +20,11 @@ namespace DistTestCore.Metrics //GF____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 diff --git a/DistTestCore/Metrics/dashboard.json b/DistTestCore/Metrics/dashboard.json index 59b6bbb..038a0f2 100644 --- a/DistTestCore/Metrics/dashboard.json +++ b/DistTestCore/Metrics/dashboard.json @@ -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": "" +} \ No newline at end of file diff --git a/DistTestCore/PrometheusStarter.cs b/DistTestCore/PrometheusStarter.cs index d58ba6d..839061b 100644 --- a/DistTestCore/PrometheusStarter.cs +++ b/DistTestCore/PrometheusStarter.cs @@ -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(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}}"; } } From fc3f424208b2c1cde9207cb353c2b22caf14c2f9 Mon Sep 17 00:00:00 2001 From: benbierens Date: Sun, 13 Aug 2023 08:40:32 +0200 Subject: [PATCH 09/14] Splits up grafana starter --- DistTestCore/GrafanaStarter.cs | 113 ++++++++++++++++++++++++++++++ DistTestCore/PrometheusStarter.cs | 79 --------------------- DistTestCore/TestLifecycle.cs | 2 + 3 files changed, 115 insertions(+), 79 deletions(-) create mode 100644 DistTestCore/GrafanaStarter.cs diff --git a/DistTestCore/GrafanaStarter.cs b/DistTestCore/GrafanaStarter.cs new file mode 100644 index 0000000..b3ce38a --- /dev/null +++ b/DistTestCore/GrafanaStarter.cs @@ -0,0 +1,113 @@ +using DistTestCore.Metrics; +using KubernetesWorkflow; +using Logging; +using Newtonsoft.Json; +using System.Reflection; + +namespace DistTestCore +{ + public class GrafanaStarter : BaseStarter + { + public GrafanaStarter(TestLifecycle lifecycle) + : base(lifecycle) + { + } + public GrafanaStartInfo StartDashboard(RunningContainer prometheusContainer) + { + LogStart($"Starting dashboard server"); + var startupConfig = new StartupConfig(); + + var pc = prometheusContainer.ClusterExternalAddress; + var prometheusUrl = pc.Host + ":" + pc.Port; + + var workflow = lifecycle.WorkflowCreator.CreateWorkflow(); + var grafanaContainers = workflow.Start(1, Location.Unspecified, new GrafanaContainerRecipe(), startupConfig); + if (grafanaContainers.Containers.Length != 1) throw new InvalidOperationException("Expected 1 dashboard container to be created."); + + //Thread.Sleep(3000); + + var grafanaContainer = grafanaContainers.Containers.First(); + var c = grafanaContainer.ClusterExternalAddress; + + var http = new Http(new NullLog(), new DefaultTimeSet(), c, "api/"); + + // {"datasource":{"id":1,"uid":"c89eaad3-9184-429f-ac94-8ba0b1824dbb","orgId":1,"name":"CodexPrometheus","type":"prometheus","typeLogoUrl":"","access":"proxy","url":"http://kubernetes.docker.internal:31971","user":"","database":"","basicAuth":false,"basicAuthUser":"","withCredentials":false,"isDefault":false,"jsonData":{"httpMethod":"POST"},"secureJsonFields":{},"version":1,"readOnly":false},"id":1,"message":"Datasource added","name":"CodexPrometheus"} + var response = http.HttpPostJson("datasources", new GrafanaDataSource + { + uid = "c89eaad3-9184-429f-ac94-8ba0b1824dbb", + name = "CodexPrometheus", + type = "prometheus", + url = prometheusUrl, + access = "proxy", + basicAuth = false, + jsonData = new GrafanaDataSourceJsonData + { + httpMethod = "POST" + } + }); + + var response2 = http.HttpPostString("dashboards/db", GetDashboardJson()); + var jsonResponse = JsonConvert.DeserializeObject(response2); + + 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."); + + return new GrafanaStartInfo(grafanaUrl, grafanaContainer); + } + + private string GetDashboardJson() + { + var assembly = Assembly.GetExecutingAssembly(); + var resourceName = "DistTestCore.Metrics.dashboard.json"; + + using (Stream stream = assembly.GetManifestResourceStream(resourceName)) + using (StreamReader reader = new StreamReader(stream)) + { + var dashboard = reader.ReadToEnd(); + + return $"{{\"dashboard\": {dashboard} ,\"message\": \"Default Codex Dashboard\",\"overwrite\": false}}"; + } + } + } + + public class GrafanaStartInfo + { + public GrafanaStartInfo(string dashboardUrl, RunningContainer container) + { + DashboardUrl = dashboardUrl; + Container = container; + } + + public string DashboardUrl { get; } + public RunningContainer Container { get; } + } + + public class GrafanaDataSource + { + public string uid { get; set; } = string.Empty; + public string name { get; set; } = string.Empty; + public string type { get; set; } = string.Empty; + public string url { get; set; } = string.Empty; + public string access { get; set; } = string.Empty; + public bool basicAuth { get; set; } + public GrafanaDataSourceJsonData jsonData { get; set; } = new(); + } + + public class GrafanaDataSourceJsonData + { + 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; } + } + +} diff --git a/DistTestCore/PrometheusStarter.cs b/DistTestCore/PrometheusStarter.cs index 839061b..3b1e49c 100644 --- a/DistTestCore/PrometheusStarter.cs +++ b/DistTestCore/PrometheusStarter.cs @@ -1,9 +1,6 @@ using DistTestCore.Codex; using DistTestCore.Metrics; using KubernetesWorkflow; -using Logging; -using Newtonsoft.Json; -using System.Reflection; using System.Text; namespace DistTestCore @@ -25,85 +22,9 @@ namespace DistTestCore var runningContainers = workflow.Start(1, Location.Unspecified, new PrometheusContainerRecipe(), startupConfig); if (runningContainers.Containers.Length != 1) throw new InvalidOperationException("Expected only 1 Prometheus container to be created."); - var pc = runningContainers.Containers.First().ClusterExternalAddress; - var prometheusUrl = pc.Host + ":" + pc.Port; - - workflow = lifecycle.WorkflowCreator.CreateWorkflow(); - var grafanaContainers = workflow.Start(1, Location.Unspecified, new GrafanaContainerRecipe(), startupConfig); - if (grafanaContainers.Containers.Length != 1) throw new InvalidOperationException("should be 1"); - - Thread.Sleep(3000); - - var c = grafanaContainers.Containers.First().ClusterExternalAddress; - - var http = new Http(new NullLog(), new DefaultTimeSet(), c, "api/"); - var response = http.HttpPostJson("datasources", new GrafanaDataSource - { - uid = "c89eaad3-9184-429f-ac94-8ba0b1824dbb", - name = "CodexPrometheus", - type = "prometheus", - url = prometheusUrl, - access = "proxy", - basicAuth = false, - jsonData = new GrafanaDataSourceJsonData - { - httpMethod = "POST" - } - }); - - var response2 = http.HttpPostString("dashboards/db", GetDashboardJson()); - var jsonResponse = JsonConvert.DeserializeObject(response2); - - 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."); - return runningContainers; } - public class GrafanaDataSource - { - public string uid { get; set; } = string.Empty; - public string name { get; set; } = string.Empty; - public string type { get; set; } = string.Empty; - public string url { get; set; } = string.Empty; - public string access { get; set; } = string.Empty; - public bool basicAuth { get; set; } - public GrafanaDataSourceJsonData jsonData { get; set; } = new(); - } - - public class GrafanaDataSourceJsonData - { - 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(); - var resourceName = "DistTestCore.Metrics.dashboard.json"; - - //var names = assembly.GetManifestResourceNames(); - - using (Stream stream = assembly.GetManifestResourceStream(resourceName)) - using (StreamReader reader = new StreamReader(stream)) - { - var dashboard = reader.ReadToEnd(); - - return $"{{\"dashboard\": {dashboard} ,\"message\": \"Default Codex Dashboard\",\"overwrite\": false}}"; - } - } - private string GeneratePrometheusConfig(RunningContainer[] nodes) { var config = ""; diff --git a/DistTestCore/TestLifecycle.cs b/DistTestCore/TestLifecycle.cs index eede32d..0958898 100644 --- a/DistTestCore/TestLifecycle.cs +++ b/DistTestCore/TestLifecycle.cs @@ -24,6 +24,7 @@ namespace DistTestCore FileManager = new FileManager(Log, configuration); CodexStarter = new CodexStarter(this); PrometheusStarter = new PrometheusStarter(this); + GrafanaStarter = new GrafanaStarter(this); GethStarter = new GethStarter(this); testStart = DateTime.UtcNow; CodexVersion = null; @@ -38,6 +39,7 @@ namespace DistTestCore public FileManager FileManager { get; } public CodexStarter CodexStarter { get; } public PrometheusStarter PrometheusStarter { get; } + public GrafanaStarter GrafanaStarter { get; } public GethStarter GethStarter { get; } public CodexDebugVersionResponse? CodexVersion { get; private set; } From f1131abf793aabd70d9924877c391c5659dffd1e Mon Sep 17 00:00:00 2001 From: benbierens Date: Sun, 13 Aug 2023 09:07:23 +0200 Subject: [PATCH 10/14] Wires dashboard into deployer --- CodexNetDeployer/CodexNodeStarter.cs | 2 +- CodexNetDeployer/Configuration.cs | 5 +++-- CodexNetDeployer/Deployer.cs | 18 ++++++++++++------ CodexNetDeployer/deploy-continuous-testnet.sh | 2 +- DistTestCore/Codex/CodexContainerRecipe.cs | 2 +- DistTestCore/Codex/CodexDeployment.cs | 4 +++- DistTestCore/Codex/CodexStartupConfig.cs | 3 ++- DistTestCore/CodexSetup.cs | 2 +- DistTestCore/CodexStarter.cs | 8 +++++++- DistTestCore/Metrics/MetricsMode.cs | 9 +++++++++ 10 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 DistTestCore/Metrics/MetricsMode.cs diff --git a/CodexNetDeployer/CodexNodeStarter.cs b/CodexNetDeployer/CodexNodeStarter.cs index 0a3b373..836e8f8 100644 --- a/CodexNetDeployer/CodexNodeStarter.cs +++ b/CodexNetDeployer/CodexNodeStarter.cs @@ -84,7 +84,7 @@ namespace CodexNetDeployer var marketplaceConfig = new MarketplaceInitialConfig(100000.Eth(), 0.TestTokens(), validatorsLeft > 0); marketplaceConfig.AccountIndexOverride = i; codexStart.MarketplaceConfig = marketplaceConfig; - codexStart.MetricsEnabled = config.RecordMetrics; + codexStart.MetricsMode = config.Metrics; if (config.BlockTTL != Configuration.SecondsIn1Day) { diff --git a/CodexNetDeployer/Configuration.cs b/CodexNetDeployer/Configuration.cs index ee7ac7e..0257389 100644 --- a/CodexNetDeployer/Configuration.cs +++ b/CodexNetDeployer/Configuration.cs @@ -1,5 +1,6 @@ using ArgsUniform; using DistTestCore.Codex; +using DistTestCore.Metrics; namespace CodexNetDeployer { @@ -43,8 +44,8 @@ namespace CodexNetDeployer [Uniform("block-ttl", "bt", "BLOCKTTL", false, "Block timeout in seconds. Default is 24 hours.")] public int BlockTTL { get; set; } = SecondsIn1Day; - [Uniform("record-metrics", "rm", "RECORDMETRICS", false, "If true, metrics will be collected for all Codex nodes.")] - public bool RecordMetrics { get; set; } = false; + [Uniform("metrics", "m", "METRICS", false, "[None*, Record, Dashboard]. Determines if metrics will be recorded and if a dashboard service will be created.")] + public MetricsMode Metrics { get; set; } = MetricsMode.None; [Uniform("teststype-podlabel", "ttpl", "TESTSTYPE-PODLABEL", false, "Each kubernetes pod will be created with a label 'teststype' with value 'continuous'. " + "set this option to override the label value.")] diff --git a/CodexNetDeployer/Deployer.cs b/CodexNetDeployer/Deployer.cs index feb750e..e790320 100644 --- a/CodexNetDeployer/Deployer.cs +++ b/CodexNetDeployer/Deployer.cs @@ -27,7 +27,7 @@ namespace CodexNetDeployer // We trick the Geth companion node into unlocking all of its accounts, by saying we want to start 999 codex nodes. var setup = new CodexSetup(999, config.CodexLogLevel); setup.WithStorageQuota(config.StorageQuota!.Value.MB()).EnableMarketplace(0.TestTokens()); - setup.MetricsEnabled = config.RecordMetrics; + setup.MetricsMode = config.Metrics; Log("Creating Geth instance and deploying contracts..."); var gethStarter = new GethStarter(lifecycle); @@ -52,9 +52,9 @@ namespace CodexNetDeployer if (container != null) codexContainers.Add(container); } - var prometheusContainer = StartMetricsService(lifecycle, setup, codexContainers); + var (prometheusContainer, grafanaStartInfo) = StartMetricsService(lifecycle, setup, codexContainers); - return new CodexDeployment(gethResults, codexContainers.ToArray(), prometheusContainer, CreateMetadata()); + return new CodexDeployment(gethResults, codexContainers.ToArray(), prometheusContainer, grafanaStartInfo, CreateMetadata()); } private TestLifecycle CreateTestLifecycle() @@ -74,13 +74,19 @@ namespace CodexNetDeployer return new TestLifecycle(log, lifecycleConfig, timeset, config.TestsTypePodLabel, string.Empty); } - private RunningContainer? StartMetricsService(TestLifecycle lifecycle, CodexSetup setup, List codexContainers) + private (RunningContainer?, GrafanaStartInfo?) StartMetricsService(TestLifecycle lifecycle, CodexSetup setup, List codexContainers) { - if (!setup.MetricsEnabled) return null; + if (setup.MetricsMode == DistTestCore.Metrics.MetricsMode.None) return (null, null); Log("Starting metrics service..."); var runningContainers = new[] { new RunningContainers(null!, null!, codexContainers.ToArray()) }; - return lifecycle.PrometheusStarter.CollectMetricsFor(runningContainers).Containers.Single(); + var prometheusContainer = lifecycle.PrometheusStarter.CollectMetricsFor(runningContainers).Containers.Single(); + + if (setup.MetricsMode == DistTestCore.Metrics.MetricsMode.Record) return (prometheusContainer, null); + + Log("Starting dashboard service..."); + var grafanaStartInfo = lifecycle.GrafanaStarter.StartDashboard(prometheusContainer); + return (prometheusContainer, grafanaStartInfo); } private string? GetKubeConfig(string kubeConfigFile) diff --git a/CodexNetDeployer/deploy-continuous-testnet.sh b/CodexNetDeployer/deploy-continuous-testnet.sh index 338b8c1..c0460c8 100644 --- a/CodexNetDeployer/deploy-continuous-testnet.sh +++ b/CodexNetDeployer/deploy-continuous-testnet.sh @@ -10,4 +10,4 @@ dotnet run \ --max-collateral=1024 \ --max-duration=3600000 \ --block-ttl=300 \ - --record-metrics=true + --metrics=Dashboard diff --git a/DistTestCore/Codex/CodexContainerRecipe.cs b/DistTestCore/Codex/CodexContainerRecipe.cs index c600c01..64f85c3 100644 --- a/DistTestCore/Codex/CodexContainerRecipe.cs +++ b/DistTestCore/Codex/CodexContainerRecipe.cs @@ -51,7 +51,7 @@ namespace DistTestCore.Codex { AddEnvVar("CODEX_BLOCK_TTL", config.BlockTTL.ToString()!); } - if (config.MetricsEnabled) + if (config.MetricsMode != Metrics.MetricsMode.None) { AddEnvVar("CODEX_METRICS", "true"); AddEnvVar("CODEX_METRICS_ADDRESS", "0.0.0.0"); diff --git a/DistTestCore/Codex/CodexDeployment.cs b/DistTestCore/Codex/CodexDeployment.cs index 52192dc..b22c77a 100644 --- a/DistTestCore/Codex/CodexDeployment.cs +++ b/DistTestCore/Codex/CodexDeployment.cs @@ -5,17 +5,19 @@ namespace DistTestCore.Codex { public class CodexDeployment { - public CodexDeployment(GethStartResult gethStartResult, RunningContainer[] codexContainers, RunningContainer? prometheusContainer, DeploymentMetadata metadata) + public CodexDeployment(GethStartResult gethStartResult, RunningContainer[] codexContainers, RunningContainer? prometheusContainer, GrafanaStartInfo? grafanaStartInfo, DeploymentMetadata metadata) { GethStartResult = gethStartResult; CodexContainers = codexContainers; PrometheusContainer = prometheusContainer; + GrafanaStartInfo = grafanaStartInfo; Metadata = metadata; } public GethStartResult GethStartResult { get; } public RunningContainer[] CodexContainers { get; } public RunningContainer? PrometheusContainer { get; } + public GrafanaStartInfo? GrafanaStartInfo { get; } public DeploymentMetadata Metadata { get; } } diff --git a/DistTestCore/Codex/CodexStartupConfig.cs b/DistTestCore/Codex/CodexStartupConfig.cs index 2a17334..5e72755 100644 --- a/DistTestCore/Codex/CodexStartupConfig.cs +++ b/DistTestCore/Codex/CodexStartupConfig.cs @@ -1,4 +1,5 @@ using DistTestCore.Marketplace; +using DistTestCore.Metrics; using KubernetesWorkflow; namespace DistTestCore.Codex @@ -14,7 +15,7 @@ namespace DistTestCore.Codex public Location Location { get; set; } public CodexLogLevel LogLevel { get; } public ByteSize? StorageQuota { get; set; } - public bool MetricsEnabled { get; set; } + public MetricsMode MetricsMode { get; set; } public MarketplaceInitialConfig? MarketplaceConfig { get; set; } public string? BootstrapSpr { get; set; } public int? BlockTTL { get; set; } diff --git a/DistTestCore/CodexSetup.cs b/DistTestCore/CodexSetup.cs index 0ffb713..4aefd39 100644 --- a/DistTestCore/CodexSetup.cs +++ b/DistTestCore/CodexSetup.cs @@ -59,7 +59,7 @@ namespace DistTestCore public ICodexSetup EnableMetrics() { - MetricsEnabled = true; + MetricsMode = Metrics.MetricsMode.Record; return this; } diff --git a/DistTestCore/CodexStarter.cs b/DistTestCore/CodexStarter.cs index a1e38b7..52686f1 100644 --- a/DistTestCore/CodexStarter.cs +++ b/DistTestCore/CodexStarter.cs @@ -68,9 +68,15 @@ namespace DistTestCore private IMetricsAccessFactory CollectMetrics(CodexSetup codexSetup, RunningContainers[] containers) { - if (!codexSetup.MetricsEnabled) return new MetricsUnavailableAccessFactory(); + if (codexSetup.MetricsMode == MetricsMode.None) return new MetricsUnavailableAccessFactory(); var runningContainers = lifecycle.PrometheusStarter.CollectMetricsFor(containers); + + if (codexSetup.MetricsMode == MetricsMode.Dashboard) + { + var info = lifecycle.GrafanaStarter.StartDashboard(runningContainers.Containers.First()); + } + return new CodexNodeMetricsAccessFactory(lifecycle, runningContainers); } diff --git a/DistTestCore/Metrics/MetricsMode.cs b/DistTestCore/Metrics/MetricsMode.cs new file mode 100644 index 0000000..60b4f5e --- /dev/null +++ b/DistTestCore/Metrics/MetricsMode.cs @@ -0,0 +1,9 @@ +namespace DistTestCore.Metrics +{ + public enum MetricsMode + { + None, + Record, + Dashboard + } +} From de662363833d1e1781beb08213b09943d7881ebd Mon Sep 17 00:00:00 2001 From: benbierens Date: Sun, 13 Aug 2023 10:01:06 +0200 Subject: [PATCH 11/14] Cleans up grafana starter. --- DistTestCore/CodexStarter.cs | 2 +- DistTestCore/GrafanaStarter.cs | 105 ++++++++++++++++++++++----------- 2 files changed, 72 insertions(+), 35 deletions(-) diff --git a/DistTestCore/CodexStarter.cs b/DistTestCore/CodexStarter.cs index 52686f1..3c35e42 100644 --- a/DistTestCore/CodexStarter.cs +++ b/DistTestCore/CodexStarter.cs @@ -74,7 +74,7 @@ namespace DistTestCore if (codexSetup.MetricsMode == MetricsMode.Dashboard) { - var info = lifecycle.GrafanaStarter.StartDashboard(runningContainers.Containers.First()); + lifecycle.GrafanaStarter.StartDashboard(runningContainers.Containers.First()); } return new CodexNodeMetricsAccessFactory(lifecycle, runningContainers); diff --git a/DistTestCore/GrafanaStarter.cs b/DistTestCore/GrafanaStarter.cs index b3ce38a..82a4614 100644 --- a/DistTestCore/GrafanaStarter.cs +++ b/DistTestCore/GrafanaStarter.cs @@ -1,8 +1,8 @@ using DistTestCore.Metrics; using KubernetesWorkflow; -using Logging; using Newtonsoft.Json; using System.Reflection; +using Utils; namespace DistTestCore { @@ -15,24 +15,40 @@ namespace DistTestCore public GrafanaStartInfo StartDashboard(RunningContainer prometheusContainer) { LogStart($"Starting dashboard server"); + + var grafanaContainer = StartGrafanaContainer(); + var grafanaAddress = lifecycle.Configuration.GetAddress(grafanaContainer); + + var http = new Http(lifecycle.Log, new DefaultTimeSet(), grafanaAddress, "api/"); + + Log("Connecting datasource..."); + AddDataSource(http, prometheusContainer); + + Log("Uploading dashboard configurations..."); + var jsons = ReadEachDashboardJsonFile(); + var dashboardUrls = jsons.Select(j => UploadDashboard(http, grafanaAddress, j)).ToArray(); + + LogEnd("Dashboard server started."); + + return new GrafanaStartInfo(dashboardUrls, grafanaContainer); + } + + private RunningContainer StartGrafanaContainer() + { var startupConfig = new StartupConfig(); - - var pc = prometheusContainer.ClusterExternalAddress; - var prometheusUrl = pc.Host + ":" + pc.Port; var workflow = lifecycle.WorkflowCreator.CreateWorkflow(); var grafanaContainers = workflow.Start(1, Location.Unspecified, new GrafanaContainerRecipe(), startupConfig); if (grafanaContainers.Containers.Length != 1) throw new InvalidOperationException("Expected 1 dashboard container to be created."); - //Thread.Sleep(3000); + return grafanaContainers.Containers.First(); + } - var grafanaContainer = grafanaContainers.Containers.First(); - var c = grafanaContainer.ClusterExternalAddress; - - var http = new Http(new NullLog(), new DefaultTimeSet(), c, "api/"); - - // {"datasource":{"id":1,"uid":"c89eaad3-9184-429f-ac94-8ba0b1824dbb","orgId":1,"name":"CodexPrometheus","type":"prometheus","typeLogoUrl":"","access":"proxy","url":"http://kubernetes.docker.internal:31971","user":"","database":"","basicAuth":false,"basicAuthUser":"","withCredentials":false,"isDefault":false,"jsonData":{"httpMethod":"POST"},"secureJsonFields":{},"version":1,"readOnly":false},"id":1,"message":"Datasource added","name":"CodexPrometheus"} - var response = http.HttpPostJson("datasources", new GrafanaDataSource + private static void AddDataSource(Http http, RunningContainer prometheusContainer) + { + var prometheusAddress = prometheusContainer.ClusterExternalAddress; + var prometheusUrl = prometheusAddress.Host + ":" + prometheusAddress.Port; + var response = http.HttpPostJson("datasources", new GrafanaDataSourceRequest { uid = "c89eaad3-9184-429f-ac94-8ba0b1824dbb", name = "CodexPrometheus", @@ -46,45 +62,60 @@ namespace DistTestCore } }); - var response2 = http.HttpPostString("dashboards/db", GetDashboardJson()); - var jsonResponse = JsonConvert.DeserializeObject(response2); - - 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."); - - return new GrafanaStartInfo(grafanaUrl, grafanaContainer); + if (response.message != "Datasource added") + { + throw new Exception("Test infra failure: Failed to add datasource to dashboard: " + response.message); + } } - private string GetDashboardJson() + public static string UploadDashboard(Http http, Address grafanaAddress, string dashboardJson) + { + var request = GetDashboardCreateRequest(dashboardJson); + var response = http.HttpPostString("dashboards/db", request); + var jsonResponse = JsonConvert.DeserializeObject(response); + if (jsonResponse == null || string.IsNullOrEmpty(jsonResponse.url)) throw new Exception("Failed to upload dashboard."); + + return grafanaAddress.Host + ":" + grafanaAddress.Port + jsonResponse.url; + } + + private static string[] ReadEachDashboardJsonFile() { var assembly = Assembly.GetExecutingAssembly(); - var resourceName = "DistTestCore.Metrics.dashboard.json"; - - using (Stream stream = assembly.GetManifestResourceStream(resourceName)) - using (StreamReader reader = new StreamReader(stream)) + var resourceNames = new[] { - var dashboard = reader.ReadToEnd(); + "DistTestCore.Metrics.dashboard.json" + }; - return $"{{\"dashboard\": {dashboard} ,\"message\": \"Default Codex Dashboard\",\"overwrite\": false}}"; - } + return resourceNames.Select(r => GetManifestResource(assembly, r)).ToArray(); + } + + private static string GetManifestResource(Assembly assembly, string resourceName) + { + using var stream = assembly.GetManifestResourceStream(resourceName); + if (stream == null) throw new Exception("Unable to find resource " + resourceName); + using var reader = new StreamReader(stream); + return reader.ReadToEnd(); + } + + private static string GetDashboardCreateRequest(string dashboardJson) + { + return $"{{\"dashboard\": {dashboardJson} ,\"message\": \"Default Codex Dashboard\",\"overwrite\": false}}"; } } public class GrafanaStartInfo { - public GrafanaStartInfo(string dashboardUrl, RunningContainer container) + public GrafanaStartInfo(string[] dashboardUrls, RunningContainer container) { - DashboardUrl = dashboardUrl; + DashboardUrls = dashboardUrls; Container = container; } - public string DashboardUrl { get; } + public string[] DashboardUrls { get; } public RunningContainer Container { get; } } - public class GrafanaDataSource + public class GrafanaDataSourceRequest { public string uid { get; set; } = string.Empty; public string name { get; set; } = string.Empty; @@ -95,6 +126,13 @@ namespace DistTestCore public GrafanaDataSourceJsonData jsonData { get; set; } = new(); } + public class GrafanaDataSourceResponse + { + public int id { get; set; } + public string message { get; set; } = string.Empty; + public string name { get; set; } = string.Empty; + } + public class GrafanaDataSourceJsonData { public string httpMethod { get; set; } = string.Empty; @@ -109,5 +147,4 @@ namespace DistTestCore public string url { get; set; } = string.Empty; public int version { get; set; } } - } From bce8a48cade7a915e00381d869beaf6eece4794f Mon Sep 17 00:00:00 2001 From: benbierens Date: Sun, 13 Aug 2023 10:07:47 +0200 Subject: [PATCH 12/14] logs grafana image id --- CodexNetDeployer/Program.cs | 3 ++- DistTestCore/TestLifecycle.cs | 3 ++- KubernetesWorkflow/PodLabels.cs | 1 + Logging/ApplicationIds.cs | 4 +++- Logging/StatusLog.cs | 2 ++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CodexNetDeployer/Program.cs b/CodexNetDeployer/Program.cs index 9c1ecbf..da18e01 100644 --- a/CodexNetDeployer/Program.cs +++ b/CodexNetDeployer/Program.cs @@ -30,7 +30,8 @@ public class Program $"\tCodex image: '{new CodexContainerRecipe().Image}'" + nl + $"\tCodexContracts image: '{new CodexContractsContainerRecipe().Image}'" + nl + $"\tPrometheus image: '{new PrometheusContainerRecipe().Image}'" + nl + - $"\tGeth image: '{new GethContainerRecipe().Image}'" + nl); + $"\tGeth image: '{new GethContainerRecipe().Image}'" + nl + + $"\tGrafana image: '{new GrafanaContainerRecipe().Image}'" + nl); if (!args.Any(a => a == "-y")) { diff --git a/DistTestCore/TestLifecycle.cs b/DistTestCore/TestLifecycle.cs index 0958898..260e438 100644 --- a/DistTestCore/TestLifecycle.cs +++ b/DistTestCore/TestLifecycle.cs @@ -78,7 +78,8 @@ namespace DistTestCore codexId: GetCodexId(), gethId: new GethContainerRecipe().Image, prometheusId: new PrometheusContainerRecipe().Image, - codexContractsId: new CodexContractsContainerRecipe().Image + codexContractsId: new CodexContractsContainerRecipe().Image, + grafanaId: new GrafanaContainerRecipe().Image ); } diff --git a/KubernetesWorkflow/PodLabels.cs b/KubernetesWorkflow/PodLabels.cs index 60fc332..85b3a98 100644 --- a/KubernetesWorkflow/PodLabels.cs +++ b/KubernetesWorkflow/PodLabels.cs @@ -25,6 +25,7 @@ namespace KubernetesWorkflow Add("gethid", applicationIds.GethId); Add("prometheusid", applicationIds.PrometheusId); Add("codexcontractsid", applicationIds.CodexContractsId); + Add("grafanaid", applicationIds.GrafanaId); } public PodLabels GetLabelsForAppName(string appName) diff --git a/Logging/ApplicationIds.cs b/Logging/ApplicationIds.cs index d52dc10..7162a36 100644 --- a/Logging/ApplicationIds.cs +++ b/Logging/ApplicationIds.cs @@ -2,17 +2,19 @@ { public class ApplicationIds { - public ApplicationIds(string codexId, string gethId, string prometheusId, string codexContractsId) + public ApplicationIds(string codexId, string gethId, string prometheusId, string codexContractsId, string grafanaId) { CodexId = codexId; GethId = gethId; PrometheusId = prometheusId; CodexContractsId = codexContractsId; + GrafanaId = grafanaId; } public string CodexId { get; } public string GethId { get; } public string PrometheusId { get; } public string CodexContractsId { get; } + public string GrafanaId { get; } } } diff --git a/Logging/StatusLog.cs b/Logging/StatusLog.cs index 96a8cc2..f5d5831 100644 --- a/Logging/StatusLog.cs +++ b/Logging/StatusLog.cs @@ -26,6 +26,7 @@ namespace Logging gethid = applicationIds.GethId, prometheusid = applicationIds.PrometheusId, codexcontractsid = applicationIds.CodexContractsId, + grafanaid = applicationIds.GrafanaId, category = NameUtils.GetCategoryName(), fixturename = fixtureName, testname = NameUtils.GetTestMethodName(), @@ -59,6 +60,7 @@ namespace Logging public string gethid { get; set; } = string.Empty; public string prometheusid { get; set; } = string.Empty; public string codexcontractsid { get; set; } = string.Empty; + public string grafanaid { get; set; } = string.Empty; public string category { get; set; } = string.Empty; public string fixturename { get; set; } = string.Empty; public string testname { get; set; } = string.Empty; From 75cdb94e274078cb3274ae52e0a780e92a8ef3e6 Mon Sep 17 00:00:00 2001 From: benbierens Date: Sun, 13 Aug 2023 10:10:47 +0200 Subject: [PATCH 13/14] use cluster-external addresses for dashboard URLs --- DistTestCore/GrafanaStarter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DistTestCore/GrafanaStarter.cs b/DistTestCore/GrafanaStarter.cs index 82a4614..f66db8c 100644 --- a/DistTestCore/GrafanaStarter.cs +++ b/DistTestCore/GrafanaStarter.cs @@ -26,7 +26,7 @@ namespace DistTestCore Log("Uploading dashboard configurations..."); var jsons = ReadEachDashboardJsonFile(); - var dashboardUrls = jsons.Select(j => UploadDashboard(http, grafanaAddress, j)).ToArray(); + var dashboardUrls = jsons.Select(j => UploadDashboard(http, grafanaContainer, j)).ToArray(); LogEnd("Dashboard server started."); @@ -68,13 +68,14 @@ namespace DistTestCore } } - public static string UploadDashboard(Http http, Address grafanaAddress, string dashboardJson) + public static string UploadDashboard(Http http, RunningContainer grafanaContainer, string dashboardJson) { var request = GetDashboardCreateRequest(dashboardJson); var response = http.HttpPostString("dashboards/db", request); var jsonResponse = JsonConvert.DeserializeObject(response); if (jsonResponse == null || string.IsNullOrEmpty(jsonResponse.url)) throw new Exception("Failed to upload dashboard."); + var grafanaAddress = grafanaContainer.ClusterExternalAddress; return grafanaAddress.Host + ":" + grafanaAddress.Port + jsonResponse.url; } From b4302ab6f76b1263f8c26af3d066f99647b17f7c Mon Sep 17 00:00:00 2001 From: benbierens Date: Sun, 13 Aug 2023 11:19:35 +0200 Subject: [PATCH 14/14] Decent dashboard setup --- DistTestCore/GrafanaStarter.cs | 11 +- DistTestCore/Http.cs | 17 +- .../Metrics/GrafanaContainerRecipe.cs | 18 +- DistTestCore/Metrics/dashboard.json | 1965 +++++++++++++++-- 4 files changed, 1864 insertions(+), 147 deletions(-) diff --git a/DistTestCore/GrafanaStarter.cs b/DistTestCore/GrafanaStarter.cs index f66db8c..61bb17d 100644 --- a/DistTestCore/GrafanaStarter.cs +++ b/DistTestCore/GrafanaStarter.cs @@ -1,8 +1,8 @@ using DistTestCore.Metrics; +using IdentityModel.Client; using KubernetesWorkflow; using Newtonsoft.Json; using System.Reflection; -using Utils; namespace DistTestCore { @@ -19,7 +19,7 @@ namespace DistTestCore var grafanaContainer = StartGrafanaContainer(); var grafanaAddress = lifecycle.Configuration.GetAddress(grafanaContainer); - var http = new Http(lifecycle.Log, new DefaultTimeSet(), grafanaAddress, "api/"); + var http = new Http(lifecycle.Log, new DefaultTimeSet(), grafanaAddress, "api/", AddBasicAuth); Log("Connecting datasource..."); AddDataSource(http, prometheusContainer); @@ -44,6 +44,13 @@ namespace DistTestCore return grafanaContainers.Containers.First(); } + private void AddBasicAuth(HttpClient client) + { + client.SetBasicAuthentication( + GrafanaContainerRecipe.DefaultAdminUser, + GrafanaContainerRecipe.DefaultAdminPassword); + } + private static void AddDataSource(Http http, RunningContainer prometheusContainer) { var prometheusAddress = prometheusContainer.ClusterExternalAddress; diff --git a/DistTestCore/Http.cs b/DistTestCore/Http.cs index 1239fd7..0d99db0 100644 --- a/DistTestCore/Http.cs +++ b/DistTestCore/Http.cs @@ -1,5 +1,4 @@ -using IdentityModel.Client; -using Logging; +using Logging; using Newtonsoft.Json; using System.Net.Http.Headers; using System.Net.Http.Json; @@ -13,14 +12,21 @@ namespace DistTestCore private readonly ITimeSet timeSet; private readonly Address address; private readonly string baseUrl; + private readonly Action onClientCreated; private readonly string? logAlias; public Http(BaseLog log, ITimeSet timeSet, Address address, string baseUrl, string? logAlias = null) + : this(log, timeSet, address, baseUrl, DoNothing, logAlias) + { + } + + public Http(BaseLog log, ITimeSet timeSet, Address address, string baseUrl, Action onClientCreated, string? logAlias = null) { this.log = log; this.timeSet = timeSet; this.address = address; this.baseUrl = baseUrl; + this.onClientCreated = onClientCreated; this.logAlias = logAlias; if (!this.baseUrl.StartsWith("/")) this.baseUrl = "/" + this.baseUrl; if (!this.baseUrl.EndsWith("/")) this.baseUrl += "/"; @@ -60,7 +66,6 @@ namespace DistTestCore var url = GetUrl() + route; using var content = JsonContent.Create(body); Log(url, JsonConvert.SerializeObject(body)); - client.SetBasicAuthentication("admin", "admin"); var result = Time.Wait(client.PostAsync(url, content)); var str = Time.Wait(result.Content.ReadAsStringAsync()); Log(url, str); @@ -75,7 +80,6 @@ namespace DistTestCore using var client = GetClient(); var url = GetUrl() + route; Log(url, body); - client.SetBasicAuthentication("admin", "admin"); var content = new StringContent(body); content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); var result = Time.Wait(client.PostAsync(url, content)); @@ -151,7 +155,12 @@ namespace DistTestCore { var client = new HttpClient(); client.Timeout = timeSet.HttpCallTimeout(); + onClientCreated(client); return client; } + + private static void DoNothing(HttpClient client) + { + } } } diff --git a/DistTestCore/Metrics/GrafanaContainerRecipe.cs b/DistTestCore/Metrics/GrafanaContainerRecipe.cs index 272001e..455af39 100644 --- a/DistTestCore/Metrics/GrafanaContainerRecipe.cs +++ b/DistTestCore/Metrics/GrafanaContainerRecipe.cs @@ -7,27 +7,19 @@ namespace DistTestCore.Metrics public override string AppName => "grafana"; public override string Image => "grafana/grafana-oss:10.0.3"; + public const string DefaultAdminUser = "adminium"; + public const string DefaultAdminPassword = "passwordium"; + protected override void Initialize(StartupConfig startupConfig) { - //var config = startupConfig.Get(); - - //AddExposedPortAndVar("PROM_PORT"); AddExposedPort(3000); - //AddEnvVar("PROM_CONFIG", config.PrometheusConfigBase64); - - // [auth.anonymous] - // enabled = true - //GF____FILE AddEnvVar("GF_AUTH_ANONYMOUS_ENABLED", "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 + AddEnvVar("GF_SECURITY_ADMIN_USER", DefaultAdminUser); + AddEnvVar("GF_SECURITY_ADMIN_PASSWORD", DefaultAdminPassword); } } } diff --git a/DistTestCore/Metrics/dashboard.json b/DistTestCore/Metrics/dashboard.json index 038a0f2..591f0c3 100644 --- a/DistTestCore/Metrics/dashboard.json +++ b/DistTestCore/Metrics/dashboard.json @@ -1,134 +1,1843 @@ { - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": { - "type": "grafana", - "uid": "-- Grafana --" - }, - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "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": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 3, + "panels": [], + "title": "API Upload/Download", + "type": "row" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" } - ] - }, - "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 - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 0 - }, - "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" - }, - "editorMode": "builder", - "expr": "codexApiDownloads_total", - "instant": false, - "range": true, - "refId": "A" - } - ], - "title": "Codex API Downloads", - "type": "timeseries" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 1 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" } - ], - "refresh": "10s", - "schemaVersion": 38, - "style": "dark", - "tags": [], - "templating": { - "list": [] + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexApiUploads_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Uploads", + "type": "timeseries" }, - "time": { - "from": "now-1h", - "to": "now" + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 1 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "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": "Downloads", + "type": "timeseries" }, - "timepicker": {}, - "timezone": "", - "title": "Codex", - "uid": null, - "version": 2, - "weekStart": "" + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 9 + }, + "id": 2, + "panels": [], + "title": "Local Storage", + "type": "row" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 10 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexRepostoreBlocks", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Number of Blocks", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 10 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexRepostoreBytesReserved", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Bytes reserved", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 10 + }, + "id": 7, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexRepostoreBytesUsed", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Bytes used", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 18 + }, + "id": 8, + "panels": [], + "title": "Block Exchange", + "type": "row" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 19 + }, + "id": 11, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexBlockExchangeBlocksSent_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Blocks sent", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 19 + }, + "id": 9, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexBlockExchangeBlocksReceived_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Blocks received", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 27 + }, + "id": 10, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexBlockExchangeWantHaveListsSent_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "WantHave lists sent", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 6, + "y": 27 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexBlockExchangeWantBlockListsSent_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "WantBlock lists sent", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 12, + "y": 27 + }, + "id": 13, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexBlockExchangeWantHaveListsReceived_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "WantHave lists received", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 18, + "y": 27 + }, + "id": 14, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexBlockExchangeWantBlockListsReceived_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "WantBlock lists received", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 35 + }, + "id": 15, + "panels": [], + "title": "Purchases", + "type": "row" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 36 + }, + "id": 16, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexPurchasesPending_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Pending", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 6, + "y": 36 + }, + "id": 20, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexPurchasesSubmitted_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Submitted", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 12, + "y": 36 + }, + "id": 18, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexPurchasesStarted_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Started", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 18, + "y": 36 + }, + "id": 19, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexPurchasesFinished_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Finished", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 44 + }, + "id": 17, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexPurchasesFailed_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Failed", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 6, + "y": 44 + }, + "id": 23, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexPurchasesCancelled_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Cancelled", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 12, + "y": 44 + }, + "id": 21, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexPurchasesUnknown_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Unknown", + "type": "timeseries" + }, + { + "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 + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 18, + "y": 44 + }, + "id": 22, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "c89eaad3-9184-429f-ac94-8ba0b1824dbb" + }, + "editorMode": "builder", + "expr": "codexPurchasesError_total", + "instant": false, + "range": true, + "refId": "A" + } + ], + "title": "Error", + "type": "timeseries" + } + ], + "refresh": "10s", + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Codex", + "uid": "ca93f344-dd41-48c4-95a7-876c340e3005", + "version": 6, + "weekStart": "" } \ No newline at end of file