zoukankan      html  css  js  c++  java
  • kube-prometheus 监控 redis部署

    1. 使用ansible 建立一个redis 实例

     
    2. 部署redis_exporter 
    docker版部署 

    docker run -d --name redis_exporter -e REDIS_ADDR="redis://192.168.20.157:6379"  -e REDIS_PASSWORD='Senfffc.yl' -p 9121:9121  oliver006/redis_exporter


    二进制部署

    wget https://github.com/oliver006/redis_exporter/releases/download/v1.12.1/redis_exporter-v1.12.1.linux-amd64.tar.gz
    
    tar -zxvf   redis_exporter-v1.12.1.linux-amd64.tar.gz

    ./redis_exporter -redis.addr=192.168.20.157:6379  -redis.password='Senfffc.yl'  -web.listen-address=192.168.20.157:9121

    注意 密码中有点 等特殊字符, 需要使用 '' .

    三 访问:

    5. 在k8s上,新建 endpoint  service   servicemonitor

    cat redis-monitor.yaml 

    apiVersion: v1
    kind: Endpoints
    metadata:
      name: redis-metrics
      namespace: monitoring
      labels:
        k8s-app: redis-metrics
    subsets:
    - addresses:
        - ip: 192.168.20.157
      ports:
      - name: redis-exporter
        port: 9121
        protocol: TCP
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: redis-metrics
      namespace: monitoring
      labels:
        k8s-app: redis-metrics
    spec:
      type: ClusterIP
      clusterIP: None
      ports:
      - name: redis-exporter
        port: 9121
        protocol: TCP
    ---
    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: redis-metrics
      namespace: monitoring
      labels:
        app: redis-metrics
        k8s-app: redis-metrics
        prometheus: kube-prometheus
        release: kube-prometheus
    spec:
      endpoints:
      - port: redis-exporter
        interval: 15s
      selector:
        matchLabels:
          k8s-app: redis-metrics
      namespaceSelector:
        matchNames:
        - monitoring

     6. k8s 执行 yaml文件

    kubectl create -f  redis-monitor.yaml

    7. granfana 配置

    导入 模版:https://grafana.com/grafana/dashboards?search=kubernetes

     

    显示: 

  • 相关阅读:
    QPS、TPS、RT、并发数、吞吐量理解和性能优化深入思考
    从开源协议到谷歌禁用华为、Docker实体清单事件
    如何画好架构图?
    使用委托的异步方法
    里氏替换原则(转)
    HTTP协议详解(转)
    httpApplication事件和asp.net生命周期(整理)
    WebDev.WebServer.exe
    正则表达式的3种匹配模式
    Code First实体与数据表之间的映射关系
  • 原文地址:https://www.cnblogs.com/fengjian2016/p/13864478.html
Copyright © 2011-2022 走看看