### Run Aliyun Exporter Source: https://context7.com/aylei/aliyun-exporter/llms.txt Start the exporter process with default or custom configuration and port settings. ```bash # Run with default port 9525 and default config file ./aliyun-exporter.yml aliyun-exporter # Run with custom port and config file aliyun-exporter -p 9525 -c /path/to/aliyun-exporter.yml # Access metrics at http://localhost:9525/metrics # Browse available projects at http://localhost:9525/ ``` -------------------------------- ### Run the Exporter Source: https://github.com/aylei/aliyun-exporter/blob/master/README.md Start the exporter process specifying the port and configuration file path. ```bash > aliyun-exporter -p 9525 -c aliyun-exporter.yml ``` -------------------------------- ### Install Aliyun Exporter Source: https://github.com/aylei/aliyun-exporter/blob/master/README.md Install the package via pip. Requires Python 3.5+. ```bash pip3 install aliyun-exporter ``` -------------------------------- ### Launch Monitoring Stack with Docker Compose Source: https://github.com/aylei/aliyun-exporter/blob/master/README.md Use docker-compose to start the exporter along with Prometheus, Grafana, and Alertmanager. ```bash git clone git@github.com:aylei/aliyun-exporter.git cd docker-compose ALIYUN_ACCESS_ID=YOUR_ACCESS_ID ALIYUN_ACCESS_SECRET=YOUR_ACCESS_KEY docker-compose up ``` -------------------------------- ### Docker Compose Setup for Aliyun Exporter Stack Source: https://github.com/aylei/aliyun-exporter/blob/master/README.md Use this command to set up and launch the Aliyun Exporter along with Prometheus, Alertmanager, Grafana, and DingTalk notification integration using Docker Compose. Ensure you configure your public IP, DingTalk token, and Aliyun credentials before running. ```bash # config prometheus external host export PROMETHEUS_HOST=YOUR_PUBLIC_IP_OR_HOSTNAME # config dingtalk robot token export DINGTALK_TOKEN=YOUR_DINGTALK_ROBOT_TOEKN # config aliyun-exporter credential export ALIYUN_REGION=YOUR_REGION export ALIYUN_ACCESS_ID=YOUR_ID export ALIYUN_ACCESS_SECRET=YOUR_SECRET docker-compose up -d ``` -------------------------------- ### ECS CPU Utilization Metric Source: https://context7.com/aylei/aliyun-exporter/llms.txt Example of a gauge metric for ECS CPU utilization, including instance and user IDs. ```text # TYPE aliyun_acs_ecs_dashboard_CPUUtilization gauge aliyun_acs_ecs_dashboard_CPUUtilization{instanceId="i-abc123",userId="12345"} 25.5 ``` -------------------------------- ### Get Metrics Meta for Specific Project Source: https://context7.com/aylei/aliyun-exporter/llms.txt Use curl to retrieve metadata for metrics within a specific CloudMonitor project. ```bash # Get metrics meta for a specific project curl http://localhost:9525/projects/acs_ecs_dashboard ``` -------------------------------- ### Initialize and Use InfoProvider Source: https://context7.com/aylei/aliyun-exporter/llms.txt Configures the Alibaba Cloud client and retrieves resource metrics. Results are cached for one hour by default. ```python from aliyun_exporter.info_provider import InfoProvider from aliyunsdkcore.client import AcsClient # Initialize Alibaba Cloud client client = AcsClient( ak='your_access_key_id', secret='your_access_key_secret', region_id='cn-hangzhou' ) # Create info provider (results cached for 1 hour) provider = InfoProvider(client) # Get resource metrics (returns GaugeMetricFamily) # Supported resources: 'ecs', 'rds', 'redis', 'slb', 'mongodb' ecs_info = provider.get_metrics('ecs') rds_info = provider.get_metrics('rds') redis_info = provider.get_metrics('redis') slb_info = provider.get_metrics('slb') mongodb_info = provider.get_metrics('mongodb') # Metrics are exposed with resource metadata as labels: # aliyun_meta_ecs_info{InstanceId="i-xxx",HostName="server1",VpcAttributes="10.0.0.1"} 1.0 # aliyun_meta_rds_info{DBInstanceId="rm-xxx",DBInstanceDescription="prod-db"} 1.0 ``` -------------------------------- ### Deploy with Docker Source: https://context7.com/aylei/aliyun-exporter/llms.txt Run the exporter as a Docker container, mounting the configuration file and passing credentials via environment variables. ```bash # Pull the Docker image docker pull aylei/aliyun-exporter:0.3.1 # Run with configuration file mounted docker run -p 9525:9525 \ -v $(pwd)/aliyun-exporter.yml:/etc/aliyun-exporter/aliyun-exporter.yml \ -e ALIYUN_ACCESS_ID=your_access_key_id \ -e ALIYUN_ACCESS_SECRET=your_access_key_secret \ -e ALIYUN_REGION=cn-hangzhou \ aylei/aliyun-exporter:0.3.1 \ -c /etc/aliyun-exporter/aliyun-exporter.yml ``` -------------------------------- ### Deploy Full Monitoring Stack Source: https://context7.com/aylei/aliyun-exporter/llms.txt Launch a complete monitoring stack including Prometheus, Grafana, and Alertmanager using Docker Compose. ```bash # Clone the repository git clone git@github.com:aylei/aliyun-exporter.git cd aliyun-exporter/docker-compose # Set required environment variables export PROMETHEUS_HOST=your_public_ip_or_hostname export DINGTALK_TOKEN=your_dingtalk_robot_token export ALIYUN_ACCESS_ID=your_access_key_id export ALIYUN_ACCESS_SECRET=your_access_key_secret export ALIYUN_REGION=cn-hangzhou # Launch the stack docker-compose up -d # Access services: # - Grafana: http://localhost:3000 (admin:admin) # - Prometheus: http://localhost:9090 # - Alertmanager: http://localhost:9093 # - Exporter: http://localhost:9525 ``` -------------------------------- ### Full Configuration Schema Source: https://github.com/aylei/aliyun-exporter/blob/master/README.md Detailed configuration structure including rate limiting, credentials, and metric specifications. ```yaml rate_limit: 5 # request rate limit per second. default: 10 credential: access_key_id: # required access_key_secret: # required region_id: # default: 'cn-hangzhou' metrics: # required, metrics specifications acs_cdn: # required, Project Name of CloudMonitor - name: QPS # required, Metric Name of CloudMonitor, belongs to a certain Project rename: qps # rename the related prometheus metric. default: same as the 'name' period: 60 # query period. default: 60 measure: Average # measure field in the response. default: Average info_metrics: - ecs - rds - redis ``` -------------------------------- ### Discover Available Monitor Projects Source: https://context7.com/aylei/aliyun-exporter/llms.txt Use curl to query the exporter's web UI for a list of all available monitor projects. ```bash # Browse all available monitor projects curl http://localhost:9525/ ``` -------------------------------- ### Configure Credentials via Environment Variables Source: https://context7.com/aylei/aliyun-exporter/llms.txt Set credentials using environment variables to override settings in the configuration file. ```bash # Set credentials via environment variables export ALIYUN_ACCESS_ID=your_access_key_id export ALIYUN_ACCESS_SECRET=your_access_key_secret export ALIYUN_REGION=cn-hangzhou # Run the exporter (credentials from env vars) aliyun-exporter -c aliyun-exporter.yml ``` -------------------------------- ### Python CollectorConfig Initialization Source: https://context7.com/aylei/aliyun-exporter/llms.txt Python code demonstrating how to initialize the CollectorConfig class, load credentials and metrics from a YAML file, and register the AliyunCollector with Prometheus. ```python from aliyun_exporter.collector import CollectorConfig, AliyunCollector from prometheus_client.core import REGISTRY import yaml # Load configuration from YAML file with open('aliyun-exporter.yml', 'r') as f: cfg = yaml.load(f, Loader=yaml.FullLoader) # Create collector config (credentials can come from env vars) # Environment variables: ALIYUN_ACCESS_ID, ALIYUN_ACCESS_SECRET, ALIYUN_REGION config = CollectorConfig( credential=cfg.get('credential'), metrics=cfg.get('metrics'), info_metrics=cfg.get('info_metrics'), rate_limit=cfg.get('rate_limit', 10) ) # Register collector with Prometheus collector = AliyunCollector(config) REGISTRY.register(collector) ``` -------------------------------- ### Pull and Run Docker Image Source: https://github.com/aylei/aliyun-exporter/blob/master/README.md Commands to pull the official Docker image and run it with a local configuration file mounted. ```bash docker pull aylei/aliyun-exporter:0.3.1 ``` ```bash docker run -p 9525:9525 -v $(pwd)/aliyun-exporter.yml:$(pwd)/aliyun-exporter.yml aylei/aliyun-exporter:0.3.1 -c $(pwd)/aliyun-exporter.yml ``` -------------------------------- ### Configure Aliyun Exporter Source: https://context7.com/aylei/aliyun-exporter/llms.txt Define credentials, rate limits, and specific CloudMonitor metrics to collect in a YAML configuration file. ```yaml # aliyun-exporter.yml credential: access_key_id: access_key_secret: region_id: cn-hangzhou rate_limit: 5 # Request rate limit per second, default: 10 metrics: acs_ecs_dashboard: # Project name from CloudMonitor - name: CPUUtilization period: 60 # Query period in seconds, default: 60 measure: Average # Measure field: Average, Maximum, Minimum - name: DiskReadBPS period: 60 - name: memory_usedutilization rename: mem_usage # Rename metric in Prometheus output period: 15 acs_rds_dashboard: - name: CpuUsage period: 60 - name: MemoryUsage period: 60 - name: DiskUsage period: 60 - name: ConnectionUsage period: 60 acs_kvstore: # Redis - name: CpuUsage period: 60 - name: MemoryUsage period: 60 acs_slb_dashboard: - name: Qps period: 60 - name: StatusCode5xx period: 60 - name: Rt period: 60 acs_mongodb: - name: CPUUtilization period: 300 - name: QPS period: 300 acs_cdn: - name: QPS # Resource information metrics (exposes instance metadata as labels) info_metrics: - ecs - rds - redis - slb - mongodb ``` -------------------------------- ### Generate YAML Configuration Template Source: https://context7.com/aylei/aliyun-exporter/llms.txt Use curl to generate a YAML configuration template for all metrics within a specified project. ```bash # Generate YAML configuration template for a project curl http://localhost:9525/yaml/acs_ecs_dashboard # Output: Ready-to-use YAML config for all metrics in the project ``` -------------------------------- ### Configure Aliyun Exporter Metrics Source: https://github.com/aylei/aliyun-exporter/blob/master/aliyun_exporter/templates/yaml.html Defines the structure for Aliyun Exporter metrics configuration. Use this template to specify metrics for a given project and iterate through a list of metrics, setting their names and periods. ```yaml metrics: {{ project }}: {%- for metric in metrics %} - name: {{ metric\[\'Metric\' ] | formatmetric }} period: {{ metric\[\'Periods' ] | formatperiod}} {%- endfor -%} ``` -------------------------------- ### Configure Exporter Credentials and Metrics Source: https://github.com/aylei/aliyun-exporter/blob/master/README.md Define the Alibaba Cloud credentials and the specific metrics to collect in a YAML configuration file. ```yaml credential: access_key_id: access_key_secret: region_id: metrics: acs_cdn: - name: QPS acs_mongodb: - name: CPUUtilization period: 300 ``` -------------------------------- ### Configure Prometheus Scrape Source: https://context7.com/aylei/aliyun-exporter/llms.txt Add the Aliyun Exporter as a target in the Prometheus configuration file. ```yaml # prometheus.yml global: scrape_interval: 30s evaluation_interval: 30s scrape_configs: - job_name: 'aliyun-exporter' scrape_interval: 30s scrape_timeout: 30s static_configs: - targets: ['aliyun-exporter:9525'] ``` -------------------------------- ### Fetch Metrics Source: https://context7.com/aylei/aliyun-exporter/llms.txt Verify metric output by querying the exporter's metrics endpoint. ```bash # Fetch metrics curl http://localhost:9525/metrics # Example output: # HELP aliyun_acs_ecs_dashboard_CPUUtilization ``` -------------------------------- ### RDS Performance Metrics Configuration Source: https://context7.com/aylei/aliyun-exporter/llms.txt YAML configuration for the 'rds_performance' special project, enabling collection of detailed RDS MySQL metrics. ```yaml # special_projects.yml credential: access_key_id: access_key_secret: region_id: cn-hangzhou metrics: rds_performance: - name: MySQL_QPSTPS - name: MySQL_NetworkTraffic - name: MySQL_Sessions - name: MySQL_InnoDBBufferRatio - name: MySQL_InnoDBDataReadWriten - name: MySQL_InnoDBLogRequests - name: MySQL_InnoDBLogWrites - name: MySQL_TempDiskTableCreates - name: MySQL_MyISAMKeyBufferRatio - name: MySQL_COMDML - name: MySQL_RowDML - name: MySQL_MemCpuUsage - name: MySQL_IOPS - name: MySQL_DetailedSpaceUsage - name: MySQL_CPS # Required: info_metrics must include rds for rds_performance to work info_metrics: - rds ``` -------------------------------- ### ECS Info Metric Source: https://context7.com/aylei/aliyun-exporter/llms.txt A gauge metric providing metadata for ECS instances, with instance ID, hostname, and VPC attributes. ```text # Resource info metrics (always value 1.0, metadata in labels) # HELP aliyun_meta_ecs_info # TYPE aliyun_meta_ecs_info gauge aliyun_meta_ecs_info{InstanceId="i-abc123",HostName="my-server",VpcAttributes="10.0.0.5"} 1.0 ``` -------------------------------- ### CloudMonitor Request Latency Metric Source: https://context7.com/aylei/aliyun-exporter/llms.txt A summary metric measuring the latency of CloudMonitor requests, categorized by project. ```text # Exporter telemetry # HELP cloudmonitor_request_latency_seconds CloudMonitor request latency # TYPE cloudmonitor_request_latency_seconds summary cloudmonitor_request_latency_seconds{project="acs_ecs_dashboard",quantile="0.5"} 0.125 ``` -------------------------------- ### Prometheus Alert: Critical RDS CPU Pressure Source: https://context7.com/aylei/aliyun-exporter/llms.txt Prometheus alerting rule to detect critical CPU pressure on RDS instances. It aggregates CPU usage and joins with RDS instance metadata. ```yaml - name: rds rules: - alert: rds_cpu_pressure:critical expr: |- sum(aliyun_acs_rds_dashboard_CpuUsage * on (instanceId) group_left(DBInstanceDescription,ZoneId) label_replace(aliyun_meta_rds_info, "instanceId", "$1", "DBInstanceId", "(.*)")) without (instance, userId, job) > 95 labels: severity: 0 for: 5m annotations: summary: 'RDS {{ $labels.DBInstanceDescription }} under critical cpu pressure > 95%' ``` -------------------------------- ### Prometheus Alert: Critical SLB 5xx Percent Source: https://context7.com/aylei/aliyun-exporter/llms.txt Prometheus alerting rule to detect a critical percentage of 5xx errors for SLB instances. It calculates the ratio of 5xx responses to total QPS. ```yaml - name: slb rules: - alert: slb_5xx_percent:critical expr: | sum(aliyun_acs_slb_dashboard_StatusCode5xx) by (vip, port) / sum(aliyun_acs_slb_dashboard_Qps) by (vip, port) > 0.1 labels: severity: 0 for: 5m annotations: summary: 'SLB {{ $labels.vip }}:{{ $labels.port }} 5xx percent > 10%' ``` -------------------------------- ### Prometheus Alert: High ECS CPU Pressure Source: https://context7.com/aylei/aliyun-exporter/llms.txt Prometheus alerting rule to detect high CPU pressure on ECS instances. It correlates CPU utilization with instance metadata. ```yaml # rules.yml groups: - name: ecs rules: - alert: ecs_cpu_pressure:high expr: |- (aliyun_acs_ecs_dashboard_CPUUtilization > 95) * on (instanceId) group_left(VpcAttributes,HostName,InnerIpAddress) label_replace(aliyun_meta_ecs_info,"instanceId","$1","InstanceId","(.*)") labels: severity: 1 for: 5m annotations: summary: 'ECS {{ $labels.HostName }} cpu usage > 95%' ``` -------------------------------- ### ECS CPU Utilization Up Metric Source: https://context7.com/aylei/aliyun-exporter/llms.txt A gauge metric indicating the success of fetching the ECS CPU utilization metric. ```text # HELP aliyun_acs_ecs_dashboard_CPUUtilization_up Did the aliyun_acs_ecs_dashboard_CPUUtilization fetch succeed. # TYPE aliyun_acs_ecs_dashboard_CPUUtilization_up gauge aliyun_acs_ecs_dashboard_CPUUtilization_up 1 ``` -------------------------------- ### Prometheus Alert: High ECS Memory Pressure Source: https://context7.com/aylei/aliyun-exporter/llms.txt Prometheus alerting rule to detect high memory pressure on ECS instances. It correlates memory utilization with instance metadata. ```yaml - alert: ecs_memory_pressure:high expr: |- (aliyun_acs_ecs_dashboard_memory_usedutilization > 95) * on (instanceId) group_left(VpcAttributes,HostName,InnerIpAddress) label_replace(aliyun_meta_ecs_info,"instanceId","$1","InstanceId","(.*)") labels: severity: 1 for: 5m annotations: summary: 'ECS {{ $labels.HostName }} memory usage > 95%' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.