AWS Elastic Beanstalk的应用程序见解 [英] Application Insights with AWS Elastic Beanstalk

本文介绍了AWS Elastic Beanstalk的应用程序见解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Application Insights在AWS Elastic Beanstalk的多个实例上托管的应用程序上运行.问题在于服务器都被视为单个服务器.我认为这是因为它们都具有相同的主机名.

I'm trying to get Application Insights running on an application on hosted on multiple instances in an 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.

有人知道我怎么做:

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

推荐答案

如果该字段是公共字段,则可以使用Telemetry Initializer更改设置值,也可以创建自己的属性来存储正确的名称.无论哪种方式,遥测初始化程序看起来很可行:

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. 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.

这篇关于AWS Elastic Beanstalk的应用程序见解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆