static async Task Main() { Console.CancelKeyPress += OnExit; Console.Title = "Lhi.HsbDemo.Orders.EmailNotificationHandler"; // Start Metrics for Prometheus //var metricServer = new MetricServer(port: 3031); var prometheus = AppSettings.Prometheus; var metricServer = new MetricServer(prometheus, 3031); metricServer.Start(); var endpointConfiguration = new EndpointConfiguration("Lhi.NsbDemo.Orders.EmailNotificationHandler"); // Configure Stackify StackifyLib.Config.ApiKey = AppSettings.StackifyApiKey; StackifyLib.Config.AppName = AppSettings.StackifyApiName; StackifyLib.Config.Environment = AppSettings.StackifyEnvironment; // configure Serilog var tracingLog = new LoggerConfiguration() .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(AppSettings.ElasticSearchUrl)) { AutoRegisterTemplate = true, AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6, IndexFormat = "nsbdemo-{0:yyyy.MM.dd}", InlineFields = true }) .WriteTo.Stackify() .MinimumLevel.Information() .CreateLogger(); var serilogFactory = LogManager.Use <SerilogFactory>(); serilogFactory.WithLogger(tracingLog); endpointConfiguration.EnableFeature <TracingLog>(); endpointConfiguration.SerilogTracingTarget(tracingLog); var transport = endpointConfiguration.UseTransport <RabbitMQTransport>(); transport.UseConventionalRoutingTopology(); var rabbitmqConnectionString = AppSettings.RabbitMQUrl; transport.ConnectionString(rabbitmqConnectionString); //endpointConfiguration.UseSerialization<NewtonsoftSerializer>(); endpointConfiguration.EnableInstallers(); endpointConfiguration.Conventions() //.DefiningEventsAs(c => c.Namespace != null && c.Name.EndsWith("Event")) .DefiningCommandsAs(c => c.Namespace != null && c.Name.EndsWith("Command")); var endpointInstance = Endpoint.Start(endpointConfiguration) .GetAwaiter().GetResult(); // Wait until the message arrives. closingEvent.WaitOne(); await endpointInstance.Stop() .ConfigureAwait(false); }
public async Task RunAsync(CancellationToken cancel) { _log.Info($"Configured to probe Docker on {DockerUrl}"); _tracker = new DockerTracker(new Uri(DockerUrl)); Metrics.DefaultRegistry.AddBeforeCollectCallback(UpdateMetricsAsync); var server = new MetricServer(9417); #if DEBUG _log.Info($"Open http://localhost:9417/metrics to initiate a probe."); #endif server.Start(); while (!cancel.IsCancellationRequested) { try { await Task.Delay(-1, cancel); } catch (TaskCanceledException) when(cancel.IsCancellationRequested) { // Totally normal - we are exiting. break; } } await server.StopAsync(); }
internal void Start() { Logger.Info("Starting Prometheus metrics server at {0}:{1}", _host, _port); _dotnetCollector.StartCollecting(); _systemMetrics.AddSystemMetrics(); _server.Start(); }
//private static KestrelMetricServer Server; public static void InitServer() { var diagnosticSourceRegistration = DiagnosticSourceAdapter.StartListening(); Server = new MetricServer(port: 1234); Server.Start(); }
public void Start() { var endpoint = IPEndPoint.Parse(_config.Prometheus.IPEndpoint); _metricServer = new MetricServer(hostname: endpoint.Address.ToString(), port: endpoint.Port); _metricServer.Start(); }
public void StartFeedVersion1() { _fsdConsumer.AddClientDtoReceived += FsdConsumer_AddClientDtoReceived; _fsdConsumer.RemoveClientDtoReceived += FsdConsumer_RemoveClientDtoReceived; _fsdConsumer.PilotDataDtoReceived += FsdConsumer_PilotDataDtoReceived; _fsdConsumer.AtcDataDtoReceived += FsdConsumer_AtcDataDtoReceived; _fsdConsumer.FlightPlanDtoReceived += FsdConsumer_FlightPlanDtoReceived; _fsdConsumer.FlightPlanCancelDtoReceived += FsdConsumer_FlightPlanCancelDtoReceived; _fsdConsumer.AtisDataDtoReceived += FsdConsumer_AtisDataDtoReceived; _fsdConsumer.NotifyDtoReceived += FsdConsumer_NotifyDtoReceived; _fsdConsumer.WallopDtoReceived += FsdConsumer_WallopDtoReceived; _fsdConsumer.BroadcastDtoReceived += FsdConsumer_BroadcastDtoReceived; _fsdConsumer.AtisTimer.Elapsed += FsdConsumer_AtisTimerElapsed; _timeoutTimer.Elapsed += RemoveTimedOutConnections; _prometheusMetricsTimer.Elapsed += SetPrometheusConnectionCounts; _fsdConsumer.Start(ConsumerName, ConsumerCallsign); _timeoutTimer.Start(); _fsdConsumer.AtisTimer.Start(); _fileTimer.Elapsed += WriteDataFiles; _fileTimer.Start(); _prometheusMetricsTimer.Start(); MetricServer metricServer = new MetricServer(port: 8501); metricServer.Start(); Console.WriteLine("Starting Feed Version 1 & 2"); }
static void Main(string[] args) { // Initialize the global logging, usually this should go to the regular Windows eventlog GVars.MyLog = new System.Diagnostics.EventLog("Application"); GVars.MyLog.Source = "PrometheusNodeExporter"; // Load all plugins an initialize the metrics NodeCollector.Core.PluginCollection availablePlugins = NodeCollector.Core.PluginSystem.LoadCollectors(); foreach (NodeCollector.Core.INodeCollector collector in availablePlugins) { collector.RegisterMetrics(); } string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); ushort port = NodeExporterWindows.Properties.Settings.Default.Port; string metricUrl = "metrics/"; GVars.MyLog.WriteEntry(string.Format("Start Prometheus exporter v{0} service on port :{1}/tcp (url {2}).", version, port, metricUrl), EventLogEntryType.Information, 0); MetricServer metricServer = new MetricServer(port: port, url: metricUrl); metricServer.Start(); Console.WriteLine("Press [ENTER] twice to exit..."); Console.ReadLine(); Console.ReadLine(); }
public static int Main(string[] args) { Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(Configuration) .Enrich.FromLogContext() .WriteTo.Console(outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Properties:j} {Message:lj} {NewLine}{Exception}") .CreateLogger(); var server = new MetricServer(port: 9090); Metrics.SuppressDefaultMetrics(); // remove default metrics server.Start(); try{ Log.Information("Iniciando aplicação..."); CreateHostBuilder(args).Build().Run(); return(0); } catch (Exception ex) { Log.Fatal(ex, "Host terminated unexpectedly"); return(1); }finally{ Log.CloseAndFlush(); } }
public static async Task Main(string[] args) { var server = new MetricServer(hostname: "localhost", port: 5001, useHttps: false); server.Start(); await CreateHostBuilder(args).Build().RunAsync(); }
private Task StartMetricsServer() { Thread.Sleep(TimeSpan.FromSeconds(ConfigData.Data.Bot.BotWarmupTimeInSeconds)); if (this._client == null || this._client.CurrentUser == null) { this._logger.Log("Delaying metric server startup"); Thread.Sleep(TimeSpan.FromSeconds(ConfigData.Data.Bot.BotWarmupTimeInSeconds)); } this._logger.Log("Starting metrics server"); var prometheusPort = 4444; if (!this._client.CurrentUser.Id.Equals(Constants.BotProductionId)) { this._logger.Log("Prometheus port selected is non-production"); prometheusPort = 4422; } this._logger.Log($"Prometheus starting on port {prometheusPort}"); var server = new MetricServer("localhost", prometheusPort); server.Start(); this._logger.Log($"Prometheus running on localhost:{prometheusPort}/metrics"); return(Task.CompletedTask); }
// Use this for initialization private void Start() { if (!Application.isEditor) { metricServer = new MetricServer(port: 1234); metricServer.Start(); } resetCounter = Metrics.CreateCounter("reset", "How many times the worker has been reset"); herbivorousInUseGauge = Metrics.CreateGauge("herbivorousInUse", "Current total amount of herbivorous agents"); carnivorousInUseGauge = Metrics.CreateGauge("carnivorousInUse", "Current total amount of carnivorous agents"); herbivorousSpecieLifeExpectancyGauge = Metrics.CreateGauge("herbivorousSpecieLifeExpectancy", "Life expectancy of herbivorous specie"); carnivorousSpecieLifeExpectancyGauge = Metrics.CreateGauge("carnivorousSpecieLifeExpectancy", "Life expectancy of carnivorous specie"); evolAcademy = FindObjectOfType <EvolAcademy>(); workerObjects = new List <Utils.Tuple <Utils.Tuple <int, int>, GameObject> >(); // Instanciate pools to spawn / release objects herbivorousPool = new Pool(ItemsToSpawn.Find(go => go.name.Equals("HerbivorousAgent")), false); carnivorousPool = new Pool(ItemsToSpawn.Find(go => go.name.Equals("CarnivorousAgent")), false); herbPool = new Pool(ItemsToSpawn.Find(go => go.name.Equals("Herb")), false); godPool = new Pool(ItemsToSpawn.Find(go => go.name.Equals("GodAgent")), false); SpawnWorkers(); }
public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); var server = new MetricServer(hostname: "localhost", port: 5000); server.Start(); }
static async Task Main(string[] args) { Console.WriteLine("Starting Evaluation-Producer"); EnvironmentVariables.SetFromEnvironmentVariables(); EnvironmentVariables.PrintProperties(); var messages = MessageGenerator.GenerateMessages(EnvironmentVariables.AmountOfMessagesVariable); var metricServer = new MetricServer(80); metricServer.Start(); Console.WriteLine($"Starting {EnvironmentVariables.ApplicationType} Producer"); switch (EnvironmentVariables.ApplicationType) { case "Dream-Stream": await DreamStream(messages, EnvironmentVariables.TopicName); break; case "Kafka": //await KafkaAwait(messages, EnvironmentVariables.TopicName); await KafkaFlush(messages, EnvironmentVariables.TopicName); break; case "Nats-Streaming": break; default: throw new NotImplementedException($"The method {EnvironmentVariables.ApplicationType} has not been implemented"); } }
private static void Main(string[] args) { var fileName = args[0]; var metricServer = new MetricServer(null, new MetricServerOptions { Port = 58433, Host = Debugger.IsAttached ? "127.0.0.1" : "*" }); try { metricServer.Start(); Observable.Create <string>(async(o, cancel) => { using var reader = File.OpenText(fileName); while (!cancel.IsCancellationRequested) { var line = reader.ReadLine(); if (reader.BaseStream.Length < reader.BaseStream.Position) { reader.BaseStream.Seek(0, SeekOrigin.Begin); } if (line != null) { Console.WriteLine(); Console.WriteLine(line); o.OnNext(line); } else { Console.Write("."); await Task.Delay(1000, cancel); } } o.OnCompleted(); }) .Select(JObject.Parse) .Select(j => new Reading(j)) .SelectMany(r => r.Metrics.Select(m => new Metric(r.Unique + m.Key, m.Key, m.Value, r.Labels))) .Subscribe(m => { if (!metrics.TryGetValue(m.Unique, out var gauge)) { gauge = Metrics.CreateGauge("rtl433_" + m.Name, "", true, "model", "channel", "id", "unique"); } gauge.WithLabels(m.LabelValues) .Set(m.Value, DateTimeOffset.Now); }); var mre = new ManualResetEvent(false); Console.CancelKeyPress += (sender, eventArgs) => mre.Set(); mre.WaitOne(); } finally { metricServer.Stop(); } }
static void Main(string[] args) { if (!File.Exists(Config.CollectorConfigPath)) { WriteLine("No collector config path configured. Set $env:COLLECTOR_CONFIG_PATH"); return; } var logger = new LoggerConfiguration() .ReadFrom.AppSettings() .CreateLogger(); var json = File.ReadAllText(Config.CollectorConfigPath); var collectorConfig = JsonConvert.DeserializeObject <CollectorConfiguration>(json); if (!collectorConfig.PerformanceCounterCollectors.Any()) { logger.Information("No collectors configured. Config file path: {Path}", Config.CollectorConfigPath); return; } DefaultCollectorRegistry.Instance.Clear(); DefaultCollectorRegistry.Instance.RegisterOnDemandCollectors( new ConfiguredPerformanceCounterCollector(collectorConfig, Config.RecordCollections, logger)); var server = new MetricServer(Config.MetricsPort); server.Start(); logger.Information("Metrics server listening on port: {Port}", Config.MetricsPort); _ResetEvent.WaitOne(); }
private static void StartMetricServer() { var metricsPort = Config.Current.GetValue <int>("Metrics:Port"); var server = new MetricServer(metricsPort); server.Start(); Console.WriteLine($"Metrics server listening on port ${metricsPort}"); }
private static void StartMetricServer(IConfiguration config) { var metricsPort = config.GetValue <int>("Metrics:Port"); var server = new MetricServer(metricsPort); server.Start(); Log.Information("Metrics server listening on port: {metricsPort}", metricsPort); }
public Task StartAsync(CancellationToken cancellationToken) { // Start the HTTP Server _logger.LogInformation("Starting metrics server on {listeningUrl}", _listeningUrl); _server.Start(); return(Task.CompletedTask); }
/// <inheritdoc/> public void Start() { const string path = "metrics/"; _logger.Information($"Starting metric server on port {_configuration.Port} on path '{path}'"); _server = new MetricServer(hostname: "*", port: _configuration.Port, url: path, registry: _collectorRegistry); _server.Start(); }
public static void Main(string[] args) { var server = new MetricServer(port: 9000); server.Start(); CreateHostBuilder(args).Build().Run(); }
public static void StartMetrics(string instanceName, int bindPort, string bindHost = null) { _name = instanceName; _srv = bindHost != null ? new MetricServer(bindHost, bindPort) : new MetricServer(bindPort); _srv.Start(); }
public void Start() { Logger.LogAction("starting prometheus server", () => { _collector.Start(); _server.Start(); }); }
private void StartMetricServer() { var metricsPort = 80; var server = new MetricServer(metricsPort); server.Start(); Console.WriteLine($"Metrics server listening on port {metricsPort}"); }
public void Start() { Logger.LogAction("starting prometheus server", () => { DefaultCollectorRegistry.Instance.RegisterOnDemandCollectors(_prometheusCollection); _collector.Start(); _server.Start(); }); }
public ProcessorMetricServer(ILogger logger) { _logger = logger; _metricServer = new MetricServer(port: 9201); _counter = Metrics.CreateCounter("processor_messagecounter", "counting accumulative all messages sent to redis and calculate messages processed by a second"); _metricServer.Start(); _logger.Debug($"[Processor at {DateTime.Now}] Metric server started"); }
/// <summary> /// Plugin initialization /// </summary> public override void Initialize() { server.Start(); foreach (Collectors.BaseCollector collector in collectors) { collector.Initialize(); // TODO: init based on enabled or not in config } }
public void Start() { _server.Start(); Metrics.DefaultRegistry.AddBeforeCollectCallback(() => { DbKeys.Set(_context.EstimateNumberOfKeys()); DbSize.Set(_context.EstimateDirSize()); }); }
private static void ConfigurePrometheusListener(IConfigurationRoot configuration) { var port = int.Parse(configuration["PrometheusPort"]); Log.Information("Starting Prometheus listener at {uri}", $"+:{port}"); var server = new MetricServer(hostname: "+", port: port); server.Start(); }
static void Main(string[] args) { Menu menu = new Menu(); var server = new MetricServer(hostname: "localhost", port: 1234); server.Start(); TickTock.Inc(); menu.MainMenu(); }
public void Start_Stop_IsRunning() { const int port = 9000; var metricServer = new MetricServer(port); metricServer.Start(); Assert.True(metricServer.IsRunning); metricServer.Stop(); Assert.False(metricServer.IsRunning); }