Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 3. Configuring tags and labels in cost management

download PDF

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:

  1. Tag or label resources on each of your integrations. See Section 3.2, “Configuring tags on your integrations”.
  2. Refine and add to your tags to optimize your view of cost data. See Section 1.2, “Creating a strategy for tags”.
Note

See the Getting started with cost management guide for instructions on configuring integrations.

3.1. How cost management associates tags

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:

Table 3.1. Example: Tag matching
Source and resource typeKeyValue

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

To identify your OpenShift resources running on AWS or Azure instances, cost management matches tags between integrations in the following order:

  1. Direct resource matching (AWS EC2 instance ID or Azure virtual machine instance ID)
  2. Special OpenShift tags
  3. Custom tags

3.1.2. OpenShift label inheritance in cost management

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)

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

There are three special-case AWS tags you can use to associate cost with OpenShift:

  • openshift_cluster
  • openshift_node
  • openshift_project

These tags have matching priority over custom tags, and are especially useful in differentiating the costs of different OpenShift clusters running on the same AWS instance.

To use this tagging method to identify an OpenShift cluster, tag your AWS instance with the key openshift_cluster, and provide the OpenShift integration name as the value. In the following example, the name of OpenShift integration in the cost management application is dev-cluster:

Table 3.2. Example: Special OpenShift tags
Source and resource typeKeyValue

AWS resource (RDS)

openshift_cluster

dev-cluster

OpenShift cluster

No tags needed. This will match if the name of the OpenShift integration in cost management is dev-cluster.

No tags needed.

3.1.5. Custom tags

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.

Table 3.3. Example: Custom tags
Source and resource typeKeyValue

AWS resource (RDS)

team

engineering

OpenShift pod

team

engineering

3.2. Configuring tags on your integrations

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

Amazon creates certain identifiers automatically, like the EC2 instance resource identifier (a number such as i-123456789), which cost management uses similarly to a tag.

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

  1. Create and apply tags to your AWS resources.

    Note

    If you converted from a compatible third-party Linux distribution to Red Hat Enterprise Linux (RHEL) and purchased the RHEL for third-party migration listing in AWS, activate the cost allocation tags for your RHEL systems on the AWS Cost Allocation tags page. 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.

    For instructions in the AWS documentation, see User-Defined Cost Allocation Tags.

  2. 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

Adding an Microsoft Azure integration creates identifiers for virtual machine instances automatically, which cost management uses similarly to tags to associate Azure resources to related OpenShift resources.

You can also add your own tags in Microsoft Azure at the individual resource level.

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

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

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.

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.5. Enabling and Disabling tags in cost management

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 in Getting started with cost management for more information about user roles and access.

Procedure

  1. From cost management, click Cost Management Settings.
  2. Click the Tags and labels tab.
  3. Select the tags you want to disable.
  4. Click Disable tags.

    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

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 in Getting started with cost management 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

  1. From cost management, click Cost Management Settings.
  2. Click the Cost categories tab.
  3. Select the cost category to enable. You can select more than one.
  4. Click Enable categories.

    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.

Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.