The UCloud Exporter chart deploys a Prometheus exporter for UCloud services, enabling monitoring of your UCloud infrastructure.
What It Monitors
This exporter collects metrics from UCloud services including:
- UHost - Virtual machine instances
- UDB - Managed database services
- ULB - Load balancer metrics
- UDisk - Cloud disk storage
- UMem - Managed Redis/Memcache
- Other UCloud products
Installation
Prerequisites
You need UCloud API credentials (PublicKey and PrivateKey).
Basic Installation
helm repo add douban https://douban.github.io/charts
helm install ucloud-exporter douban/ucloud-exporter
Authentication Configuration
Never commit UCloud credentials to version control. Always use Kubernetes secrets or external secret management solutions.
Using Environment Variables
Configure credentials securely:
extraEnvs:
- name: UCLOUD_PUBLIC_KEY
valueFrom:
secretKeyRef:
name: ucloud-credentials
key: public-key
- name: UCLOUD_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: ucloud-credentials
key: private-key
- name: UCLOUD_REGION
value: "cn-bj2"
- name: UCLOUD_PROJECT_ID
value: "your-project-id"
Environment variables for credentials and configuration
Create Credentials Secret
kubectl create secret generic ucloud-credentials \
--from-literal=public-key="YOUR_PUBLIC_KEY" \
--from-literal=private-key="YOUR_PRIVATE_KEY"
Configuration
Additional command-line arguments for the exporter
image.repository
string
default:"ghcr.io/douban/ucloud-exporter"
Container image repository
Port the exporter listens on
Service port to expose metrics
ServiceMonitor Configuration
For automatic Prometheus scraping via the Prometheus Operator:
serviceMonitor:
enabled: true
interval: 60s
labels:
prometheus: kube-prometheus
Enable ServiceMonitor resource creation
Scrape interval (60s recommended for cloud APIs)
Manual Prometheus Configuration
If not using the Prometheus Operator:
scrape_configs:
- job_name: 'ucloud-exporter'
static_configs:
- targets: ['ucloud-exporter:9200']
scrape_interval: 60s
scrape_timeout: 30s
Example Values
replicaCount: 1
image:
repository: ghcr.io/douban/ucloud-exporter
tag: "main"
pullPolicy: IfNotPresent
extraEnvs:
- name: UCLOUD_PUBLIC_KEY
valueFrom:
secretKeyRef:
name: ucloud-credentials
key: public-key
- name: UCLOUD_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: ucloud-credentials
key: private-key
- name: UCLOUD_REGION
value: "cn-bj2"
- name: UCLOUD_PROJECT_ID
value: "org-abc123"
service:
type: ClusterIP
port: 9200
serviceMonitor:
enabled: true
interval: 60s
timeout: 30s
labels:
release: prometheus
resources:
limits:
cpu: 200m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
Metrics Exposed
Metrics are available at the /metrics endpoint:
ucloud_uhost_cpu_usage - UHost CPU usage percentage
ucloud_uhost_memory_usage - UHost memory usage
ucloud_uhost_disk_usage - UHost disk usage
ucloud_udb_connections - Database connections
ucloud_udb_qps - Database queries per second
ucloud_ulb_connections - Load balancer connections
ucloud_udisk_iops - Disk IOPS
Prometheus Rules
Example alerting rules:
prometheusRule:
enabled: true
rules:
- alert: UCloudHighCPU
expr: ucloud_uhost_cpu_usage > 80
for: 5m
labels:
severity: warning
annotations:
summary: High CPU usage on UHost
description: "UHost {{ $labels.instance_id }} CPU usage is {{ $value }}%"
- alert: UCloudDatabaseConnections
expr: ucloud_udb_connections > 1000
for: 5m
labels:
severity: warning
annotations:
summary: High database connections
description: "UDB {{ $labels.db_id }} has {{ $value }} connections"
Use Cases
Infrastructure Monitoring
Monitor your UCloud infrastructure:
# Average CPU usage across all UHosts
avg(ucloud_uhost_cpu_usage)
# Instances with high memory usage
ucloud_uhost_memory_usage > 80
Track database performance:
# Database QPS
sum by (db_id) (ucloud_udb_qps)
# Connection pool usage
ucloud_udb_connections / ucloud_udb_max_connections
Security Best Practices
Follow these security guidelines:
- Use sub-accounts - Create dedicated API credentials with minimal permissions
- Read-only access - Grant only monitoring/describe permissions
- Rotate credentials - Change API keys regularly
- Use Kubernetes secrets - Never hardcode credentials in values files
- Network policies - Restrict network access to the exporter
- Audit logging - Enable API audit logs in UCloud console
Resources