예제 #1
0
        public PrometheusEndpoint(MetricsWriterLoadData metricsWriterLoadData) : base(metricsWriterLoadData)
        {
            host = metricsWriterLoadData.Settings["host"] ?? "localhost";

            port = 9796;
            if (metricsWriterLoadData.Settings["port"] != null)
            {
                if (!ushort.TryParse(metricsWriterLoadData.Settings["port"], out port))
                {
                    Logger.Error($"Prometheus port not an valid value. Using a value of {port} instead.");
                }
            }

            path = metricsWriterLoadData.Settings["path"] ?? "/metrics";

            httpListener.Prefixes.Add($"http://{host}:{port}/");

            // TODO support adding labels from config

            httpListener.Start();

            listenThread = new Thread(Listen);
            listenThread.Start();

            Logger.Trace($"Prometheus endpoint started at 'http://{host}:{port}{path}'");
        }
예제 #2
0
 /// <summary>
 ///     Creates a new MetricsWriter.
 /// </summary>
 /// <param name="metricsWriterLoadData">The data to start the metrics writer with.</param>
 public MetricsWriter(MetricsWriterLoadData metricsWriterLoadData) : base(metricsWriterLoadData)
 {
 }