Terraform
HCP Terraform Operator for Kubernetes metrics
This topic provides reference information about the Prometheus-compatible metrics available in the HCP Terraform and Terraform Enterprise operators for Kubernetes.
Available metrics
The operator exposes all metrics provided by the controller-runtime by default. Refer to the Kubebuilder documentation for a full list of available metrics.
Starting with version 2.10.0, the operator introduces HCP Terraform–specific metrics. These metrics use the prefix hcp_tf_*.
The operator exposes the following metrics. Note that the metrics are provided by specific controllers. Refer to the Controller column for the corresponding metric.
| Metric name | Type | Description | Controller |
|---|---|---|---|
hcp_tf_runs{run_status, agent_pool_id, agent_pool_name} | Gauge | Pending runs by statuses. | RunsCollector |
hcp_tf_runs_total{agent_pool_id, agent_pool_name} | Gauge | Total number of pending runs. | RunsCollector |
Scrape metrics
The operator exposes metrics in the Prometheus format for each controller. Refer to the Prometheus data model for more information on the metric format.
Metrics are available at the standard /metrics path over the HTTPS port 8443.
The metrics are protected by kube-rbac-proxy. This allows RBAC-based access to the metrics within the Kubernetes cluster.
How metrics are scraped will depend on how you operate your Prometheus server. The following example assumes that you use the Prometheus Operator to run Prometheus.
If you deployed the HCP Terraform Operator using the Helm chart, it creates a Kubernetes ClusterIP Service resource. Use this service as a target for Prometheus. The service name is generated using the following template: {{ .Release.Name }}-controller-manager-metrics-service.
The following example shows a Prometheus Operator ConfigMap configured to scrape metrics from an HCP Terraform Operator Helm release named hcpt-operator. In this configuration, the service name is hcpt-operator-controller-manager-metrics-service.
apiVersion: v1
data:
...
prometheus.yml: |
...
- job_name: hcpt-operator
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
scheme: https
scrape_interval: 15s
scrape_timeout: 5s
static_configs:
- targets:
- hcpt-operator-controller-manager-metrics-service:8443
tls_config:
insecure_skip_verify: true