Chapter 3. Configuring tags and labels in cost management
You must configure tags in each integration before cost management can use the tags to automatically organize your cost data.
After adding your integrations to cost management:
- Tag or label resources on each of your integrations. See Section 3.2, “Configuring tags on your integrations”.
- Refine and add to your tags to optimize your view of cost data. See Section 1.2, “Creating a strategy for tags”.
See the Getting started with cost management guide for instructions on configuring integrations.
3.1. How cost management associates tags Copy linkLink copied to clipboard!
Tags in AWS and Microsoft Azure and labels in OpenShift consist of key:value pairs. When the key:value pairs match, the AWS/Azure and OpenShift costs are automatically associated by cost management. Tag matching in cost management is not case sensitive: for example, an AWS resource tagged APP and an OpenShift resource tagged app are a match:
| Source and resource type | Key | Value |
|---|---|---|
| AWS resource (RDS) | APP | Cost-Management |
| OpenShift pod | app | cost-management |
If an AWS resource tag matches with multiple OpenShift projects, the cost and usage of that resource are split evenly between the matched projects.
This is not the case with AWS compute resources that are matched through the instance ID-node relationship. In that case, cost and usage are broken down using information about a project’s resource consumption within the OpenShift cluster.
By default, cost management tracks AWS compute usage and costs by associating the Amazon EC2 instance ID or Microsoft Azure virtual machine instance ID with the OpenShift Container Platform node running on that instance.
3.1.1. Tag matching hierarchy in cost management Copy linkLink copied to clipboard!
To identify your OpenShift resources running on AWS or Azure instances, cost management matches tags between integrations in the following order:
- Direct resource matching (AWS EC2 instance ID or Azure virtual machine instance ID)
- Special OpenShift tags
- Custom tags
3.1.2. OpenShift label inheritance in cost management Copy linkLink copied to clipboard!
OpenShift labels follow an inheritance pattern from cluster to node, and from project to pod. You can associate costs at the node or project level without labeling every pod in your cluster.
Key-value pairs from node and project labels are inherited at the pod level for pod metrics in cost management. Key-value pairs from the cluster and node labels are inherited at the project level by the persistent volume claims (PVC) at each level. You can group by cluster, node, or project labels to see relevant PVCs in those workloads.
If a key already exists in the pod, then the value for that key in the pod remains. Cost management does not overwrite the pod value with the project or node value. A similar process happens from node to project.
Consider the following examples.
Example 1: Your organization assigns the label app and the value costpod1 to a pod. The project for this pod has the label app and the value cost-project. These resources are running on a node with the label us-east-1. The label app and the value costpod1 remain associated with the pod.
Example 2: Your organization has a project with the label app and the value cost-project. The project has three pods running and they are not labeled. Cost management associates the label app and the value cost-project with these pods.
3.1.3. Direct resource matching (instance ID) Copy linkLink copied to clipboard!
The integrations apply these identifiers automatically. This form of tagging provides a direct link between Microsoft Azure or AWS instances and OpenShift nodes.
AWS assigns every EC2 instance a resource identifier (a number such as i-01f44b3d90ef90055). OpenShift nodes are matched directly to the AWS EC2 instance the cluster is running on using the AWS resource identifier. The OpenShift reports in cost management (generated from Prometheus data) include this identifier for nodes. Similarly in Microsoft Azure, each virtual machine instance ID is included in the OpenShift reports for cost management.
3.1.4. Special OpenShift tags Copy linkLink copied to clipboard!
You can use the following special-case tags to associate cloud cost with OpenShift:
-
openshift_cluster -
openshift_node -
openshift_project
These tags have matching priority over custom tags, and are especially useful to differentiate the costs of different OpenShift clusters running on the same instance.
To use this tagging method to identify an OpenShift cluster, tag your instance with the key openshift_cluster and enter the OpenShift integration name as the value. In the following example, the name of the OpenShift integration in cost management is dev-cluster:
| Source and resource type | Key | Value |
|---|---|---|
| AWS resource (RDS) |
|
|
| OpenShift cluster |
No tags needed. This will match if the name of the OpenShift integration in cost management is | No tags needed. |
3.1.5. Custom tags Copy linkLink copied to clipboard!
You can use any key:value combination as tags, and cost management will associate identical tag key and values together. You can then group costs by tag key, account, service, region, and more to view your costs and charge for that tag.
| Source and resource type | Key | Value |
|---|---|---|
| AWS resource (RDS) |
|
|
| OpenShift pod |
|
|
3.2. Configuring tags on your integrations Copy linkLink copied to clipboard!
To control the tags that cost management imports, activate or enable the tags that you want to view for each integration:
- You must activate AWS tags, and are then selected and exported to cost management in the data export. For instructions, see Activating AWS tags for cost management in the Adding an Amazon Web Services (AWS) source guide.
- Microsoft Azure tags are exported to cost management in the cost export report configured in Configuring a daily Azure data export schedule.
- OpenShift Container Platform labels are exported by the Cost Management Metrics Operator and included in the metrics reports that cost management uses as input.
3.2.1. Adding tags to an AWS resource Copy linkLink copied to clipboard!
Amazon creates certain identifiers automatically, such as the EC2 instance resource identifier, or a number such as i-123456789, which cost management uses similarly.
You can also add your own tags at the individual resource level. These tags must be activated for Cost and Usage Reporting to export them to the cost management application.
Configure AWS tags for cost management using the following steps:
Procedure
Create and apply tags to your AWS resources.
NoteYou must label the VMs for your RHEL systems if you have done both of the following tasks: * You converted from a compatible third-party Linux distribution to Red Hat Enterprise Linux (RHEL). * You purchased the RHEL for third-party migration listing in AWS and activated the cost allocation tags for your RHEL systems on the AWS Cost Allocation tags page.
If you did both of the preceding tasks, create
com_redhat_rhel_conversionand set the tag value totrue. If you are using ELS (Extended Lifecycle Support), createcom_redhat_rhel_addonand set the value toELS. Finally, createcom_redhat_rheland set the tag value to7or8to match your version of RHEL. The changes will be reflected in cost management the next time cost management downloads data.Do not use host metering if you plan on tagging items for RHEL metering. Your instances could be double-billed.
For instructions in the AWS documentation, see User-Defined Cost Allocation Tags.
Activate the tags you want to be collected by the cost management application through the data export. In the AWS Billing console, select the tags that you want to activate from the Cost Allocation Tags area.
For instructions in the AWS documentation, see Activating the AWS-Generated Cost Allocation Tags.
3.2.2. Adding tags to a Microsoft Azure resource Copy linkLink copied to clipboard!
To create identifiers for virtual machine instances automatically, add a Microsoft Azure integration, which cost management uses similarly to tags to associate Microsoft Azure resources to related OpenShift resources. Add your own tags in Microsoft Azure at the individual resource level.
You must label the VMs for your RHEL systems if you have done both of the following tasks: * You converted from a compatible third-party Linux distribution to Red Hat Enterprise Linux (RHEL). * You purchased the RHEL for third party migration listing in Microsoft Azure and labeled the VMs for your RHEL systems.
If you did both of the preceding tasks, create com_redhat_rhel_conversion and set the tag value to true. If you are using ELS (Extended Lifecycle Support), create com_redhat_rhel_addon and set the value to ELS. Finally, create com_redhat_rhel and set the tag value to 7 or 8 to match your version of RHEL. The changes will be reflected in cost management the next time cost management downloads data.
Do not use host metering if you plan on tagging items for RHEL metering. If you plan to tag, this could cause instances to be double-billed.
Create and apply Microsoft Azure tags for cost management using the instructions in the Microsoft Azure documentation: Use tags to organize your Azure resources and management hierarchy.
3.2.3. Adding tags to a Google Cloud resource Copy linkLink copied to clipboard!
You can apply custom labels to Google Cloud resources, such as virtual machine instances, images, and persistent disks. These labels are automatically added to your BigQuery export and sent to cost management.
Procedure
Create and apply labels to your Google Cloud resources.
See Creating and managing labels in the Google Cloud documentation for instructions.
3.2.4. Viewing labels in an OpenShift namespace Copy linkLink copied to clipboard!
The AWS or Microsoft Azure tag equivalent in OpenShift is a label, which also consists of a key:value pair. The cost management service collects OpenShift tag data from nodes, pods, and persistent volumes (or persistent volume claims) using Prometheus metrics and Cost Management Metrics Operator.
Procedure
- To view the available tags, navigate to a resource in the OpenShift web console. Any assigned labels are listed under the Labels heading, for example: openshift.io/cluster-monitoring=true.
3.2.4.1. OpenShift labels and Prometheus character restrictions Copy linkLink copied to clipboard!
Cost Management collects your OpenShift labels through the kube-state-metrics tool, which makes the data available in Prometheus. Cost management retrieves this data from Prometheus. However, Prometheus has restrictive rules for allowed characters in label names. For this reason, the kube-state-metrics tool automatically converts any unsupported characters in the labels to underscores () to ensure compatibility with Prometheus. This conversion process can lead to conflicts, for example problematic.text and problematic/text are both converted to problematic_text. To resolve this conflict, the kube-state-metrics tool automatically adds the suffix _conflict_N_, where _N is a number. In this examples, it converts the labels to problematic_text_conflict1 and problematic_text_conflict2.
If an expected label is missing in cost management, check the original OpenShift label for unsupported characters such as dots or slashes to see how it was renamed when it was collected by the kube-state-metrics tool.
3.2.5. Enabling and Disabling tags in cost management Copy linkLink copied to clipboard!
All cloud provider tags are activated in cost management by default. Sometimes having too many resource tags can affect cost management performance. Enabled tags are limited to 200 per account. Unnecessary tags can also make managing your costs more complicated when grouping tags and matching key:value pairs. Disable tags you are not actively using to reduce these potential issues.
Prerequisites
- You must have Organization Administrator or Cost Price List Administrator privileges to change these settings in cost management. See Limiting access to cost management resources for more information about user roles and access.
Procedure
-
From cost management, click
. - Click the Tags and labels tab.
- Select the tags you want to disable.
Click .
This tag is now deactivated for the cost management application. You can enable tags you have disabled on the same page by selecting the tags you want to enable and clicking Enable tags.
3.2.6. Configuring Amazon Web Services cost categories in cost management Copy linkLink copied to clipboard!
You can enable or disable Amazon Web Services (AWS) cost categories in the cost management service. AWS cost categories allow your organization to group meaningful cost and usage information in addition to tags. In order to use cost categories in cost management, they must first be configured in the AWS Console. The following procedure describes how to enable cost categories in the cost management service.
Prerequisites
- You must have Organization Administrator or Cost Price List Administrator privileges to change these settings in cost management. See Limiting access to cost management resources for more information about user roles and access.
- You have an Amazon Web Services integration added to cost management with cost categories enabled through the Amazon Web Services Console.
Procedure
-
From cost management, click
. - Click the Cost categories tab.
- Select the cost category to enable. You can select more than one.
Click .
The selected cost categories are now enabled for the cost management application. You can also disable cost categories by selecting the cost categories you want to disable and clicking Disable categories.