tencent cloud

Tencent Cloud Observability Platform

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Strengths
Basic Features
Basic Concepts
Use Cases
Use Limits
Purchase Guide
Tencent Cloud Product Monitoring
Application Performance Management
Mobile App Performance Monitoring
Real User Monitoring
Cloud Automated Testing
Prometheus Monitoring
Grafana
EventBridge
PTS
Quick Start
Monitoring Overview
Instance Group
Tencent Cloud Product Monitoring
Application Performance Management
Real User Monitoring
Cloud Automated Testing
Performance Testing Service
Prometheus Getting Started
Grafana
Dashboard Creation
EventBridge
Alarm Service
Cloud Product Monitoring
Tencent Cloud Service Metrics
Operation Guide
CVM Agents
Cloud Product Monitoring Integration with Grafana
Troubleshooting
Practical Tutorial
Application Performance Management
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Parameter Information
FAQs
Mobile App Performance Monitoring
Overview
Operation Guide
Access Guide
Practical Tutorial
Tencent Cloud Real User Monitoring
Product Introduction
Operation Guide
Connection Guide
FAQs
Cloud Automated Testing
Product Introduction
Operation Guide
FAQs
Performance Testing Service
Overview
Operation Guide
Practice Tutorial
JavaScript API List
FAQs
Prometheus Monitoring
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Terraform
FAQs
Grafana
Product Introduction
Operation Guide
Guide on Grafana Common Features
FAQs
Dashboard
Overview
Operation Guide
Alarm Management
Console Operation Guide
Troubleshooting
FAQs
EventBridge
Product Introduction
Operation Guide
Practical Tutorial
FAQs
Report Management
FAQs
General
Alarm Service
Concepts
Monitoring Charts
CVM Agents
Dynamic Alarm Threshold
CM Connection to Grafana
Documentation Guide
Related Agreements
Application Performance Management Service Level Agreement
APM Privacy Policy
APM Data Processing And Security Agreement
RUM Service Level Agreement
Mobile Performance Monitoring Service Level Agreement
Cloud Automated Testing Service Level Agreement
Prometheus Service Level Agreement
TCMG Service Level Agreements
PTS Service Level Agreement
PTS Use Limits
Cloud Monitor Service Level Agreement
API Documentation
History
Introduction
API Category
Making API Requests
Monitoring Data Query APIs
Alarm APIs
Legacy Alert APIs
Notification Template APIs
TMP APIs
Grafana Service APIs
Event Center APIs
TencentCloud Managed Service for Prometheus APIs
Monitoring APIs
Data Types
Error Codes
Glossary

Customize Application Instance Attributes

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2025-03-12 11:43:26
When an application is integrated with APM, for each application instance, users can customize a series of instance attributes to achieve query filtering and data aggregation based on instance attributes. In the observable data generated by the application instance, the corresponding instance attribute information will be attached. For example, in the application details feature provided by APM, users can filter target instances based on instance attributes and analyze the performance under specific K8s clusters, K8s workloads, and application image versions. In container monitoring, CVM monitoring and other features provided by APM, it is necessary to associate other cloud products through instance attributes to achieve integrated observability.

APM-Supported Instance Attributes

Attribute Name
Key
Required
Scenarios Where Automatic Injection Is Possible
Instance name
host.name
Yes
Connect via Tencent Cloud Enhanced Java Agent
Connect via Skywalking Solution
TKE environment can be integrated with one click via tencent-opentelemetry-operator
CVM region
cvm.region
No
Connecting via Tencent Cloud OpenTelemetry Java Agent Enhanced Edition
CVM instance ID
cvm.instance.id
No
Connecting via Tencent Cloud OpenTelemetry Java Agent Enhanced Edition
TKE region
k8s.region
No
One-click integration of TKE environment via Tencent OpenTelemetry Operator
TKE cluster ID
k8s.cluster.id
No
One-click integration of TKE environment via Tencent OpenTelemetry Operator
K8s node IP
k8s.node.ip
No
One - click connection of TKE environment through Tencent OpenTelemetry Operator.
K8s namespace.
k8s.namespace.name
No
One-click integration of TKE environment via Tencent OpenTelemetry Operator
Name of K8s Deployment.
k8s.deployment.name
No
One-click integration of TKE environment via Tencent OpenTelemetry Operator
Name of K8s Pod.
k8s.pod.name
No
One-click integration of TKE environment via Tencent OpenTelemetry Operator
K8s Pod IP
k8s.pod.ip
No
One-click integration of TKE environment via Tencent OpenTelemetry Operator
Application version.
service.version
No
One-click integration of TKE environment via Tencent OpenTelemetry Operator
Custom field 1
custom_key_1
No
-
Custom field 2
custom_key_2
No
-
Custom Field 3
custom_key_3
No
-

Manually Set Instance Attributes

Note:
Only applications connected through the OpenTelemetry scheme are supported.
In scenarios where instance attributes can be automatically injected, do not override them by manual settings.
When connecting an application, instance attributes need to be filled in the Resource Attributes along with token and service.name. In the OpenTelemetry standard, Resource Attributes reflect the basic information of an application instance in the form of key-value pairs. Users can set instance attributes through environment variables or in the access code. The specific setting method is consistent with the way token and service.name are set when connecting the application.

Method 1: Set Instance Attributes Through Environment Variables

Add instance attributes to the environment variable OTEL_RESOURCE_ATTRIBUTES. Eventually, OTEL_RESOURCE_ATTRIBUTES will be displayed in a format similar to key1=value1,key2=value2,key3=value3.
Refer to the following code to set two instance attributes: k8s.region and k8s.cluster.id.
export OTEL_RESOURCE_ATTRIBUTES="service.name=myService,token=myToken"
export OTEL_RESOURCE_ATTRIBUTES="$OTEL_RESOURCE_ATTRIBUTES,k8s.region=ap-guangzhou,k8s.cluster.id=cls-7i2n4axx"
For applications deployed in Kubernetes (without one-click integration via tencent-opentelemetry-operator), instance attributes can also be set in the workload YAML file through OTEL_RESOURCE_ATTRIBUTES environment variable, refer to the following code snippet:
spec:
containers:
- env:
- name: OTEL_RESOURCE_ATTRIBUTES
value: "service.name=myService,token=myToken,k8s.region=ap-guangzhou,k8s.cluster.id=cls-7i2n4axx"
For applications in TKE environment integrated with one click via tencent-opentelemetry-operator, instance attributes that have not been automatically injected can be set in the workload YAML file, refer to the following code snippet:
spec:
containers:
- env:
- name: OTEL_RESOURCE_ATTRIBUTES
value: "custom_key_1=value1,custom_key_2=value_2,cvm.region=ap-guangzhou,cvm.instance.id=ins-3flvdptq"
Note:
For applications in the TKE environment that are connected with one click through tencent-opentelemetry-operator, besides the instance attributes that can be automatically injected, token and service.name have also been automatically injected. Do not overwrite them in the Yaml file through the OTEL_RESOURCE_ATTRIBUTES environment variable.

Method 2: Set Instance Attributes In the Access Code

If integrating an application through code, you can directly set instance attributes in the integration code. For example, in a Go application:
import (
"context"
"errors"
"os"
"go.opentelemetry.io/otel/sdk/resource"
)
r, err := resource.New(ctx, []resource.Option{
resource.WithAttributes(
attribute.KeyValue{Key: "token", Value: attribute.StringValue("my-token")},
attribute.KeyValue{Key: "service.name", Value: attribute.StringValue("my-service")},
attribute.KeyValue{Key: "host.name", Value: attribute.StringValue("10.10.0.1")},
attribute.KeyValue{Key: "k8s.region", Value: attribute.StringValue("ap-guangzhou")},
attribute.KeyValue{Key: "k8s.cluster.id", Value: attribute.StringValue("cls-7i2n4ace")},
),
}...)

How To Dynamically Obtain Pod Names

Since information such as Pod name, Pod IP, and node IP can only be determined after the Pod is created, during the deployment of workloads, you can dynamically obtain this information through Kubernetes Downward API and write it into environment variables for future reference, making it convenient to manually set instance attributes.
spec:
containers:
- env:
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: NODE_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
After saving to environment variables, they can be directly referenced, for example:
spec:
containers:
- env:
- name: OTEL_RESOURCE_ATTRIBUTES
value: "service.name=myService,token=myToken,k8s.pod.ip=$(POD_IP),k8s.pod.name=$(POD_NAME)"
Note:
For applications in the TKE environment that are connected with one click through tencent-opentelemetry-operator, instance attributes such as Pod name, Pod IP and node IP have all been automatically injected. Do not overwrite them in the Yaml file through the OTEL_RESOURCE_ATTRIBUTES environment variable.





Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan