Aliyun Exporter

repository·master·Indexed 43 days ago

https://github.com/aylei/aliyun-exporter

A Prometheus exporter that collects metrics from the Alibaba Cloud CloudMonitor API. It enables the integration of Alibaba Cloud monitoring with Prometheus, Grafana, and Alertmanager. The exporter supports Python 3.5+ and Docker deployment, featuring a web UI for metric discovery and specialized support for RDS performance metrics via the rds_performance project.

Tokens
2.6K
Snippets
12
Records
16
Agent score
55%

What's inside Aliyun Exporter

  1. Use Special Projects for RDS Performance

    master

    Some metrics are not available via the standard CloudMonitor API. The exporter uses 'Special Projects' to handle these.

    One such project is rds_performance. These projects use different APIs and do not consume your CloudMonitor API invocation quota, but they can be slower. It is recommended to run special projects in a standalone exporter instance to avoid impacting standard metric collection.

  2. Monitor Exporter health and metrics

    master

    The exporter provides self-monitoring metrics:

    • cloudmonitor_request_latency_seconds: Latency of CloudMonitor API calls.
    • cloudmonitor_failed_request_latency_seconds: Latency of failed CloudMonitor API calls.
    • aliyun_{project}_{metric}_up: A boolean metric indicating if a specific Cloud Monitor metric was successfully scraped.
  3. Use the rds_performance special project

    master

    Some metrics are not exposed via the standard Cloud Monitor API. To maintain configuration consistency, use the special project rds_performance to fetch detailed RDS performance data.

    metrics:
      rds_performance:
      - name: <RDS_METRIC_NAME>
  4. Explore Metrics Meta via Web UI

    master

    The exporter hosts a simple web interface to help you discover available CloudMonitor metrics. After launching, visit http://localhost:9525 to browse:

    • host:port/: Lists all available monitor projects.
    • host:port/projects/{project}: Shows metrics meta for a specific project.
    • host:port/yaml/{project}: Provides a configuration YAML for the project's metrics.
  5. Configure the full monitoring stack with Docker Compose

    master

    To deploy the full stack (Exporter, Prometheus, Alertmanager, Grafana, and DingTalk integration), set the following environment variables before running docker-compose up -d:

    • PROMETHEUS_HOST: Your public IP or hostname.
    • DINGTALK_TOKEN: Your DingTalk robot token.
    • ALIYUN_REGION: Your Alibaba Cloud region.
    • ALIYUN_ACCESS_ID: Your Alibaba Cloud Access Key ID.
    • ALIYUN_ACCESS_SECRET: Your Alibaba Cloud Access Key Secret.
    export PROMETHEUS_HOST=YOUR_PUBLIC_IP_OR_HOSTNAME
    export DINGTALK_TOKEN=YOUR_DINGTALK_ROBOT_TOEKN
    export ALIYUN_REGION=YOUR_REGION
    export ALIYUN_ACCESS_ID=YOUR_ID
    export ALIYUN_ACCESS_SECRET=YOUR_SECRET
    docker-compose up -d
  6. Deploy the full monitoring stack with Docker Compose

    master

    To deploy the complete stack (Exporter, Prometheus, Alertmanager, Grafana, and DingTalk webhook), set the following environment variables and run docker-compose up -d from the ./docker-compose directory.

    Required Environment Variables:

    • PROMETHEUS_HOST: Public IP or hostname of Prometheus (used for alert links).
    • DINGTALK_TOKEN: DingTalk robot token for notifications.
    • ALIYUN_REGION: Your Alibaba Cloud region.
    • ALIYUN_ACCESS_ID: Your Alibaba Cloud Access Key ID.
    • ALIYUN_ACCESS_SECRET: Your Alibaba Cloud Access Key Secret.
    export PROMETHEUS_HOST=YOUR_PUBLIC_IP_OR_HOSTNAME
    export DINGTALK_TOKEN=YOUR_DINGTALK_ROBOT_TOEKN
    export ALIYUN_REGION=YOUR_REGION
    export ALIYUN_ACCESS_ID=YOUR_ID
    export ALIYUN_ACCESS_SECRET=YOUR_SECRET
    docker-compose up -d
  7. Quick Start with Docker Compose

    master

    You can launch a complete monitoring stack including Aliyun-Exporter, Prometheus, Grafana, and Alertmanager using the provided docker-compose setup. This requires Docker 1.17+.

    1. Clone the repository.
    2. Navigate to the docker-compose directory.
    3. Run the stack with your Alibaba Cloud credentials as environment variables.

    Once running, you can access Grafana at http://localhost:3000 (default credentials: admin:admin).

    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
  8. Run aliyun-exporter via Docker

    master

    You can run the exporter as a container. An external configuration file must be mounted into the container.

    docker pull aylei/aliyun-exporter:0.3.1
    
    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
  9. Configure aliyun-exporter via YAML

    master

    The exporter is configured using a YAML file. Key configuration sections include:

    • rate_limit: Request rate limit per second (default: 10).
    • credential: Alibaba Cloud credentials (access_key_id, access_key_secret, and region_id which defaults to cn-hangzhou).
    • metrics: A required list of CloudMonitor projects and their specific metrics. For each metric, you can specify name, rename, period (query period in seconds, default 60), and measure (e.g., Average, default Average).
    • info_metrics: A list of projects to include instance information (e.g., ecs, rds, redis).
    rate_limit: 5
    credential:
      access_key_id: <YOUR_ACCESS_KEY_ID>
      access_key_secret: <YOUR_ACCESS_KEY_SECRET>
      region_id: <REGION_ID>
    
    metrics:
      acs_cdn:
      - name: QPS
        rename: qps
        period: 60
        measure: Average
    
    info_metrics:
      - ecs
      - rds
      - redis
  10. Run aliyun-exporter

    master

    After installation, run the exporter by specifying a configuration file.

    • Default port: 9525
    • Default config location: ./aliyun-exporter.yml

    Metrics are exposed at http://localhost:9525/metrics.

    aliyun-exporter -p 9525 -c aliyun-exporter.yml
  11. Configure environment variables for aliyun-exporter via Docker Compose

    master

    When running the aliyun-exporter service using the provided Docker Compose setup, you must provide the following environment variables to authenticate with Alibaba Cloud and configure connectivity:

    • ALIYUN_ACCESS_ID: Your Alibaba Cloud Access Key ID.
    • ALIYUN_ACCESS_SECRET: Your Alibaba Cloud Access Key Secret.
    • ALIYUN_REGION: The Alibaba Cloud region (e.g., cn-hangzhou).
    • PROMETHEUS_HOST: The host address used for the Prometheus external URL (defaults to localhost).
    • DINGTALK_TOKEN: The access token for the DingTalk robot webhook used by the webhook-dingtalk service.
    # Required environment variables
    ALIYUN_ACCESS_ID=YOUR_ACCESS_ID
    ALIYUN_ACCESS_SECRET=YOUR_ACCESS_SECRET
    ALIYUN_REGION=cn-hangzhou
    PROMETHEUS_HOST=localhost
    DINGTALK_TOKEN=YOUR_DINGTALK_ROBOT_TOKEN