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.

Configuration

To enable OpenTelemetry, you have to adjust the default configuration of your Traefik Hub agent by adding the following values.

Values

ValueDescriptionRequired
hub.metrics.opentelemetry.insecureSetting it to true allows Prometheus to connect to the OpenTelemetry endpoint hub.metrics.opentelemetry.address.Yes
hub.metrics.opentelemetry.addressThe address of your Prometheus instance.
This can be an internal (prometheus.monitoring:9090) or external (monitoring.example.com) URL.
Yes
hub.metrics.opentelemetry.pathThe OpenTelemetry endpoint used by the Traefik Hub agent.
The default endpoint is /api/v1/otlp/v1/metrics.
Yes

Adjust the Configuration

If you don't have it already, save the default Traefik Hub configuration using Helm.

CLI
helm show values traefik/traefik-hub > values.yaml

Second, adjust the values.yaml file by adding the configuration for OpenTelemetry to the additionalArguments part of the file.

YAML
additionalArguments:
- --hub.metrics.opentelemetry.insecure=true
- --hub.metrics.opentelemetry.address=prometheus.monitoring:9090
- --hub.metrics.opentelemetry.path=/api/v1/otlp/v1/metrics
info

In the shown example above, hub.metrics.opentelemetry.address points to an internal running Prometheus cluster (prometheus.monitoring:9090).

For more information, please read the documentation about the configuration options.

Deploy Your Custom Settings

Once the configuration is adjusted, use Helm to (re)deploy the Traefik Hub agent with the new values to enable OpenTelemetry.

CLI
helm upgrade --install --namespace traefik-hub traefik-hub traefik/traefik-hub \
--values values.yaml

Congratulations, OpenTelemtry is now enabled.

Good to know

If you prefer, you can also deploy the needed additionalArguments to enable OpenTelemetry as a "one-liner" command with Helm.

You can do that by adding the additionalArguments values through --set.

CLI
helm upgrade --install --namespace traefik-hub traefik-hub traefik/traefik-hub --set additionalArguments='{\
--hub.metrics.opentelemetry.insecure,\
--hub.metrics.opentelemetry.address=prometheus.monitoring:9090,\
--hub.metrics.opentelemetry.path=/api/v1/otlp/v1/metrics\
}'

Please refer to the official Helm documentation to learn more about --set and the use of arrays and list.


Metrics

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.

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).
Every Dataflow metric has the following labels available

code, method, protocol, user_id, email, token_name, api_name, api_version_name, api_namespace, gateway_name, agent_id, instance_id, tls_version, tls_cipher

API Management Metrics

MetricTypeLabelsDescription
traefik_hub_api_gateways_ratioGaugeagent_id, instance_idNumber of API Gateways.
traefik_hub_apis_ratioGaugeagent_id, instance_id, api_namespaceNumber of APIs.
traefik_hub_api_gateway_apis_ratioGaugeagent_id, instance_id, gateway_nameNumber of APIs published on API Gateways.
traefik_hub_api_portal_apis_ratioGaugeagent_id, instance_id, portal_nameNumber of APIs published on API Portals.
traefik_hub_api_versions_ratioGaugeagent_id, instance_id, api_name, api_namespaceNumber of API versions.
traefik_hub_api_collections_ratioGaugeagent_id, instance_id, api_namespaceNumber of API collections.
traefik_hub_api_rate_limits_ratioGaugeagent_id, instance_idNumber of API Rate Limit.
traefik_hub_api_accesses_ratioGaugeagent_id, instance_idNumber of API Accesses.
traefik_hub_api_keys_ratioGaugeagent_id, instance_id, user_id, user_emailNumber of API keys with access to APIs on the agent.
traefik_hub_users_ratioGaugeagent_id, instance_idNumber of users that belong to a group attached to at least one API Access.
traefik_hub_user_groups_ratioGaugeagent_id, instance_idNumber of groups attached to at least one API Access.
traefik_hub_portals_ratioGaugeagent_id, instance_id, portal_typeNumber of API Portals.

Ingress Metrics

MetricTypeDescription
traefik_hub_edge_ingresses_ratioGaugeNumber of edge ingress deprecated.
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.
traefik_hub_acps_ratioGaugeNumber of ACPs deprecated.
Each ingress metric has the following labels available

agent_id, instance_id

Deployment Metrics

MetricTypeLabelsDescription
traefik_hub_api_nodes_ratioGaugeagent_id, instance_idNumber of nodes hosting microservices serving APIs.
traefik_hub_nodes_ratioGaugeagent_id, instance_idNumber of nodes in the cluster.

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"
gateway_nameName of the API Gateway."my-gateway"
agend_idIdentifier of the Traefik Hub agent."5d351900-26e0-408a-8f36-2112b50b26ff"
instance_idPod ID of the Traefik Hub agent instance."traefik-6d67f77db9-nrrnm"
tls_versionTLS version used for the request."1.0"
tls_cipherTLS cipher used for the request."TLS_FALLBACK_SCSV"
portal_typeType of the API Portal."single_cluster", "multi_cluster"
portal_nameName of the API Portal."my-api-portal"

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