美文网首页
Prometheus 监控阿里云 RDS MySQL 版

Prometheus 监控阿里云 RDS MySQL 版

作者: awker | 来源:发表于2020-10-26 19:50 被阅读0次
    1. 创建一个阿里云 只读访问云数据库服务(RDS)权限的用户,并获取用户 Access Key ID 和 Access Key Secret 。


    2. 获取阿里云 RDS MySQL 版监控数据,使用的是这个 exporter(目前作者不维护了,如果功能不能满足要求,也可以自行修改代码。): https://github.com/aylei/aliyun-exporter
      修改 aliyun-exporter 的配置文件

    # mkdir -p /data/aliyun-exporter/
    # cd /data/aliyun-exporter/
    // 编辑 aliyun-exporter 的配置文件,更改 access_key_id、access_key_secret、region_id 的值
    # vim rds.yml
    credential:
      access_key_id: 更改为你的 Access Key ID
      access_key_secret: 更改为你的 Access Key Secret
      region_id: 更改为你的 region_id
    
    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_MyISAMKeyReadWrites
      - name: MySQL_COMDML
      - name: MySQL_RowDML
      - name: MySQL_MemCpuUsage
      - name: MySQL_IOPS
      - name: MySQL_DetailedSpaceUsage
      - name: MySQL_CPS
    

    通过 docker 方式启动 aliyun-exporter ,端口为 9525

    # docker run -d -p 9525:9525 -v /data/aliyun-exporter/rds.yml:/usr/src/app/aliyun-exporter.yml aylei/aliyun-exporter:0.3.1 -c /usr/src/app/aliyun-exporter.yml
    

    通过 curl 请求 localhost:9525/metrics 可以看到监控数据

    # curl -s localhost:9525/metrics | grep QPSTPS | head -n 3
    # HELP aliyun_rds_performance_MySQL_QPSTPS_QPS 
    # TYPE aliyun_rds_performance_MySQL_QPSTPS_QPS gauge
    aliyun_rds_performance_MySQL_QPSTPS_QPS{instanceId="rm-wz9h42ku9o21xt1m2"} 14.75
    

    3、修改 prometheus 配置,追加 rds 的 job_name

    # vim prometheus.yml
      - job_name: 'rds'
        static_configs:
        - targets: ['10.1.9.41:9525']
    

    可以在 prometheus 界面看到数据


    4、grafana 配置



    附录 阿里云 RDS 状态监控 dashboard 下载地址:https://github.com/ackfin/wiki/blob/main/%E9%98%BF%E9%87%8C%E4%BA%91%20RDS%20%E7%8A%B6%E6%80%81%E7%9B%91%E6%8E%A7-1603711533817.json

    参考:

    1. RDS的性能参数表:https://www.alibabacloud.com/help/zh/doc-detail/26316.htm

    相关文章

      网友评论

          本文标题:Prometheus 监控阿里云 RDS MySQL 版

          本文链接:https://www.haomeiwen.com/subject/bzlzmktx.html