1. Công cụ
2. Cài đặt
- Install package qua manager package tool
- Config tại file Program.cs
return WebHost.CreateDefaultBuilder(args)
.UseMetrics(options =>{options.EndpointOptions = endpointsOptions =>{endpointsOptions.MetricsTextEndpointOutputFormatter = new MetricsPrometheusTextOutputFormatter();endpointsOptions.MetricsEndpointOutputFormatter = new MetricsPrometheusProtobufOutputFormatter();};}).UseStartup<Startup>();
- Config tại startup.cs
public void ConfigureServices(IServiceCollection services)
3. Cài đặt Promethes{.....services.AddHealth().AddHealthReportingHostedService();services.AddMvcCore().AddMetricsCore();}
- Config prometheus.yml
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
scheme: https
metrics_path: /metrics-text
static_configs:
- targets: ['localhost:44324']
- Chạy prometheus. Vào trình duyệt gõ: http://localhost:9090/targets nếu state UP thì connect thành công
4. Cài Grafana
- Các bước cài cũng chỉ next next và finish, nên mình sẽ không hướng dẫn củ thể lên đây
- Truy cập http://localhost:3000/
- Đăng nhập với tài khoản admin, pass: admin
- Add data source prometheus như dưới:
- Nếu Save và Test thành công vào import
nếu có thắc mắc hãy liên hệ Đinh Công Tân VCCorp
No comments:
Post a Comment