.Net Core 2.0+ InfluxDB+Grafana+App Metrics 实现跨平台的实时性能监控

转载部分:

https://www.cnblogs.com/edisonchou/p/integrated_performance_monitoring_foundation.html

 

ConfigureServices下添加:

#region AppMetrics添加

            bool isOpenMetrics = Convert.ToBoolean(Configuration["AppMetrics:IsOpen"]);
            if (isOpenMetrics)
            {
                string database = Configuration["AppMetrics:DatabaseName"];
                string connStr = Configuration["AppMetrics:ConnectionString"];
                string app = Configuration["AppMetrics:App"];
                string env = Configuration["AppMetrics:Env"];
                string username = Configuration["AppMetrics:UserName"];
                string password = Configuration["AppMetrics:Password"];

                var uri = new Uri(connStr);
                var metrics = AppMetrics.CreateDefaultBuilder().Configuration.Configure(options =>
                {
                    options.AddAppTag(app);
                    options.AddEnvTag(env);
                }).Report.ToInfluxDb(options =>
                {
                    options.InfluxDb.BaseUri = uri;
                    options.InfluxDb.Database = database;
                    options.InfluxDb.UserName = username;
                    options.InfluxDb.Password = password;
                    options.HttpPolicy.BackoffPeriod = TimeSpan.FromSeconds(30);
                    options.HttpPolicy.FailuresBeforeBackoff = 5;
                    options.HttpPolicy.Timeout = TimeSpan.FromSeconds(10);
                    options.FlushInterval = TimeSpan.FromSeconds(5);
                }).Build();

                services.AddMetrics(metrics);
                services.AddMetricsReportingHostedService();
                //services.AddMetricsReportScheduler();
                services.AddMetricsTrackingMiddleware();
                services.AddMetricsEndpoints();
            }

            #endregion

 

上一篇:influxDB简介及设计原则


下一篇:Android apktool反编译资源文件为空解决办法(测试天猫、淘宝等apk成功)