所有,我正在尝试将 OpenTelemetry 收集器与 Prometheus 集成到 .Net 应用程序中。我在应用程序中使用 OTLP Exporter,并在同一系统上将 OpenTelemetry Collector 作为 Windows 服务运行。请找到以下我用于收集器的“config.yaml”
extensions:
health_check:
pprof:
endpoint: 0.0.0.0:1777
zpages:
endpoint: 0.0.0.0:55679
receivers:
otlp:
protocols:
grpc:
http:
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 5s
static_configs:
- targets: [ 'localhost:55681' ]
processors:
batch:
exporters:
zipkin:
endpoint: "http://127.0.0.1:9411/api/v2/spans"
prometheus:
endpoint: "localhost:55681"
namespace: promexample
const_labels:
label1: value1
logging:
logLevel: debug
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging,zipkin]
metrics:
receivers: [otlp,prometheus]
processors: [batch]
exporters: [logging,prometheus]
extensions: [health_check, pprof, zpages]
这是'prometheus.yml'
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 10s
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:55681']
我没有看到导出到 Prometheus 的指标。我正在应用程序中以编程方式创建一些计数器,并在 Prometheus 中寻找相同的计数器。
请注意,我尝试将跟踪导出到 Zipkin 并且效果很好。
任何帮助是极大的赞赏。Prometheus UI 目标运行状况显示为“UP”,如下所示。