sls报表监控代码段运行时效
本地配置
如果LogMonitor下AppId为空,则读取外层
"LogMonitor": {
//"AppId": "",
"LogPath": "D:\\logmonitor"
},
"AppId": "KeyingPlatform.Api",
//ConfigureServices
//注册日志监控中间件
services.AddKeyingLogMonitorMiddleware(Configuration);
//framework
MonitorCenter.Instance.Register("AppId", "LogPath");
public static class KeyingLogMonitorMiddleware
{
public static void AddKeyingLogMonitorMiddleware(this IServiceCollection services, IConfiguration configuration)
{
var logMonitor = configuration.GetSection("LogMonitor").Get<LogMonitor>();
if (string.IsNullOrWhiteSpace(logMonitor.AppId))
{
logMonitor.AppId = configuration.GetValue<string>("AppId");
}
MonitorCenter.Instance.Register(logMonitor.AppId, logMonitor.LogPath);
}
}
public class LogMonitor
{
public string AppId { get; set; }
public string LogPath { get; set; }
}
线上配置
D:\logmonitor
sls配置
-- AppId
* | select DISTINCT lower(AppId) where AppId<>'null' LIMIT 100
-- Name
*|select DISTINCT name where name is not null
-- 百分比位图
*|select k, v from(select map(array [0.50,0.75,0.90,0.95,0.99], p) as m from( select approx_percentile(spend, array [0.50,0.75,0.90,0.95,0.99]) as p FROM log)), unnest(m) as t(k, v)
-- 最大最小分析
* | select appId,name,max(spend) maxspend,avg(spend) avgSpend where name is not null group by appId,name order by maxspend desc
-- 趋势图
*|select date_format(date_trunc('minute', __time__),'%m-%d %H:%i') as t, name, spend where name is not null order by t
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)