Sobes.tech
Middle

How do exporters transmit metrics?

sobes.tech AI

Answer from AI

Exporters use various protocols and formats to transmit metrics to monitoring systems such as Prometheus, Grafana, and others. Main approaches:

  1. Prometheus Protocol:

    • Exporter opens an HTTP server on a specific port.
    • Monitoring system (e.g., Prometheus server) periodically "scrapes" metrics from this HTTP server.
    • Data format — text, specific to Prometheus, where each line represents a metric with labels and a value.
    # HELP go_gc_duration_seconds A summary of the pause durations of the go garbage collector.
    # TYPE go_gc_duration_seconds summary
    go_gc_duration_seconds{quantile="0"} 6.14e-06
    go_gc_duration_seconds{quantile="0.25"} 1.0281e-05
    go_gc_duration_seconds{quantile="0.5"} 1.2357e-05
    
  2. Protobuf via gRPC or other RPC frameworks:

    • More efficient in terms of size and parsing.
    • Often used in high-load systems or when transmitting data over networks with limited bandwidth.
    • Requires defining metric structures in .proto files.
  3. JSON over HTTP API:

    • A common format that many systems can easily parse.
    • Exporter provides an HTTP API through which metrics can be obtained in JSON format.
    {
      "metrics": [
        {
          "name": "http_requests_total",
          "labels": {
            "method": "GET",
            "status": "200"
          },
          "value": 1024
        }
      ]
    }
    
  4. OpenTelemetry Protocol (OTLP):

    • A standardized protocol for collecting telemetry (metrics, traces, logs).
    • Supports data transmission via gRPC or HTTP.
    • Data protocols are based on Protobuf.
  5. Proprietary Protocols:

    • Some monitoring systems or agents use their own protocols for data transmission, optimized for their specific needs.

The choice of protocol depends on the monitoring system, exporter type, performance requirements, and flexibility. The most common approach in the Prometheus ecosystem is scraping metrics over HTTP in its native text format.