.Net Core 2.*+ InfluxDB+Grafana+App Metrics实时性能监控
前言
.net core 2.* 实施性能监控
这个工具其实给运维 大大们用起来是更爽的。但是Grafana现在还没有找到中文版。
本文需要了解的相关技术与内容:
InfluxDb(分布式时序数据库,开源)(注:分布式部分已商业化最新的分布式版本已不在开源,单例的继续开源)
Grafana(开源的,功能齐全的度量仪表盘和图形编辑器)
App Metrics(主角,开源的支持.NET Core的监控插件,采用管道注入的方式,对代码的入侵性极小)
效果图
安装influxdb
influxdb在1.*版本之后就不再有网页版本了。
所以大家选择版本的时候一定要注意这个事情免得找不到influxdb 的 admin控制台
下载地址
https://dl.influxdata.com/influxdb/releases/influxdb-1.6.3_windows_amd64.zip
我这里选择的是1.6.3版本
解压文件夹之后进行如下配置,打开config中的配置文件
修改如下几项目
[meta]
# Where the metadata/raft database is stored
dir = "D:/influxdb/meta"
[data]
# The directory where the TSM storage engine stores TSM files.
dir = "D:/influxdb/data"
# The directory where the TSM storage engine stores WAL files.
wal-dir = "D:/influxdb/wal"
如果使用的是1.*之前的版本就可以打开admin控制台
配置是这样的
[admin]
# Determines whether the admin service is enabled.
enabled = true # The default bind address used by the admin service.
bind-address = ":8083"
然后运行influxdb
influxd -config influxdb.conf
运行起来之后就是这个样子
好多 人都使用了1.*之后的版本,没有admin控制台给大家 推荐一个工具
InfluxDBStudio-0.1.0 用这个货创建一个数据库就可以了
配置Grafana
下载地址:
https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.1.windows-amd64.zip
解压之后 在文件夹之后直接运行这个程序
grafana-server.exe
Grafana默认会监听3000的端口,所以我们进入
http://127.0.0.1:3000,
默认账号密码:admin admin
就是这样的效果啦
安装默认的模板
地址如下:https://grafana.com/dashboards/2125
这里选择刚才我们下载的json文件就可以,或者直接输入2125都可以
添加数据库配置文件
配置好了之后就会出现这个样子了
在.net core配置
先把这些DLL引用了吧。项目右键编辑帖进去 重新生成一下就可以了。
<PackageReference Include="App.Metrics" Version="2.1.0" />
<PackageReference Include="App.Metrics.AspNetCore.Endpoints" Version="2.0.0" />
<PackageReference Include="App.Metrics.AspNetCore.Reporting" Version="2.0.0" />
<PackageReference Include="App.Metrics.AspNetCore.Tracking" Version="2.0.0" />
<PackageReference Include="App.Metrics.Extensions.Reporting.InfluxDB" Version="1.2.0" />
<PackageReference Include="App.Metrics.Formatters.Json" Version="2.1.0" />
<PackageReference Include="App.Metrics.Reporting.InfluxDB" Version="2.0.0" />
修改appsettings.json配置文件
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"InfluxDB": {
"IsOpen": true,
"DataBaseName": "LogDb",
"ConnectionString": "http://127.0.0.1:8086",
"username": "admin",
"password": "xxxxxxxxxx",
"app": "LogDbDemo",
"env": "stage"
}
}
修改startup进行管道接管
ConfigureServices添加 如下
#region Metrics监控配置
string IsOpen = Configuration.GetSection("InfluxDB")["IsOpen"].ToLower();
if (IsOpen == "true")
{
string database = Configuration.GetSection("InfluxDB")["DataBaseName"];
string InfluxDBConStr = Configuration.GetSection("InfluxDB")["ConnectionString"];
string app = Configuration.GetSection("InfluxDB")["app"];
string env = Configuration.GetSection("InfluxDB")["env"];
string username = Configuration.GetSection("InfluxDB")["username"];
string password = Configuration.GetSection("InfluxDB")["password"]; var uri = new Uri(InfluxDBConStr); var metrics = AppMetrics.CreateDefaultBuilder()
.Configuration.Configure(
options =>
{
options.AddAppTag(app);
options.AddEnvTag(env);
})
.Report.ToInfluxDb(
options =>
{
options.InfluxDb.BaseUri = uri;
options.InfluxDb.Database = database;
options.InfluxDb.UserName = username;
options.InfluxDb.Password = password;
options.HttpPolicy.BackoffPeriod = TimeSpan.FromSeconds(30);
options.HttpPolicy.FailuresBeforeBackoff = 5;
options.HttpPolicy.Timeout = TimeSpan.FromSeconds(10);
options.FlushInterval = TimeSpan.FromSeconds(5);
})
.Build(); services.AddMetrics(metrics);
services.AddMetricsReportScheduler();
services.AddMetricsTrackingMiddleware();
services.AddMetricsEndpoints(); }
#endregion
Configure添加这些东西
#region 注入Metrics
string IsOpen = Configuration.GetSection("InfluxDB")["IsOpen"].ToLower();
if (IsOpen == "true")
{
app.UseMetricsAllMiddleware();
// Or to cherry-pick the tracking of interest
app.UseMetricsActiveRequestMiddleware();
app.UseMetricsErrorTrackingMiddleware();
app.UseMetricsPostAndPutSizeTrackingMiddleware();
app.UseMetricsRequestTrackingMiddleware();
app.UseMetricsOAuth2TrackingMiddleware();
app.UseMetricsApdexTrackingMiddleware(); app.UseMetricsAllEndpoints();
// Or to cherry-pick endpoint of interest
app.UseMetricsEndpoint();
app.UseMetricsTextEndpoint();
app.UseEnvInfoEndpoint();
}
#endregion
运行项目跑一圈之后 返回Grafana就出现了这样的图例
.Net Core 2.*+ InfluxDB+Grafana+App Metrics实时性能监控的更多相关文章
- 使用App Metrics实现性能监控
App Metrics监控需要安装InfluxDB时序数据库和Grafana可视化分析工具 1.安装InfluxDB 下载地址:https://portal.influxdata.com/downlo ...
- .Net Core 2.0+ InfluxDB+Grafana+App Metrics 实现跨平台的实时性能监控
最近这段时间一直在忙,没时间写博客,负责了一个项目,从前端到后端一直忙,同时还有其他第几个项目的系统架构要处理. 去年就开始关注net core了,只是平时写写demo,没用在项目中,正好这次机会就用 ...
- 基于 Njmon + InfluxDB + Grafana 实现性能指标实时可视监控
引言 最近逛 nmon 官网时,发现了一个新工具 njmon,功能与 nmon 类似,但输出为 JSON 格式,可以用于服务器性能统计. 可以使用 njmon 来向 InfluxDB 存储服务器性能统 ...
- 【jmeter】基于InfluxDB&Grafana的JMeter实时性能测试数据的监控和展示
本文主要讲述如何利用JMeter监听器Backend Listener,配合使用InfluxDB+Grafana展示实时性能测试数据 关于JMeter实时测试数据 JMeter从2.11版本开始,命令 ...
- jmeter --- 基于InfluxDB&Grafana的JMeter实时性能测试数据的监控和展示
转自:https://blog.csdn.net/RickyOne_RR/article/details/50637839 本文主要讲述如何利用JMeter监听器Backend Listener,配合 ...
- 转:基于InfluxDB&Grafana的JMeter实时性能测试数据的监控和展示
本文主要讲述如何利用JMeter监听器Backend Listener,配合使用InfluxDB+Grafana展示实时性能测试数据 关于JMeter实时测试数据 JMeter从2.11版本开始,命令 ...
- .NetCore使用skywalking实现实时性能监控
一.简介 很久之前写了一篇 <.Net Core 2.0+ InfluxDB+Grafana+App Metrics 实现跨平台的实时性能监控>关于NetCore性能监控的文章,使用Inf ...
- [#] - .Net平台的实时性能监控
App Metricshttps://www.app-metrics.io ASP.NET Core之跨平台的实时性能监控http://www.cnblogs.com/GuZhenYin/p/7170 ...
- 搭建jmeter+influxdb+grafana压测实时监控平台(超详细,小白适用)
1.前言 在使用jmeter做性能测试的时候,监控系统性能的时候,无论是使用插件还是报告生成,都没法实现实时监控.使用JMeter+Influxdb+Grafana可以实现实时监控. 本次环境搭建各软 ...
随机推荐
- Prim算法和Kruskal算法介绍
一.Prim算法 普利姆(Prim)算法适用于求解无向图中的最小生成树(Minimum Cost Spanning Tree).下面是Prim算法构造最小生成树的过程图解. ...
- docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /tmp/tfserving/
注意要是当前的完整路径 pwd查看到完整路径,再加入到source里面即可
- tensorflow.python.framework.errors_impl.PermissionDeniedError: /data; Permission denied
在linux系统中,tensorflow跑mnist数据集出现错误,本应该自动下载的数据集 将mnist自动下载的路径,由/data/mnist之前的/删掉即可.改为data/mnist.
- 11 git第二部分(未完成)
https://www.cnblogs.com/shangchunhong/p/9444335.html
- 题解 [51nod1607] 卷积和
题面 解析 神仙LZF随机找出的毒瘤题. 一开始读题过于草率导致\(naive\)了. step 1 看上去特别像数位DP(实际上也有一点). 先预处理出有\(i\)位的数(最高位不为\(0\))的数 ...
- HDU 6107 - Typesetting | 2017 Multi-University Training Contest 6
比赛的时候一直念叨链表怎么加速,比完赛吃饭路上突然想到倍增- - /* HDU 6107 - Typesetting [ 尺取法, 倍增 ] | 2017 Multi-University Train ...
- MyBatis插件原理
官方文档:https://mybatis.org/mybatis-3/zh/configuration.html#plugins MyBatis 允许你在已映射语句执行过程中的某一点进行拦截调用.默认 ...
- hbuilder离线打包iOS,xcode开发卡在启动页注意点
1.Display Name的名称与manifest.json中的name保持一致. 2.项目文件夹名.contro.xml中的appid.manifest.json中的id一致
- P1129 [ZJOI2007]矩阵游戏 二分图匹配
思路:脑子+二分图匹配 提交:1次(课上讲过) 题解: 发现:如果符合题意,那么行和列一定是一一匹配的(必要条件),所以最大匹配必须是$n$. 同时我们发现,一定可以通过交换行列的方式,将(看起来)有 ...
- 如何打开Mac OSX 终端的颜色
如何打开Mac OSX 终端的颜色 听语音 | 浏览:8453 | 更新:2015-12-15 16:48 1 2 3 4 5 6 7 分步阅读 Mac 终端默认颜色很单一,文件夹和文件无法区分,可以 ...