【prometheus-operator】k8s监控redis

1、准备exporter

https://github.com/oliver006/redis_exporter

oliver006-redis_exporter-amd64.tar

# 安装镜像

docker load -i oliver006-redis_exporter-amd64.tar

# 上传镜像
docker tag  oliver006/redis_exporter ip/monitor/redis_exporter:latest
docker push ip/monitor/redis_exporter:latest

2、部署exporter

kind: Deployment
apiVersion: apps/v1
metadata:
  name: redis-exporter
  namespace: devops
  labels:
    app: redis-exporter
  annotations:
    deployment.kubernetes.io/revision: '1'
    kubesphere.io/creator: admin
    kubesphere.io/description: 监控使用
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis-exporter
  template:
    metadata:
      labels:
        app: redis-exporter
      annotations:
        kubesphere.io/containerSecrets: '{"container-zsbagq":"harbor"}'
    spec:
      containers:
        - name: container-zsbagq
          image: 'ip:8888/monitor/redis_exporter:latest'
          args:
            - '-redis.addr'
            - 'redis-hip-redis-cluster-headless.hip-mid:6379'
            - '-redis.password'
            - '111111'
          ports:
            - name: tcp-9121
              containerPort: 9121
              protocol: TCP
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      imagePullSecrets:
        - name: harbor

3、创建serviceMonitor

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app: redis-exporter
  name: redis-exporter
  namespace: devops
spec:
  endpoints:
  - interval: 30s
    port: tcp-9121
    params:
        target:
          - redis-hip-redis-cluster-headless.hip-mid:6379
    relabelings:
      - sourceLabels: [__param_target]
        targetLabel: instance
  selector:
    matchLabels:
      app: redis-exporter
  namespaceSelector:
    matchNames:
    - devops

创建成功,访问prometheus targets界面,显示如图

4、grafana模板

id:17507

以上内容对您有帮助,请点赞支持,谢谢!

相关推荐

  1. k8s的部署管理以及prometheus相关监控

    2024-03-21 11:00:04       64 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-21 11:00:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-21 11:00:04       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-21 11:00:04       82 阅读
  4. Python语言-面向对象

    2024-03-21 11:00:04       91 阅读

热门阅读

  1. Reactive: Vue3数据更新但是表单没有更新

    2024-03-21 11:00:04       41 阅读
  2. 在Spring Boot中如何处理跨域请求(CORS)?

    2024-03-21 11:00:04       45 阅读
  3. Elasticsearch8搭建及Springboot中集成使用

    2024-03-21 11:00:04       40 阅读
  4. ffmpeg不常用命令整理

    2024-03-21 11:00:04       48 阅读
  5. docker基础(三)之docker rm和docker rmi

    2024-03-21 11:00:04       45 阅读
  6. 蓝队面试场景题,面试经验小记

    2024-03-21 11:00:04       39 阅读
  7. ubuntu18.04安装ffmpeg

    2024-03-21 11:00:04       36 阅读
  8. Onedrive技巧与问题

    2024-03-21 11:00:04       42 阅读
  9. vty实验

    vty实验

    2024-03-21 11:00:04      35 阅读