Metrics
Endpoint Summary
Section titled “Endpoint Summary”- 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
).
Request Details
Section titled “Request Details”- Method:
GET
- Path:
/metrics
- Query Parameters: None
- Request Body: None
Response Details
Section titled “Response Details”- 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.
- Standard Prometheus Go client library metrics (e.g., garbage collection stats, goroutine counts) if
- Body Example (Illustrative Format):
# HELP go_goroutines Number of goroutines that currently exist.# TYPE go_goroutines gaugego_goroutines 42# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.# TYPE go_memstats_alloc_bytes gaugego_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 gaugeagent_fd_open_count 25# ... other custom FD metrics ...# HELP agent_app_start_timestamp Application start timestamp (Unix seconds).# TYPE agent_app_start_timestamp gaugeagent_app_start_timestamp 1714474451 # Example timestamp# ... potentially more custom application metrics ...
- Code:
- Error Response:
- This endpoint typically aims to return
200 OK
even if some metrics fail to be collected (errors are usually logged server-side). A500 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.
- This endpoint typically aims to return