PrometheusConfig.cs 845 B

12345678910111213141516171819202122232425262728293031
  1. namespace OhmGraphite
  2. {
  3. public class PrometheusConfig
  4. {
  5. public int Port { get; }
  6. public string Host { get; }
  7. public bool UseHttps { get; }
  8. public PrometheusConfig(int port, string host, bool useHttps)
  9. {
  10. Port = port;
  11. Host = host;
  12. UseHttps = useHttps;
  13. }
  14. internal static PrometheusConfig ParseAppSettings(IAppConfig config)
  15. {
  16. string host = config["prometheus_host"] ?? "*";
  17. if (!bool.TryParse(config["prometheus_https"], out bool useHttps))
  18. {
  19. useHttps = false;
  20. }
  21. if (!int.TryParse(config["prometheus_port"], out int port))
  22. {
  23. port = 4445;
  24. }
  25. return new PrometheusConfig(port, host, useHttps);
  26. }
  27. }
  28. }