当前位置:网站首页>Application insights application insights use application maps to build request link views
Application insights application insights use application maps to build request link views
2020-11-06 21:13:26 【itread01】
Applicaotn Insigths Use Application Maps Build request link view
When building the system , In most cases, the logical operation of the request needs to be in different services , Or interface to complete the entire request link . A request can go through multiple components , It is very likely that the client requests the site 1, Site 1 Request site 2, … Site N It's the final processing of data and then it's returned in turn .
In this case , If there is an intuitive view of the status of requests on each site ( success , Failure ), When problems arise , It's very helpful to locate where problems occur . By means of Azure Application insights (Application Insights) The telemetry correlation in the Application Maps Can be realized
Effect display
Implementation principle
Application Insights The data model used to allocate telemetry correlation is defined , Every outgoing operation ( for example , For another component HTTP call ) Is represented by dependency telemetry . Dependency telemetry also defines its own global, unique id, This dependency calls the request initiated by telemetering this id As its operation_parentId. Through operation_Id、operation_parentId and request.id, That is, it can generate a view of decentralized logical operations ( These fields also define the causal order of telemetry calls ).
Example item construction Application Maps
In the example item , This request was made 4 Segment forwarding .
The first paragraph : Native code access APIM(test01.azure-api.cn),
The second paragraph :APIM Visit the site 1(lbphptest.chinacloudsites.cn)
The third paragraph : Site 1 Visit the site 2(lbjavatest.chinacloudsites.cn)
The fourth paragraph : Site 2 Access to the final processing request Azure Function(Http Trigger)( functionapp120201013155425.chinacloudsites.cn).
Preparation conditions
- establish Application Insights (lbphptest202011050549)
- establish APIM(test01)
- Create two App Service (lbphptest and lbjavatest)
- Build a Azure Function(functionapp120201013155425)
notes : If you are not familiar with how to set up the above resources , You can navigate to the resources section at the end of the article
Step one : stay Azure Funciton Enable and associate Application Insights Service
Enter Azure Funciton Portal , Choice Application Insights function , Select the established one according to the page prompts Application Insights (lbphptest202011050549).
The establishment of a Function For the preset HttpTrigger Pattern , Test purpose , Code can be modified without any modification . Refer to the figure below to get Function Of URL, For the next step at the site 2 Call me .
Step two : At the site 2(lbjavatest) Enable and associate Application Insights Service , And deploy code requests Azure Function
Enter the site 2 The portal page of , stay Application Insights According to the prompt in the catalogue Enable Application Insights And choose the same Application Insights.
Deploy code to call step one Azure Function
//Level 3 [HttpGet] [Route("[Action]")] public string Fun([FromQuery] string name) { using (HttpClient httpClient = new HttpClient()) { var url = $"https://functionapp120201013155425.chinacloudsites.cn/api/HttpTrigger1?name={name}"; HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Get, url); httpRequest.Headers.Add("Accept", "application/json, text/plain, */*"); var response = httpClient.SendAsync(httpRequest).Result; string responseContent = response.Content.ReadAsStringAsync().Result; return responseContent; } }
Step three : At the site 1(lbphptest) Enable and associate Application Insights Service , And deploy the code request site 2
Enter the site 1 The portal page of , stay Application Insights According to the prompt in the catalogue Enable Application Insights And choose the same Application Insights.
Deploy code to call the site in step 2 2 Of URL, Code and access Azure Function be similar .
//Level 2 [HttpGet] [Route("[Action]")] public string FunSub([FromQuery] string name) { using (HttpClient httpClient = new HttpClient()) { var url = $"https://lbjavatest.chinacloudsites.cn/WeatherForecast/fun?name={name}"; HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Get, url); httpRequest.Headers.Add("Accept", "application/json, text/plain, */*"); var response = httpClient.SendAsync(httpRequest).Result; string responseContent = response.Content.ReadAsStringAsync().Result; return responseContent; } }
Step four : stay APIM Enable and associate Application Insights Service , And set API Visit the site 1
Enter APIM The portal page of , stay Application Insights Add the same to the table of contents Application Insights.
stay APIM To configure API Visit the site 1(lbphptest)
- Click on “Add API” Button
- Choose from App Service To establish
- Choose a site 1(lbphptest)
Add an operation to the interface. A new operation , Visit the site 1 Interface in /weatherforecast/funsub?name={name}
Step 5 : stay ASP.NET Core Add code in Application Insights SDK And configure the connection string , Access in the interface APIM.
Add... To native code Application Insights SDK
Configure the connection string ( In a string Application Insights Of Overview Page copy )
{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "ApplicationInsights": { "ConnectionString": "InstrumentationKey=xxx-xxx-xxx-xxx-xxxxx;EndpointSuffix=applicationinsights.azure.cn;IngestionEndpoint=https://chinaeast2-0.in.applicationinsights.azure.cn/" }, "AllowedHosts": "*" }
Start the local program , And access it through the browser https://localhost:44323/weatherforecast/Funsubfornt?name=test from local -- apim -- app 1 – app 2 -- function
Look at the final renderings :
【END】
References :
stay Azure Create the first function in the portal : https://docs.azure.cn/zh-cn/azure-functions/functions-create-first-azure-function
Apply to ASP.NET Core Of the application Application Insights : https://docs.azure.cn/zh-cn/azure-monitor/app/asp-net-core
About API management : https://docs.azure.cn/zh-cn/api-management/api-management-key-concepts
stay Azure To establish ASP.NET Core Web Apply : https://docs.azure.cn/zh-cn/app-service/quickstart-dotnetcore?pivots=platform-linux
&n
版权声明
本文为[itread01]所创,转载请带上原文链接,感谢
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World