Skip to content

Metrics

  • Route: /metrics
  • Method: GET
  • Description: Exposes application performance and runtime metrics in the Prometheus text-based exposition format. This endpoint is intended to be periodically scraped by a Prometheus monitoring server.
  • Authentication: Not required (WithAuth: false).
  • Method: GET
  • Path: /metrics
  • Query Parameters: None
  • Request Body: None
  • Success Response:
    • Code: 200 OK
    • Content-Type: text/plain; version=0.0.4; charset=utf-8 (Standard Prometheus content type, likely set by the underlying metrics library).
    • Body: A plain text response containing multiple lines of metrics data. Each metric includes help text (# HELP), type information (# TYPE), and the metric name with labels and its current value. The output includes:
      • Standard Prometheus Go client library metrics (e.g., garbage collection stats, goroutine counts) if metrics.WritePrometheus includes them.
      • File descriptor usage metrics (via metrics.WriteFDMetrics).
      • A gauge metric agent_app_start_timestamp representing the application’s start time as a Unix timestamp.
    • Body Example (Illustrative Format):
      # HELP go_goroutines Number of goroutines that currently exist.
      # TYPE go_goroutines gauge
      go_goroutines 42
      # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
      # TYPE go_memstats_alloc_bytes gauge
      go_memstats_alloc_bytes 2.137472e+06
      # ... other default Go metrics ...
      # HELP agent_fd_open_count Number of currently open file descriptors
      # TYPE agent_fd_open_count gauge
      agent_fd_open_count 25
      # ... other custom FD metrics ...
      # HELP agent_app_start_timestamp Application start timestamp (Unix seconds).
      # TYPE agent_app_start_timestamp gauge
      agent_app_start_timestamp 1714474451 # Example timestamp
      # ... potentially more custom application metrics ...
  • Error Response:
    • This endpoint typically aims to return 200 OK even if some metrics fail to be collected (errors are usually logged server-side). A 500 Internal Server Error might occur if there’s a fundamental problem writing the response to the client, but Prometheus scrapers are generally designed to handle partially successful scrapes.