zoukankan      html  css  js  c++  java
  • .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();

                    services.AddMetricsTrackingMiddleware(options => options.IgnoredHttpStatusCodes = new[] { 404 });
                }

                #endregion

  • 相关阅读:
    sublime主题推荐
    安装JDK设置环境变量
    寻找灵感
    算法刷题3 PAT 1003 我要通过! (20 point(s))
    Java JDBC连接Mysql学习整理
    算法Day2-恶搞算法(网传88万代码生成)java实现
    算法刷题1:自测-1 打印沙漏 (20 point(s))
    Java I/O stream输入输出初整理
    Java this关键字初理解
    MD5加密算法
  • 原文地址:https://www.cnblogs.com/mrray/p/10729385.html
Copyright © 2011-2022 走看看