Xabaril / AspNetCore.Diagnostics.HealthChecks

Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Apache License 2.0
4.04k stars 789 forks source link

Setting up prometheus endpoint into prometheus portal/Grafana #545

Open kisalay19 opened 4 years ago

kisalay19 commented 4 years ago

This is a general query and not an issue but more of a help needed in understanding how to push results to prometheus.

Below is my setup in Startup.cs

app.UseHealthChecksPrometheusExporter("/prometheus");

On browsing this endpoint I can see the page in Prometheus text format. Now how do I visualize or link this data in the actual prometheus environment or Grafana.

  1. I have a local environment of Prometheus running through docker in my system http://localhost:9090
  2. I have a local environment of Grafana running through docker in my system http://localhost:3030

Below are the references I am using in my .NET Core API :

  1. Microsoft.AspNetCore.Diagnostics.HealthChecks 2.2.0
  2. Microsoft.Extensions.Diagnostics.HealthChecks 3.1.4
  3. AspNetCore.HealthChecks.Prometheus.Metrics 3.1.3
3GDXC commented 3 years ago

@kisalay19 you need to configure prometheus to scrap the output, typically by providing a prometheus.yml

`global: scrape_interval: 15s evaluation_interval: 15s

A scrape configuration containing exactly one endpoint to scrape.

scrape_configs:

saber13812002 commented 1 month ago

i added this:

metrics_path: '/health_metrics' 

if you use 

            app.UseHealthChecksPrometheusExporter("/health_metrics");

so because you use /prometheus

            app.UseHealthChecksPrometheusExporter("/prometheus");

you should add

metrics_path: '/prometheus' 

to your yaml file as prometheus configuration file

result something like this:

job_name: 'health_check_exporter'
    scrape_interval: 5s
    metrics_path: '/prometheus' 
    static_configs:
    targets: ['someservice:9110']`

i suggest use this for grafana dashboard :

https://github.com/saber13812002/easy-payment-backend/blob/main/DevOps/cluster/grafana/prometheus-net-process-metrics_rev3.json

import this and enjoy it:

image

saber13812002 commented 1 month ago

this can close