我已经在我的k8s集群上部署了prometheus操作符。现在,我想为我创建的自定义导出程序添加一个刮擦目标。我创建了我的prometheus.yaml文件,但是找不到如何将它应用到现有的prometheus操作符中。
发布于 2020-08-21 13:49:40
我不知道如何在何处创建/修改prometheus.yaml文件,但将向您展示管理它的方便方法。
首先,我建议您将prometheus配置文件prometheus.yaml存储为configmap。这是超级有用的,再加上你将在CM中所做的改变将是自动的,而不需要你去传播/传播到使用/消耗这个CM的荚中。
因此,在您使用CM中的新擦伤进行更改后,它将花点时间来传播更改。在kubelet中,从更新ConfigMap的那一刻到新键投射到荚的那一刻,总延迟可以长达kubelet同步周期(默认情况下为1分钟)+ ConfigMaps缓存的ttl (默认情况下为1分钟)。
现在是做改变的时候了。普罗米修斯可以选择在飞行中重新装载它的配置。你有两个选择怎么做。更多信息,你可以找到打开重新加载普罗米修斯的配置网址。
我将在这里只讨论一个解决方案:您可以向Prometheus web服务器发送一个HTTP:
curl -X POST http://localhost:9090/-/reload注意,从Prometheus2.0开始,必须传递--web.Enable-生命周期命令行标志才能使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和持续部署可以解释如何使用Prometheus来监视prometheus(也许它会在某种程度上适用于您的另一个问题)。我想向您展示的主要内容是,您可以自动处理POST请求。
因此,基本上您需要一个小的侧加容器,它将检查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发布于 2022-08-30 21:04:15
但是你必须使用additionalScrapeConfigsSecret
additionalScrapeConfigsSecret:
enabled: true
name: additional-scrape-configs
key: prometheus-additional.yaml否则您将得到错误cannot unmarshal !!map into []yaml.MapSlice。
根据这一点,您可以在没有包装的情况下将刮擦的秘密添加到下面这样的秘密中:
additionalScrapeConfigs: |
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]https://stackoverflow.com/questions/63496950
复制相似问题