暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
kubernetes学习之prometheus监控配置-20190102.docx
224
49页
0次
2022-07-02
10墨值下载
#1
、 配置
prometheus
configmap
#vim prometheus-cm.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: kube-ops
data:
prometheus.yml
|
global:
scrape_interval: 15s
scrape_timeout: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
kubectl apply -f prometheus-cm.yaml
#2
、配置
prometheus
deployment
资源
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: prometheus
namespace: kube-ops
labels:
app: prometheus
spec:
template:
metadata:
labels:
app: prometheus
spec:
serviceAccountName: prometheus
containers:
- image: prom/prometheus:v2.4.3
name: prometheus
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention=24h"
- "--web.enable-admin-api" #
控制对
admin HTTP API
的访问,其中包
括删除时间序列等功能
- "--web.enable-lifecycle" #
支持热更新,直接执行
localhost:9090/-/reload
立即生效
ports:
- containerPort: 9090
protocol: TCP
name: http
volumeMounts:
- mountPath: "/prometheus"
subPath: prometheus
name: data
- mountPath: "/etc/prometheus"
name: config-volume
resources:
requests:
cpu: 100m
memory: 512Mi
limits:
cpu: 100m
memory: 512Mi
securityContext:
runAsUser: 0
volumes:
- name: data
persistentVolumeClaim:
claimName: prometheus
- configMap:
name: prometheus-config
name: config-volume
#
我们在启动程序的时候,除了指定了
prometheus.yml
文件之外,还通过参数
storage.tsdb.path
指定了
TSDB
数据的存储路径、
#
通过
storage.tsdb.retention
设置了保留多长时间的数据,还有下面的
web.enable-admin-api
参数可以用来开启对
admin api
的访问权限,
#
参数
web.enable-lifecycle
非常重要,用来开启支持热更新的,有了这个参数之后,
prometheus.yml
配置文件只要更新了,
#
通过执行
localhost:9090/-/reload
就会立即生效,所以一定要加上这个参数。
of 49
10墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜