Reporting - Setup Kubernetes Pod Labels by API
Learn how to register Kubernetes pod labels in Ternary using the API to enable label-based cost and usage reporting for Kubernetes workloads.
Kubernetes resources support labels as part of their metadata, which are applied to objects such as pods, deployments, and clusters. These labels can represent attributes like application, environment, or team. Ternary builds on this by enabling Kubernetes pod labels to be registered via API, so container cost and usage data can be grouped and filtered using these labels. This makes it possible to analyze Kubernetes costs using the same reporting and dashboard workflows applied to other cloud resources.
Here’s a step by step process to implement this capability:
Step 1: Understand supported Kubernetes pod labels
Ternary can ingest both system-generated and customer-applied Kubernetes labels as in the following example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: data-ingest-micro
labels:
app.kubernetes.io/component: conditions
app.kubernetes.io/name: data-ingest-micro
app.kubernetes.io/part-of: workflows
company.com/env: production
company.com/squad: automations
company.com/team: analytics
Only a limited subset of Kubernetes pod labels typically provides meaningful value for financial reporting. In this example, the following label keys would be registered in Ternary to support cost analysis:
company.com/env with value production
company.com/squad with value automations
company.com/team with value analytics
app.kubernetes.io/part-of with value workflows
Once registered, these label keys surface their respective values of 'production', 'automations', 'analytics', and 'workflows'". These labels can later be used to group and filter Kubernetes container cost and usage data.
Step 2: Prerequisites
- Obtain an access token or API key by following the Ternary API Authentication guide.
- Identify the Kubernetes pod label keys that should be incorporated into cost and usage reporting.
Ternary requires explicit registration of pod label keys to know which labels to ingest and expose in reporting.
Step 3: Register a Kubernetes pod label
Register a Kubernetes pod label by calling the Ternary API as shown below.
curl -X POST \
-H "Authorization: Bearer ${TERNARY_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
"https://core-api.ternary.app/api/kubernetes-pod-labels" \
-d '{
"tenantID": "TENANT_ID",
"integrationID": "INTEGRATION_ID",
"label": "company.com%2Fenv"
}'
Important: If a label contains the / character, it must be URL-encoded as %2F to avoid conflicts with HTTP path delimiters, as in this example.
Once registered, the label becomes available for grouping and filtering after the next Kubernetes usage data refresh, typically within 24 hours.
Step 4: List registered Kubernetes pod labels
To view all Kubernetes pod labels currently registered for an integration, use the following API call:
curl -H "Authorization: Bearer ${TERNARY_ACCESS_TOKEN}" \
"https://core-api.ternary.app/api/kubernetes-pod-labels?tenantID={TENANT_ID}&integrationID={INTEGRATION_ID}"
This returns the set of pod label keys that Ternary is actively tracking for cost and usage reporting.
Step 5: Unregister a Kubernetes pod label
If a pod label should no longer be included in Kubernetes Container Usage data, it can be unregistered using the API.
curl -X DELETE \
-H "Authorization: Bearer ${TERNARY_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
"https://core-api.ternary.app/api/kubernetes-pod-labels" \
-d '{
"tenantID": "TENANT_ID",
"integrationID": "INTEGRATION_ID",
"label": "My Pod Label"
}'
After deletion, the pod label will stop being associated with Kubernetes container usage data within 30 days. For urgent removal requirements, contact Ternary support.
Step 6: Build reports using Kubernetes pod labels
Once pod labels have been ingested, they can be used in the Ternary Reporting Engine to analyze Kubernetes container cost and usage.
To build a report using Kubernetes pod labels:
- Select the Data Source that aligns with your particular provider's service name as in GKE, AKS, or EKS.
- Select an appropriate metric, such as
requestCPUcost. - Choose a registered pod label to group or filter the report results.
- Apply additional filters as needed to focus on specific applications, environments, or teams.
For example, grouping by a pod label such as my.k8s.pod-label/application allows container costs to be analyzed by application identifier.
The resulting report displays Kubernetes pods grouped by the selected label and their associated cost or usage values, enabling more detailed cost attribution and analysis.

Updated 4 days ago