当前位置: 首页 > news >正文

asp.net core接入prometheus

安装prometheus和Grafana

参考之前的文章->安装prometheus和Grafana教程
在这里插入图片描述
在这里插入图片描述

源代码

dotnet源代码
在这里插入图片描述

新建.net core7 web项目

在这里插入图片描述
修改Program.cs

using Prometheus;namespace PrometheusStu01;public class Program
{public static void Main(string[] args){var builder = WebApplication.CreateBuilder(args);builder.Services.AddControllers();var app = builder.Build();app.UseRouting();//http请求的中间件,收集http请求信息的app.UseHttpMetrics();//映射监控地址为  /metricsapp.MapMetrics();app.MapControllers();app.Run();}
}

安装prometheus-net.AspNetCore 8.2.1
访问http://localhost:5122/metrics
在这里插入图片描述
修改prometheus.yml

scrape_configs:# 省略其他配置- job_name: "asp.net core web"static_configs:- targets: ["127.0.0.1:5122"]

在这里插入图片描述
重启
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
修改Program.cs

using Prometheus;namespace PrometheusStu01;public class Program
{public static void Main(string[] args){var builder = WebApplication.CreateBuilder(args);builder.Services.AddControllers();var app = builder.Build();app.UseRouting();//http请求的中间件,收集http请求信息的app.UseMetricServer();//看这里>^.^<app.UseMetricServer();//映射监控地址为  /metricsapp.MapMetrics();app.MapControllers();app.Run();}
}

内存占用情况
在这里插入图片描述

参考

https://www.cnblogs.com/savorboard/p/diagnostics.html
https://www.cnblogs.com/sheng-jie/p/how-much-you-know-about-diagnostic-in-dotnet.html
https://learn.microsoft.com/zh-cn/dotnet/core/diagnostics/metrics-collection

http://www.lryc.cn/news/351973.html

相关文章:

  • C++ 变量类型与转换
  • 【杂七杂八】Huawei Gt runner手表系统降级
  • FMEA做不出来的原因究竟是什么?——FMEA软件
  • pandas ExcelWriter写excel报错openpyxl.utils.exceptions.IllegalCharacterError
  • Golang创建文件夹
  • 头歌OpenGauss数据库-I.复杂查询第5关:至少学了某位学生(Oliver)所学的全部课程的学生
  • 【数据结构】哈夫曼树和哈夫曼编码
  • 深入探索微软Edge:领略新一代浏览器的无限可能
  • JavaScript表达式和运算符
  • 爬虫实训案例:中国大学排名
  • C++ IO流
  • debian nginx upsync consul 实现动态负载
  • 前端基础入门三大核心之HTML篇 —— 同源策略的深度解析与安全实践
  • go 微服务框架 kratos 日志库使用方法及原理探究
  • VC++位移操作>>和<<以及逻辑驱动器插拔产生的掩码dbv.dbcv_unitmask进行分析的相关代码
  • 查看gpu
  • CSS与表格设计
  • 阴影映射(线段树)
  • Docker 容器间通讯
  • C语言章节学习归纳--数据类型、运算符与表达式
  • Centos 7.9 使用 iso 搭建本地 YUM 源
  • NFT Insider #131:Mocaverse NFT市值破3.5万ETH,The Sandbox 参加NFCsummit
  • BatBot智慧能源管理平台,更加有效地管理能源
  • 医院预约挂号系统微信小程序APP
  • 【代码随想录 二叉树】二叉树前序、中序、后序遍历的迭代遍历
  • Error:(6, 43) java: 程序包org.springframework.data.redis.core不存在
  • Qt 科目一考试系统(有源码)
  • 在 Visual Studio 2022 (VS2022) 中删除 Git 分支的步骤如下
  • 玩转OpenHarmony智能家居:如何实现开发版“碰一碰”设备控制
  • 订餐系统总结、