PrometheusConfig.cs 611 B

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