IP address Mismatch between Azure Application Insights and Google Search

只愿长相守 提交于 2020-02-03 10:56:15

问题


Why there is a difference between the IP address reported by Azure Application Insights and standard Google Search (What is my IP)?

  • IP returned by Azure App Insights: xx.xx.xx.0
  • IP returned by Google Search: xx.xx.xx.242

回答1:


Application Insights uses IP to fetch geo location information such as country/region and city and then discards the last octet of the IP for the privacy reasons.

If geo location information extracted from IP is not enough for the scenarios you'd like to address and you still want/need to send unmasked IP, you'd need to submit it as a custom property on the telemetry item with Application Insights SDK. You can use Telemetry Initializer to do that.

public class CopyIPTelemetryInitializer : ITelemetryInitializer
{
    public void Initialize(ITelemetry telemetry)
    {
        if (!string.IsNullOrEmpty(telemetry.Context.Location.Ip))
        {
            telemetry.Context.Properties["client-ip"] = telemetry.Context.Location.Ip;
        }
    }
}


来源:https://stackoverflow.com/questions/42429148/ip-address-mismatch-between-azure-application-insights-and-google-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!