tencent cloud

Tencent Kubernetes Engine

DokumentasiTencent Kubernetes EngineUse CasesMonitoringMonitoring TKE Clusters with Self-Built Prometheus

Monitoring TKE Clusters with Self-Built Prometheus

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-11-11 10:02:55
Diterjemahkan & Diperiksa oleh AI
This document describes how to configure collection rules when a self-built Prometheus is used to collect monitoring data from Tencent Cloud TKE. Nodes in a TKE cluster are classified into regular nodes and super nodes by node type. Prometheus scrapes monitoring data from nodes and containers by configuring scrape_config. Due to the different nature of nodes, the collection rules to be configured vary slightly.

Conventional Node Collection Rules

The collection configuration file for regular nodes is as follows:
- job_name: "tke-cadvisor"
scheme: https
metrics_path: /metrics/cadvisor # Collect container cadvisor monitoring data
tls_config:
insecure_skip_verify: true # The kubelet of tke uses a self-signed certificate, so certificate verification is skipped.
authorization:
credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__meta_kubernetes_node_label_node_kubernetes_io_instance_type]
regex: eklet # Exclude super nodes
action: drop
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- job_name: "tke-kubelet"
scheme: https
metrics_path: /metrics # Collect monitoring data of kubelet itself
tls_config:
insecure_skip_verify: true
authorization:
credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__meta_kubernetes_node_label_node_kubernetes_io_instance_type]
regex: eklet
action: drop
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- job_name: "tke-probes" # Collect container health check data
scheme: https
metrics_path: /metrics/probes
tls_config:
insecure_skip_verify: true
authorization:
credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__meta_kubernetes_node_label_node_kubernetes_io_instance_type]
regex: eklet
action: drop
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
Usage Instructions:
Use node service discovery (with the role of kubernetes_sd_configs set to node) to scrape several types of monitoring data exposed by kubelet:10250 on all nodes.
If a cluster uses both regular nodes and super nodes, exclude the super nodes by filtering out nodes with the label node.kubernetes.io/instance-type: eklet in relabel_configs.
The kubelet certificate on TKE nodes is self-signed, so certificate verification must be skipped. Therefore, set insecure_skip_verify to true.
kubelet exposes container cadvisor monitoring data, kubelet's own monitoring data, and container health check data through the /metrics/cadvisor, /metrics, and /metrics/probes paths respectively. Configure separate scrape jobs for these three paths to collect the data.

Super Node Collection Rules

The collection configuration file for super nodes is as follows:
- job_name: eks # Collect monitoring data of super nodes
honor_timestamps: true
metrics_path: '/metrics' # All health data is under this path
params: # Parameters are usually required to filter out IPVS-related metrics, because the data volume may be large and cause high Pod load.
collect[]:
- 'ipvs'
# - 'cpu'
# - 'meminfo'
# - 'diskstats'
# - 'filesystem'
# - 'load0vg'
# - 'netdev'
# - 'filefd'
# - 'pressure'
# - 'vmstat'
scheme: http
kubernetes_sd_configs:
- role: pod # Monitoring data of super node Pods is exposed on port 9100 of the Pod's own IP, so Pod service discovery is used.
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_tke_cloud_tencent_com_pod_type]
regex: eklet # Collect only Pods on super nodes
action: keep
- source_labels: [__meta_kubernetes_pod_phase]
regex: Running # Resources of Pods not in Running state have been released, so no collection is needed.
action: keep
- source_labels: [__meta_kubernetes_pod_ip]
separator: ;
regex: (.*)
target_label: __address__
replacement: ${1}:9100 # Monitoring metrics are exposed on port 9100 of the Pod.
action: replace
- source_labels: [__meta_kubernetes_pod_name]
separator: ;
regex: (.*)
target_label: pod # Write the Pod name to the "pod" label.
replacement: ${1}
action: replace
- source_labels: [__meta_kubernetes_namespace]
separator: ;
regex: (.*)
target_label: namespace # Write the namespace of the Pod to the "namespace" label.
replacement: ${1}
action: replace
metric_relabel_configs:
- source_labels: [__name__]
separator: ;
regex: (container_.*|pod_.*|kubelet_.*)
replacement: $1
action: keep
Usage Instructions:
Monitoring data of super nodes is exposed on the /metrics HTTP API path (not HTTPS) at port 9100 of each Pod. Use Pod service discovery (with the role of kubernetes_sd_configs set to pod) to collect all the data with a single job.
Pods on super nodes support filtering out unwanted metrics through the collect[] query parameter. This prevents excessive metric data volume from increasing Pod load. You typically need to filter out ipvs metrics.
If a cluster uses both regular nodes and super nodes, ensure that only Pods on super nodes are scraped. In relabel_configs, keep only Pods with the annotation tke.cloud.tencent.com/pod-type:eklet.
If a Pod's phase is not Running, its metrics cannot be scraped, and the Pod can be excluded.
Metrics starting with container_ are cadvisor monitoring data. Metrics with the pod_ prefix are monitoring data of the underlying instance where the super node Pod resides, which is equivalent to replacing the node_ prefix metrics of node_exporter with pod_. Metrics with the kubelet_ prefix are kubelet-compatible metrics within the underlying instance of the super node Pod, primarily for pvc storage monitoring.

kube-prometheus-stack Configuration

You typically use the kube-prometheus-stack helm chart to set up Prometheus. Customize the configuration in values.yaml, and then install it into the cluster. You can configure Prometheus native scrape_config (not CRD) by writing your custom scrape_config to the prometheus.prometheusSpec.additionalScrapeConfigs field. See the following example:
prometheus:
prometheusSpec:
additionalScrapeConfigs:
- job_name: "tke-cadvisor"
scheme: https
metrics_path: /metrics/cadvisor
tls_config:
insecure_skip_verify: true
authorization:
credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__meta_kubernetes_node_label_node_kubernetes_io_instance_type]
regex: eklet
action: drop
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- job_name: "tke-kubelet"
scheme: https
metrics_path: /metrics
tls_config:
insecure_skip_verify: true
authorization:
credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__meta_kubernetes_node_label_node_kubernetes_io_instance_type]
regex: eklet
action: drop
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- job_name: "tke-probes"
scheme: https
metrics_path: /metrics/probes
tls_config:
insecure_skip_verify: true
authorization:
credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__meta_kubernetes_node_label_node_kubernetes_io_instance_type]
regex: eklet
action: drop
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- job_name: eks
honor_timestamps: true
metrics_path: '/metrics'
params:
collect[]: ['ipvs']
# - 'cpu'
# - 'meminfo'
# - 'diskstats'
# - 'filesystem'
# - 'load0vg'
# - 'netdev'
# - 'filefd'
# - 'pressure'
# - 'vmstat'
scheme: http
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_tke_cloud_tencent_com_pod_type]
regex: eklet
action: keep
- source_labels: [__meta_kubernetes_pod_phase]
regex: Running
action: keep
- source_labels: [__meta_kubernetes_pod_ip]
separator: ;
regex: (.*)
target_label: __address__
replacement: ${1}:9100
action: replace
- source_labels: [__meta_kubernetes_pod_name]
separator: ;
regex: (.*)
target_label: pod
replacement: ${1}
action: replace
- source_labels: [__meta_kubernetes_namespace]
separator: ;
regex: (.*)
target_label: namespace
replacement: ${1}
action: replace
metric_relabel_configs:
- source_labels: [__name__]
separator: ;
regex: (container_.*|pod_.*|kubelet_.*)
replacement: $1
action: keep
storageSpec:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 100Gi


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan