我在k8s集群上已经部署了普罗米修斯运营商。现在,我想为我创建的自定义导出器添加一个抓取目标。我创建了prometheus.yaml文件,但是找不到如何将其应用于现有的prometheus运算符。
答案 0 :(得分:0)
我不知道如何创建和修改prometheus.yaml
文件,但是将向您展示管理文件的便捷方法。
首先,我建议您将prometheus配置文件prometheus.yaml
存储为configmap。这非常有用,而且您将自动在CM中进行更改,而无需涉及传播/传播到与该CM一起使用/使用此CM的吊舱。
因此,在CM中使用新的剪贴簿进行更改后-take some time将传播更改。从ConfigMap更新到新键被投射到Pod之间的总延迟时间可以是kubelet中的kubelet同步时间(默认为1分钟)+ ConfigMaps缓存的ttl(默认为1分钟)。 / p>
现在该进行更改了。 Prometheus可以选择在飞行中重新加载其配置。您有两种选择方法。您可以找到打开Reloading Prometheus’ Configuration网址的更多信息。
我只会在这里提出一种解决方案: 您可以将HTTP POST发送到Prometheus Web服务器:
curl -X POST http://localhost:9090/-/reload
请注意,从Prometheus 2.0开始,-web.enable-lifecycle命令 必须传递line标志,HTTP重新加载才能正常工作。 如果重新加载成功,Prometheus将记录其已更新目标:
INFO[0248] Loading configuration file prometheus.yml source=main.go:196
INFO[0248] Stopping target manager... source=targetmanager.go:203
INFO[0248] Target manager stopped. source=targetmanager.go:216
INFO[0248] Starting target manager... source=targetmanager.go:114
还有蛋糕上的樱桃:)
有一个很棒的Prometheus, ConfigMaps and Continuous Deployment,它解释了如何使用prometheus监视Prometheus(也许可以在您的另一个问题中适用)。我想向您展示的主要内容是您可以自动化POST请求。
因此,基本上,您需要一个小的Sidecar容器,该容器将检查CM更改并在发生新更改时发送POST。这辆挎斗车应该和普罗米修斯放在同一个豆荚里
从此处复制文章中的粘贴示例以供将来参考
spec:
containers:
- name: prometheus
...
volumeMounts:
- name: config-volume
mountPath: /etc/prometheus
- name: watch
image: weaveworks/watch:master-5b2a6e5
imagePullPolicy: IfNotPresent
args: ["-v", "-t", "-p=/etc/prometheus", "curl", "-X", "POST", "--fail", "-o", "-", "-sS", "http://localhost:80/-/reload"]
volumeMounts:
- name: config-volume
mountPath: /etc/prometheus
volumes:
- name: config-volume
configMap:
name: prometheus-config