简体   繁体   English

AWS Elastic Beanstalk的应用程序见解

[英]Application Insights with AWS Elastic Beanstalk

I'm trying to get Application Insights running on an application on hosted on multiple instances in an AWS Elastic Beanstalk. 我试图让Application Insights在AWS Elastic Beanstalk的多个实例上托管的应用程序上运行。 The problem is that the servers are all seen as a single server. 问题在于服务器都被视为单个服务器。 I think this is because they all have the same HostName. 我认为这是因为它们都具有相同的主机名。

Does anyone know how I can: 有谁知道我怎么做:

  • Set the ServerName property in Application Insights manually on startup? 启动时手动在Application Insights中设置ServerName属性吗? or 要么
  • Force AWS to give each instance a different HostName? 强制AWS为每个实例赋予不同的主机名?

You can change set the value with Telemetry Initializer if the field is public, alternatively you can create your own property to store the correct name. 如果该字段是公共字段,则可以使用Telemetry Initializer更改设置值,或者可以创建自己的属性来存储正确的名称。 Either way, Telemetry Initializer looks like a way to go: 无论哪种方式, 遥测初始化器都看起来像一种方法:

public class MyTelemetryInitializer : ITelemetryInitializer
{
    public void Initialize(ITelemetry telemetry)
    {
        var requestTelemetry = telemetry as RequestTelemetry;
        // Is this a TrackRequest() ?
        if (requestTelemetry == null) return;
        int code;
        bool parsed = Int32.TryParse(requestTelemetry.ResponseCode, out code);
        if (!parsed) return;
        if (code >= 400 && code < 500)
        {
            // If we set the Success property, the SDK won't change it:
            requestTelemetry.Success = true;
            // Allow us to filter these requests in the portal:
            requestTelemetry.Context.Properties["Overridden400s"] = "true";
        }
        // else leave the SDK to set the Success property      
    }

As you can see, you can access the existing properties of the telemetry item as well as add new ones if required. 如您所见,您可以访问遥测项目的现有属性,并在需要时添加新属性。 I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM