Can not connect dotnet metrics to docker prometheus container

37 Views Asked by At

I am getting the following error;

Get "http://localhost:9184/metrics": dial tcp 172.17.0.2:9184: connect: connection refused

My C# code is as follows;

using MeterProvider meterProvider = Sdk.CreateMeterProviderBuilder()
                .AddMeter("HatCo.HatStore")
                .AddPrometheusHttpListener(options => options.UriPrefixes = new string[] { "http://localhost:9184/" })
                .Build();

My docker container yaml file is as follows;

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]

  - job_name: 'OpenTelemetryTest'
    scrape_interval: 1s # poll very quickly for a more responsive demo
    static_configs:
      - targets: ["localhost:9184"]

I have tried all the suggestions like using "docker.for.mac.localhost:9184" within the yml file, but no luck. and yes i am on a mac

0

There are 0 best solutions below