k8s-Prometheus-Pushgateway
Pushgateway简介:
- Pushgateway是prometheus的一个组件,prometheus server默认是通过exporter主动获取数据(默认采取pull拉取数据),pushgateway则是通过被动方式推送数据到prometheus server,用户可以写一些自定义的监控脚本把需要监控的数据发送给pushgateway, 然后pushgateway再把数据发送给Prometheus server
Pushgateway优点:
- Prometheus 默认采用定时pull 模式拉取targets数据,但是如果不在一个子网或者防火墙,prometheus就拉取不到targets数据,所以可以采用各个target往pushgateway上push数据,然后prometheus去pushgateway上定时pull数据
- 在监控业务数据的时候,需要将不同数据汇总, 汇总之后的数据可以由pushgateway统一收集,然后由 Prometheus 统一拉取。
pushgateway缺点:
- Prometheus拉取状态只针对 pushgateway, 不能对每个节点都有效;
Pushgateway出现问题,整个采集到的数据都会出现问题
监控下线,prometheus还会拉取到旧的监控数据,需要手动清理 pushgateway不要的数据。
1.安装pushgateway操作:
[root@node01 ~]# docker pull prom/pushgateway
2.编写pushgateway.yaml
[root@master01 pushgateway]# kubectl apply -f pushgateway.yaml deployment.apps/pushgateway created service/pushgateway created
pushgateway.yaml文件如下:
[root@master01 pushgateway]# cat pushgateway.yaml apiVersion: apps/v1 kind: Deployment metadata: name: pushgateway spec: selector: matchLabels: app: pushgateway template: metadata: name: labels: app: pushgateway annotations: prometheus.io/scrape: 'true' spec: tolerations: - key: node-role.kubernetes.io/master #容忍度 effect: NoSchedule containers: - name: pushgateway image: prom/pushgateway:latest imagePullPolicy: IfNotPresent ports: - protocol: TCP name: pushgateway containerPort: 9091 securityContext: privileged: true resources: limits: memory: 200Mi requests: cpu: 100m memory: 200Mi --- apiVersion: v1 kind: Service metadata: name: pushgateway namespace: default spec: ports: - name: nginx-module port: 9091 protocol: TCP targetPort: 9091 nodePort: 30010 selector: app: pushgateway type: NodePort
#prometheus上查看mysql-export状态
使用的话参考这篇文章
https://www.cnblogs.com/xiao987334176/p/9933963.html
继续阅读

我的微信
这是我的微信扫一扫
评论