# prometheus-server配置如下
[root@k8s-master-1 prometheus-server]# cat prometheus-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: kube-prometheus
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 1m
scrape_configs:
- job_name: 'kubernetes-node'
kubernetes_sd_configs:
- role: node
- job_name: 'prometheus-server'
static_configs:
- targets: ['localhost:9090']
relabel_configs:
- source_labels: [instance]
regex: '(.*)'
replacement: 'prometheus-server:9090'
target_label: instance
action: replace
【Kubernetes|k8s之Prometheus-node-down解决】
文章图片
文章图片
- 通过上述可以发现,当我们在node_exporter部署好了以后,默认会去http://IP:10250/metrics拉取数据,但是我们一般都是设置node_exporter与宿主机共享网络,所以应该是要去http://IP:9100/metrics拉取数据,故而要重新relabels一下标签
# prometheus配置
[root@k8s-master-1 prometheus-server]# cat prometheus-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: kube-prometheus
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 1m
scrape_configs:
- job_name: 'kubernetes-node'
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__address__]# 将__address__=192.168.0.10:10250 -> 192.168.0.10:9100,node_exporter默认是9100,且我已事先与宿主机共享网络空间了
regex: '(.*):10250'
replacement: '${1}:9100'
target_label: __address__
action: replace
- action: labelmap
regex: __meta__kubernetes_node_label_(.*)# 保留__meta__kubernetes_node_label_标签后面的值作为新标签
- job_name: 'prometheus-server'
static_configs:
- targets: ['localhost:9090']
relabel_configs:
- source_labels: [instance]# 将instance=localhost:9090 -> instance=prometheus-server:9090
regex: '(.*)'
replacement: 'prometheus-server:9090'
target_label: instance
action: replace
文章图片
文章图片
文章图片
可以发现将__address__修改成IP:9100后,即可正常获取metrics
推荐阅读
- 环境配置|ssh本机连接服务器失败
- 网络|服务器网络不通简单排查
- Google App EngineGoogle Kubernetes EngineGoogle Compute Engine的区别
- python|执行python语言的三种方式(解释器,交互式,集成开发环境等)详解 简单易懂~
- 个人网站|树莓派建立个人网站(一)(Nginx+uWSGI+Flask实现最简服务器的搭建)
- Linux|树莓派部署Web服务器(Pi+flask+uWSGI+Nginx)
- nginx|Nginx学习笔记(五)(浅析Nginx原理)
- 科研学术工具|quic-ns-3 安装配置过程【存档】
- 面试|Alibaba十年开发架构师,心血浇筑“MQ技术手册”