【问题标题】:Monitoring aspnet core web app in kubernetes with App Metrics and Influxdb does not work使用 App Metrics 和 Influxdb 监控 kubernetes 中的 aspnet 核心 Web 应用程序不起作用
【发布时间】:2019-03-08 15:19:05
【问题描述】:

我正在尝试通过 App Metrics Template 使用 Grafana-Influxdb 在 k8s 中监控我的 aspnet core webapp。

我已按照this article 和应用指标文档中发布的所有步骤进行操作。但是,我看不到来自 Influx-db 的任何数据。

我已经检查过的一些事情:

  • Influxdb 数据源已正确连接到 Grafana
  • /metrics 和 /metrics-text 正在返回数据
  • 我检查了 Influx-db 的日志,似乎 ping 正常

[httpd] xx.xxxx.xx.xx - - [07/Mar/2019:01:58:14 +0000] "GET /ping HTTP/1.1" 204 0 "-" "kube-probe/1.12" 77f046bd-407c-11e9-b1f0-a68c07c04186 54

连接Influxdb的代码:

    var metrics = new MetricsBuilder()
        .Report.ToInfluxDb(options => {
            options.InfluxDb.BaseUri = new Uri("http://influxdb-influxdb.monitoring:8086");
            options.InfluxDb.Database = "appmetrics";
            options.InfluxDb.Consistenency = "consistency";          
            options.InfluxDb.RetentionPolicy = "rp";
            options.InfluxDb.CreateDataBaseIfNotExists = true;
            options.HttpPolicy.BackoffPeriod = TimeSpan.FromSeconds(30);
            options.HttpPolicy.FailuresBeforeBackoff = 5;
            options.HttpPolicy.Timeout = TimeSpan.FromSeconds(10);
            options.MetricsOutputFormatter = new MetricsInfluxDbLineProtocolOutputFormatter();                
            options.FlushInterval = TimeSpan.FromSeconds(20);
        })
        .Build();

        services.AddMemoryCache();
        services.AddMetrics(metrics);

【问题讨论】:

  • 由于“遵循了文章中的所有步骤”,您的启动配置看起来与文章几乎完全不同。我自己没有亲自设置,但也许问题出在你改变的东西上。作为一个例子。 Configure 中似乎也有一些必要的调用,但你没有在此处发布:app.UseMetricsapp.UseMetricsReporting。你加了这些吗?
  • 我为使其工作所做的工作是遵循此存储库 github.com/AppMetrics/Samples.V2 中的演示 AspNetCore2.Api.Reservoirs。有很多选项可以配置指标,以前的所有选项都不适合我

标签: asp.net-core kubernetes grafana influxdb


【解决方案1】:

解决方案由 cmets 中的Javier Hertfelder 提供:

为了使它工作,我所做的就是遵循这个存储库中的演示 AspNetCore2.Api.Reservoirs github.com/AppMetrics/Samples.V2 有很多选项可以配置指标,而之前的所有选项都不适合我

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-19
    • 2019-05-03
    • 2022-06-21
    • 1970-01-01
    • 2019-10-05
    • 1970-01-01
    相关资源
    最近更新 更多