Пример #1
0
        // Use this method to configure the HTTP request pipeline (middleware).
        public void Configure(IApplicationBuilder app)
        {
            if (Configuration[InfrastructureConfigurationKeys.EnvironmentTag] != "prod")
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }


            app.UseCors(builder => builder
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());

            // new metricServer with seperate port for prometheus
            var metricServer = new KestrelMetricServer(8081);

            metricServer.Start();

            app.UsePrometheusMiddleware(Logger);

            app.UseMvc();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var frameBufferSizeSetting = Environment.GetEnvironmentVariable("FRAME_BUFFER_SIZE");
            int frameBufferSize        =
                string.IsNullOrEmpty(frameBufferSizeSetting) ? 2 : int.Parse(frameBufferSizeSetting);

            Frames = new LimitedSizeStack <byte[]>(frameBufferSize);
            if (Frames == null)
            {
                throw new ArgumentNullException("Unable to create Frames");
            }

            RtspUrl = Environment.GetEnvironmentVariable("RTSP_URL");
            if (string.IsNullOrEmpty(RtspUrl))
            {
                RtspUrl = Akri.Akri.GetRtspUrl();
            }
            if (string.IsNullOrEmpty(RtspUrl))
            {
                throw new ArgumentNullException("Unable to find RTSP URL");
            }

            CamerasCounter.Inc();

            FrameTask = Task.Run(() => Process(RtspUrl));

            var metricServer = new KestrelMetricServer(port: 8080);

            metricServer.Start();

            CreateHostBuilder(args).Build().Run();
        }
Пример #3
0
        public void Initialize()
        {
            var server = new KestrelMetricServer(hostname: "*", port: 5002);

            server.Start();
            _logger.LogInformation("Metrics server started successfully");
        }
Пример #4
0
        private static void SetupKestrel()
        {
            const int metricsPort  = 9089;
            var       metricServer = new KestrelMetricServer(metricsPort);

            metricServer.Start();
            InstrumentationInitialiser.Initialise(typeof(ApiInstrumentation));
        }
Пример #5
0
        private void ConfigureMetrics(IApplicationBuilder app)
        {
            ConfigureRequestDurationMetric(app);

            ConfigureBuildInfoMetric();

            var metricsPort = Configuration.GetValue <int>("MetricsPort");

            using var metricServer = new KestrelMetricServer(metricsPort);
            metricServer.Start();
        }
Пример #6
0
        public MetricsService(IOptionsMonitor <ServerOptions> options, ILogger <MetricsService> logger)
        {
            _logger = logger;

            _runtimeStatsRegistration = DotNetRuntimeStatsBuilder.Default().StartCollecting();

            var port = options.CurrentValue.MetricsPort;

            if (port != null)
            {
                _server = new KestrelMetricServer(_port = port.Value);
            }
        }
Пример #7
0
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         //.SetBasePath(Directory.GetCurrentDirectory())
                         .SetBasePath("/app/build/PublishOutput")
                         .AddEnvironmentVariables()
                         .AddCommandLine(args)
                         .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                         .Build();

            //prometheus metrics
            var metricServer = new KestrelMetricServer(Int32.Parse(config["management.metrics.export.prometheus.rsocket.port"]), "/metrics");

            metricServer.Start();

            var host = new WebHostBuilder()
                       //.UseContentRoot(Directory.GetCurrentDirectory())
                       .UseContentRoot("/app/build/PublishOutput")
                       .UseConfiguration(config)
                       .UseStartup <Startup>()
                       .UseKestrel(
                options =>
            {
                options.AllowSynchronousIO = true;
                options.Limits.MaxConcurrentConnections         = 100000;
                options.Limits.MaxConcurrentUpgradedConnections = 100000;
                options.Limits.MinRequestBodyDataRate           = null;
                options.Limits.MinResponseDataRate    = null;
                options.Limits.MinRequestBodyDataRate = new MinDataRate(bytesPerSecond: 100,
                                                                        gracePeriod: TimeSpan.FromSeconds(2));
                options.Limits.MinResponseDataRate =
                    new MinDataRate(bytesPerSecond: 100,
                                    gracePeriod: TimeSpan.FromSeconds(2));
                options.AddServerHeader = false;
                options.Listen(IPAddress.Any, 8080, listenOptions =>
                {
                    listenOptions.UseConnectionLogging();
                });
            })
                       .ConfigureLogging((hostingContext, logging) =>
            {
                logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
                logging.AddConsole();
                logging.AddDebug();
            })

                       .Build();

            host.Run();
        }
Пример #8
0
        /// <summary>
        /// Configures the HTTP request pipeline.
        /// </summary>
        /// <param name="app">The application builder.</param>
        /// <param name="env">The hosting environment.</param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseConcurrencyLimit();

            app.UseMvc();

            var metricServer = new KestrelMetricServer(port: 5002);

            metricServer.Start();
        }
Пример #9
0
        public static IMetricServer EnableMetricsServer(Prometheus config)
        {
            IMetricServer metricsServer = null;

            if (config.Enabled)
            {
                var port = config.Port ?? 4000;
                metricsServer = new KestrelMetricServer(port: port);
                metricsServer.Start();

                Log.Information("Metrics Server started and listening on: http://localhost:{0}/metrics", port);
            }

            return(metricsServer);
        }
        public static void Main(string[] args)
        {
            // Creating the kestrel metrics server listening
            // into another port
            var metricsServer = new KestrelMetricServer(9303);

            metricsServer.Start();

            // Subscribe the diagnostic listeners that will
            // export Prometheus metrics
            DiagnosticListener.AllListeners
            .SubscribeDiagnosticListener(o =>
            {
                o.AddAspNetCoreObserver();
                o.AddHttpHandlerObserver();
            });

            CreateWebHostBuilder(args).Build().Run();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Starting");

            //start metric server exposed on http://localhost:1234/metrics
            var metricServer = new KestrelMetricServer(port: 1234);

            metricServer.Start();


            var counter = Metrics.CreateCounter("myCounter", "some help about this");

            for (var i = 0; i < 2000; i++)
            {
                counter.Inc(i);
                Thread.Sleep(2000);
            }

            Console.WriteLine("Exit");
        }
Пример #12
0
        void IStartable.Start()
        {
            if (_prometheusMetricsConfig.Enabled)
            {
                _logger.LogInformation("Starting Prometheus Metrics server on port {port} with endpoint {endpoint}", _prometheusMetricsConfig.Port, _prometheusMetricsConfig.Path);
                _metricsServer = new KestrelMetricServer(port: _prometheusMetricsConfig.Port, url: _prometheusMetricsConfig.Path);

                if (_prometheusMetricsConfig.DotnetRuntimeMetrics)
                {
                    DotNetRuntimeStatsBuilder.Customize()
                    .WithThreadPoolSchedulingStats()
                    .WithContentionStats()
                    .WithGcStats()
                    .WithJitStats()
                    .WithThreadPoolStats()
                    .StartCollecting();
                }

                _metricsServer.Start();
            }
        }
Пример #13
0
        public void init(JObject config, CancellationTokenSource cts)
        {
            _config      = config.ToObject <opcPromConfigWrapper>().prometheus;
            server       = new KestrelMetricServer(_config.port);
            variablesMap = new Dictionary <string, Gauge>();
            var db_nodes = _serv.db.getDbNodes();

            try{
                selector = new NodesSelector(_config.variableFilter);
            }
            catch (Exception e) {
                logger.Error("HTTP server initialization failed: " + e.Message);
                cts.Cancel();
            }
            if (!cts.IsCancellationRequested)
            {
                foreach (var node in db_nodes)
                {
                    if (selector.selectNode(node.name))
                    {
                        variablesMap.Add(node.name, createMetric(node.name));
                    }
                }

                variablesMap.Add("opc_server_up", createMetric("opc_server_up", "Describe the status of connection with the opc-server, 0 means TCP connection down."));

                setTimer();

                try
                {
                    server.Start();
                    logger.Info("Prometheus metrics exposed at http://localhost:" + _config.port + "/metrics");
                }
                catch (Exception e)
                {
                    logger.Error("HTTP server initialization failed: " + e.Message);
                    cts.Cancel();
                }
            }
        }
        Task IHostedService.StartAsync(CancellationToken cancellationToken)
        {
            if (_prometheusMetricsConfig.Enabled)
            {
                _logger.LogInformation("Starting Prometheus Metrics server on port {port} with endpoint {endpoint}", _prometheusMetricsConfig.Port, _prometheusMetricsConfig.Path);
                _metricsServer = new KestrelMetricServer(port: _prometheusMetricsConfig.Port, url: _prometheusMetricsConfig.Path);

                if (_prometheusMetricsConfig.DotnetRuntimeMetrics)
                {
                    DotNetRuntimeStatsBuilder.Customize()
                    .WithContentionStats()
                    .WithGcStats()
                    .WithJitStats()
                    .WithThreadPoolStats()
                    .StartCollecting();
                }

                _metricsServer.Start();
            }

            return(Task.CompletedTask);
        }
 /// <summary>
 /// Auto registers metric server
 /// </summary>
 /// <param name="config"></param>
 /// <param name="logger"></param>
 public MetricServerHost(IMetricServerConfig config, ILogger logger)
 {
     _config       = config ?? throw new ArgumentNullException(nameof(config));
     _logger       = logger ?? throw new ArgumentNullException(nameof(logger));
     _metricServer = new KestrelMetricServer(_config.Port);
 }
 public MetricsCollector(IOptions <MetricsSettings> options)
 {
     _metricsServer = new KestrelMetricServer(options.Value.Host, options.Value.Port);
 }
Пример #17
0
 public MetricsService(ILogger <MetricsService> logger)
 {
     _logger       = logger;
     _server       = new KestrelMetricServer(Port);
     _runtimeStats = DotNetRuntimeStatsBuilder.Default().StartCollecting();
 }