public static MetricsReports WithElasticSearch(this MetricsReports reports, ElasticReportsConfig reportConfig, TimeSpan interval)
        {
            var bulkUri     = new Uri($@"http://{reportConfig.Host}:{reportConfig.Port}/_bulk");
            var nodeInfoUri = new Uri($@"http://{reportConfig.Host}:{reportConfig.Port}");

            return(reports.WithReport(new ElasticSearchReport(bulkUri, reportConfig.Index, nodeInfoUri, reportConfig.RollingIndexType), interval));
        }
Example #2
0
        /// <summary>
        /// MetricsConfig
        /// </summary>
        private static void MetricsConfig()
        {
            //需要使用ES版本为5,不能使用6
            var esConfig = new ElasticReportsConfig()
            {
                Host = "127.0.0.1", Port = 9200, Index = "metrics"
            };

            Metric.Config
            // Web监视仪表板,提供Metrics.NET度量值图表,浏览器打开这个地址可以访问一个Metrics.NET内置的页面
            .WithHttpEndpoint("http://localhost:1234/metrics/")
            .WithReporting(config =>
                           config.WithElasticSearch(esConfig, TimeSpan.FromSeconds(5))
                           );
            while (true)
            {
                ToElastic();
            }
        }
Example #3
0
 public static MetricsReports WithElasticSearch(this MetricsReports reports, ElasticReportsConfig reportConfig, TimeSpan interval)
 {
     return(reports.WithReport(new ElasticSearchReport(reportConfig), interval));
 }