问题描述
为什么Azure Application Insights报告的IP地址与标准Google搜索(我的IP)之间有一个差异?
Why there is a difference between the IP address reported by Azure Application Insights and standard Google Search (What is my IP)?
- Azure App Insights返回的IP:xx.xx.xx.0
- Google搜索返回的IP:xx.xx.xx.242
推荐答案
Application Insights使用IP来获取地理位置信息(例如国家/地区和城市),然后出于隐私原因丢弃IP的最后一个八位位组.
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.
如果从IP提取的地理位置信息不足以满足您要解决的方案,而您仍然希望/需要发送未屏蔽的IP,则需要使用Application将其作为自定义属性提交到遥测项目上Insights SDK.您可以使用遥测初始化器来实现.
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;
}
}
}
这篇关于Azure Application Insights和Google搜索之间的IP地址不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!