open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.36k stars 1.45k forks source link

promethues exporter not working as expected, metrics is empty #4453

Closed offSwitch closed 2 years ago

offSwitch commented 2 years ago

Describe the bug metrics is empty

Steps to reproduce after run opentelemetry-go\example\otel-collector\main.go image

curl http://192.168.137.15:32664/metrics is empty image

but jaeger exporter working correctly image

What did you expect to see?

What did you see instead?

What version did you use? otel/opentelemetry-collector:0.38.0

What config did you use? otel-collector-config:

receivers:
  otlp:
    protocols:
      grpc:
      http:
processors:
  batch:
extensions:
  zpages: {}
  memory_ballast:
    # Memory Ballast size should be max 1/3 to 1/2 of memory.
    size_mib: 683
exporters:
  jaeger:
    endpoint: "jaeger.default.svc.cluster.local:14250" # Replace with a real endpoint.
    tls:
      insecure: true
  prometheus:
    endpoint: "0.0.0.0:8889"
service:
  pipelines:
    traces/1:
      receivers: [otlp]
      exporters: [jaeger]
    metrics:
      receivers: [otlp]
      exporters: [prometheus]

otel-collector-service.yaml

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: opentelemetry
    component: otel-collector
  name: otel-collector
  namespace: default
spec:
  ports:
    - name: otlp-grpc
      nodePort: 30247
      port: 4317
      protocol: TCP
      targetPort: 4317
    - name: otlp-http
      nodePort: 32712
      port: 4318
      protocol: TCP
      targetPort: 4318
    - name: metrics
      nodePort: 30514
      port: 8888
      protocol: TCP
      targetPort: 8888
    - name: metrics2
      nodePort: 32664
      port: 8889
      protocol: TCP
      targetPort: 8889
  selector:
    component: otel-collector
  type: NodePort

Environment OS: Ubuntu 20.04

Additional context

sincejune commented 2 years ago

It looks like the main.go only exported traces data. What metrics are you expecting?

offSwitch commented 2 years ago

It looks like the main.go only exported traces data. What metrics are you expecting?

看别人用这个正常收集到trace和metric,这个main.go的readme有点问题,我对go不熟, 换成用java的example跑成功了,成功收集到trace和metric.

LeoSpyke commented 1 year ago

So did you find a solution on this @offSwitch? Because I'm facing the same issue and I don't really know what to do next.