Skip to main content

Metrics

Export Metrics on your APIs with Traefik Hub & Open Telemetry


Introduction

Traefik Hub uses OpenTelemetry (sometimes referred to as OTel). Open Telemetry is an open-source observability framework that allows you to collect, process, and export telemetry data from applications and infrastructure. Open Telemetry helps you get insights into system performance and behavior.

Read More

At any point while reading this documentation you need additional information on OpenTelemetry, you can refer to its official documentation.

Metrics are used to measure and record quantitative data about the performance and behavior of your APIs. Metrics are aggregated over time, allowing you to understand trends and patterns.

Traefik Hub exposes different kinds of metrics:

Good to know

Metrics do not provide detailed information about individual requests or transactions. Metrics provide aggregated information about the overall system or application.

Configuration

To enable OpenTelemetry, you have to adjust the default configuration of your Traefik Hub Gateway Helm Chart with the dedicated options, like in the following examples.

Traefik Hub Gateway Helm Chart values.yaml
metrics:
otlp:
enabled: true
http:
enabled: true
endpoint: "http://myotlpcollector:4318"

Adjust the Configuration

To adjust the default configuration, please refer to the values files of the Chart.


Dataflow Metrics

MetricTypeDescription
traefik_hub_api_requests_totalCounterThe number of handled API requests.
traefik_hub_api_requests_duration_milliseconds_sum traefik_hub_api_requests_duration_milliseconds_count traefik_hub_api_requests_duration_milliseconds_bucketHistogramProcessing duration histograms.
traefik_hub_api_requests_bytes_totalCounterRequests size (in bytes) handled by APIs (body size).
traefik_hub_api_responses_bytes_totalCounterResponses size (in bytes) handled by APIs (body size).

Labels

Labels, also known as tags or dimensions, are key-value pairs that provide context to metrics. Labels add additional information to your metrics and traces, allowing you to segment and filter data to gain more insights.

LabelDescriptionExample
codeRequest code"200"
methodRequest Method"GET"
protocolRequest protocol"http", "grpc", ...
user_idUnique user identifier"645133c75d2aee16b07ef3da"
The user_id holds the internal ID or the JWT ID, depending on where the user comes from.
emailUser email"[email protected]"
The owner of the API Key or Application consuming the API.
token_nameName of the API key used to authenticate."my-test-token"
api_nameName of the API."flight-api"
api_version_nameThe version of the API."flight-api-v2"
api_namespaceNamespace of the API."airlines"
tls_versionTLS version used for the request."1.0"
tls_cipherTLS cipher used for the request."TLS_FALLBACK_SCSV"

API Management Metrics

MetricTypeLabelsDescription
traefik_hub_apis_ratioGaugeapi_namespaceNumber of APIs.
traefik_hub_apis_bundle_ratioGauge-Number of API Bundles.
traefik_hub_apis_plans_ratioGauge-Number of API Plans.
traefik_hub_api_portal_apis_ratioGauge-Number of APIs published on API Portals.
traefik_hub_api_versions_ratioGaugeapi_name, api_namespaceNumber of API versions.
traefik_hub_api_accesses_ratioGauge-Number of API Accesses.
traefik_hub_api_keys_ratioGaugeuser_id, emailNumber of API keys with access to APIs on the agent.
traefik_hub_users_ratioGauge-Number of users that belong to a group attached to at least one API Access.
traefik_hub_user_groups_ratioGauge-Number of groups attached to at least one API Access.
traefik_hub_portals_ratioGauge-Number of API Portals.

Labels

Labels, also known as tags or dimensions, are key-value pairs that provide context to metrics. Labels add additional information to your metrics and traces, allowing you to segment and filter data to gain more insights.

LabelDescriptionExample
user_idUnique user identifier"645133c75d2aee16b07ef3da"
The user_id holds the internal ID or the JWT ID, depending on where the user comes from.
emailUser email"[email protected]"
The owner of the API Key or Application consuming the API.
token_nameName of the API key used to authenticate."my-test-token"
api_nameName of the API."flight-api"
api_version_nameThe version of the API."flight-api-v2"
api_namespaceNamespace of the API."airlines"

Ingress Metrics

Global Metrics

MetricTypeLabelsDescription
traefik_config_reloads_totalCountThe total count of configuration reloads.
traefik_config_last_reload_successGaugeThe timestamp of the last configuration reload success.
traefik_open_connectionsGaugeentrypoint, protocolThe current count of open connections, by entrypoint and protocol.
traefik_tls_certs_not_afterGaugeThe expiration date of certificates.
traefik_hub_ingresses_ratioGaugeNumber of Ingresses in the cluster.
traefik_hub_ingress_routes_ratioGaugeNumber of Traefik Ingresses in the cluster.
traefik_hub_services_ratioGaugeNumber of Services in the cluster.

Labels

Here is a comprehensive list of labels that are provided by the global metrics:

LabelDescriptionexample
entrypointEntrypoint that handled the connection"example_entrypoint"
protocolConnection protocol"TCP"

OpenTelemetry Semantic Conventions

Traefik Proxy follows official OpenTelemetry semantic conventions v1.23.1.

HTTP Server

MetricTypeLabelsDescription
http.server.request.durationHistogramerror.type, http.request.method, http.response.status_code, network.protocol.name, server.address, server.port, url.schemeDuration of HTTP server requests
Labels

Here is a comprehensive list of labels that are provided by the metrics:

LabelDescriptionexample
error.typeDescribes a class of error the operation ended with"500"
http.request.methodHTTP request method"GET"
http.response.status_codeHTTP response status code"200"
network.protocol.nameOSI application layer or non-OSI equivalent"http/1.1"
network.protocol.versionVersion of the protocol specified in network.protocol.name"1.1"
server.addressName of the local HTTP server that received the request"example.com"
server.portPort of the local HTTP server that received the request"80"
url.schemeThe URI scheme component identifying the used protocol"http"

HTTP Client

MetricTypeLabelsDescription
http.client.request.durationHistogramerror.type, http.request.method, http.response.status_code, network.protocol.name, server.address, server.port, url.schemeDuration of HTTP client requests
Labels

Here is a comprehensive list of labels that are provided by the metrics:

LabelDescriptionexample
error.typeDescribes a class of error the operation ended with"500"
http.request.methodHTTP request method"GET"
http.response.status_codeHTTP response status code"200"
network.protocol.nameOSI application layer or non-OSI equivalent"http/1.1"
network.protocol.versionVersion of the protocol specified in network.protocol.name"1.1"
server.addressName of the local HTTP server that received the request"example.com"
server.portPort of the local HTTP server that received the request"80"
url.schemeThe URI scheme component identifying the used protocol"http"

HTTP Metrics

On top of the official OpenTelemetry semantic conventions, Traefik provides its own metrics to monitor the incoming traffic.

EntryPoint Metrics

MetricTypeLabelsDescription
traefik_entrypoint_requests_totalCountcode, method, protocol, entrypointThe total count of HTTP requests received by an entrypoint.
traefik_entrypoint_requests_tls_totalCounttls_version, tls_cipher, entrypointThe total count of HTTPS requests received by an entrypoint.
traefik_entrypoint_request_duration_secondsHistogramcode, method, protocol, entrypointRequest processing duration histogram on an entrypoint.
traefik_entrypoint_requests_bytes_totalCountcode, method, protocol, entrypointThe total size of HTTP requests in bytes handled by an entrypoint.
traefik_entrypoint_responses_bytes_totalCountcode, method, protocol, entrypointThe total size of HTTP responses in bytes handled by an entrypoint.

Router Metrics

MetricTypeLabelsDescription
traefik_router_requests_totalCountcode, method, protocol, router, serviceThe total count of HTTP requests handled by a router.
traefik_router_requests_tls_totalCounttls_version, tls_cipher, router, serviceThe total count of HTTPS requests handled by a router.
traefik_router_request_duration_secondsHistogramcode, method, protocol, router, serviceRequest processing duration histogram on a router.
traefik_router_requests_bytes_totalCountcode, method, protocol, router, serviceThe total size of HTTP requests in bytes handled by a router.
traefik_router_responses_bytes_totalCountcode, method, protocol, router, serviceThe total size of HTTP responses in bytes handled by a router.

Service Metrics

MetricTypeLabelsDescription
traefik_service_requests_totalCountcode, method, protocol, serviceThe total count of HTTP requests processed on a service.
traefik_service_requests_tls_totalCounttls_version, tls_cipher, serviceThe total count of HTTPS requests processed on a service.
traefik_service_request_duration_secondsHistogramcode, method, protocol, serviceRequest processing duration histogram on a service.
traefik_service_retries_totalCountserviceThe count of requests retries on a service.
traefik_service_server_upGaugeservice, urlCurrent service's server status, 0 for a down or 1 for up.
traefik_service_requests_bytes_totalCountcode, method, protocol, serviceThe total size of requests in bytes received by a service.
traefik_service_responses_bytes_totalCountcode, method, protocol, serviceThe total size of responses in bytes returned by a service.

Labels

Here is a comprehensive list of labels that are provided by the metrics:

LabelDescriptionexample
cnCertificate Common Name"example.com"
codeRequest code"200"
entrypointEntrypoint that handled the request"example_entrypoint"
methodRequest Method"GET"
protocolRequest protocol"http"
routerRouter that handled the request"example_router"
sansCertificate Subject Alternative NameS"example.com"
serialCertificate Serial Number"123..."
serviceService that handled the request"example_service@provider"
tls_cipherTLS cipher used for the request"TLS_FALLBACK_SCSV"
tls_versionTLS version used for the request"1.0"
urlService server url"http://example.com"
"method label value"

If the HTTP method verb on a request is not one defined in the set of common methods for HTTP/1.1 or the PRI verb (for HTTP/2), then the value for the method label becomes EXTENSION_METHOD.


  • Learn how to use Prometheus to export your API metrics.