Ver Fonte

possible to serve prometheus export on custom path

Roy Nard há 1 ano atrás
pai
commit
c4b134fdef
2 ficheiros alterados com 6 adições e 3 exclusões
  1. 1 1
      OhmGraphite/Program.cs
  2. 5 2
      OhmGraphite/PrometheusConfig.cs

+ 1 - 1
OhmGraphite/Program.cs

@@ -111,7 +111,7 @@ namespace OhmGraphite
             {
                 Logger.Info($"Prometheus port: {config.Prometheus.Port}");
                 var registry = PrometheusCollection.SetupDefault(collector);
-                var server = new MetricServer(config.Prometheus.Host, config.Prometheus.Port, registry: registry, useHttps: config.Prometheus.UseHttps);
+                var server = new MetricServer(config.Prometheus.Host, config.Prometheus.Port, url: config.Prometheus.Path, registry: registry, useHttps: config.Prometheus.UseHttps);
                 return new PrometheusServer(server, collector);
             }
             else if (config.Timescale != null)

+ 5 - 2
OhmGraphite/PrometheusConfig.cs

@@ -5,16 +5,19 @@ namespace OhmGraphite
         public int Port { get; }
         public string Host { get; }
         public bool UseHttps { get; }
+        public string Path { get; }
 
-        public PrometheusConfig(int port, string host, bool useHttps)
+        public PrometheusConfig(int port, string host, bool useHttps, string path)
         {
             Port = port;
             Host = host;
             UseHttps = useHttps;
+            Path = path;
         }
 
         internal static PrometheusConfig ParseAppSettings(IAppConfig config)
         {
+            string path = config["prometheus_path"] ?? "metrics/";
             string host = config["prometheus_host"] ?? "*";
             if (!bool.TryParse(config["prometheus_https"], out bool useHttps))
             {
@@ -25,7 +28,7 @@ namespace OhmGraphite
                 port = 4445;
             }
 
-            return new PrometheusConfig(port, host, useHttps);
+            return new PrometheusConfig(port, host, useHttps, path);
         }
     }
 }