Skip to content

Prometheus Configuration #37516

Description

@greiner-marcus-auticon

Type of issue

Code doesn't work

Description

First

In section 7.1 Install and configure Prometheus your YAML file uses:

- job_name: "prometheus"
    - scrape_interval: 1s # poll very quickly for a more responsive demo

An error occurs when starting prometheus saying:

  • err="parsing YAML file prometheus.yml: yaml: line 23: did not find expected key"

I had to remove the dash from scrape_interval to be like:

- job_name: "prometheus"
    scrape_interval: 1s # poll very quickly for a more responsive demo

I also had to remove the line before static_configs from

    scrape_interval: 1s # poll very quickly for a more responsive demo
    static_configs:

to be like

    static_configs:

because otherwise I receive an error saying:

  • err="parsing YAML file prometheus.yml: yaml: unmarshal errors:\n line 33: field scrape_interval already set in type config.ScrapeConfig"

Second

The greetings_count metrics name could not be found first time starting prometheus and searching for it in metrics explorer. I had to alter the object initialization for CountGreetings in Program.cs from

public static readonly Counter<int> CountGreetings =
        GreeterMeter.CreateCounter<int>(name: "greetings.count", unit: "Counts the number of greetings");

to something like

public static readonly Counter<int> CountGreetings =
        GreeterMeter.CreateCounter<int>(name: "greetings_count");

to be able to choose the metrics name in prometheus' metrics explorer.

Starting with your code snippet I got into an error in Prometheus under Status -> Targets saying:

invalid metric type "the number of greetings_total counter"

The metrics name is parsed to greetings_count_Counts the number of greetings_total.

Page URL

https://learn.microsoft.com/en-us/dotnet/core/diagnostics/observability-with-otel#7-collect-metrics-with-prometheus

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/diagnostics/observability-with-otel.md

Document Version Independent Id

9db87c45-60ba-ce17-118c-f9bd15306ece

Article author

tommcdon

Metadata

Metadata

Assignees

Labels

🗺️ reQUESTTriggers an issue to be imported into Quest.dotnet-fundamentals/svcin-prThis issue will be closed (fixed) by an active pull request.

Type

No type

Projects

Status
👀 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions