Prometheus 运算符 AlertmanagerConfig 未知字段 "webhook_configs"
Prometheus operator AlertmanagerConfig unknown field "webhook_configs"
应用这些清单后https://github.com/prometheus-operator/kube-prometheus/blob/main/kustomization.yaml我想创建AlertManager
webhook:
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: custom
spec:
route:
receiver: custom
groupBy: ['job']
groupWait: 30s
groupInterval: 5m
repeatInterval: 12h
receivers:
- name: custom
webhook_configs:
- send_resolved: true
url: https://example.com
出现错误:
error: error validating "alertmanagerconfig.yaml": error validating data: ValidationError(AlertmanagerConfig.spec.receivers[0]): unknown field "webhook_configs" in com.coreos.monitoring.v1alpha1.AlertmanagerConfig.spec.receivers; if you choose to ignore these errors, turn validation off with --validate=false
如何解决?
以此link为参考,
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: custom
spec:
receivers:
- name: custom
webhookConfigs:
- send_resolved: true
url: https://example.com
您还可以使用 kubectl explain
命令检查字段
kubectl explain alertmanagerconfig.spec.receivers
问题是您使用的是实际 AlertManager 应用程序的配置参考,而不是 Prometheus Operator 提供的 Kubernetes 自定义资源的配置参考。
Prometheus Operator 采用以 AlertManagerConfig 等自定义资源形式提供的配置,并将它们转换为实际的 AlertManager 配置,并更新应用程序使用的配置文件。这就是您首先使用运算符的部分原因。它使这些事情对您来说很方便。
所以您在这里应该使用的实际配置参考是 this。
Prometheus Operator github 自述文件的 part 列出了您可以使用它的可用自定义资源。
除了 Kiran 的回答(谢谢!),还有一个小的更正 - 它实际上是 sendResolved
而不是 send_resolved
。
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: custom
spec:
receivers:
- name: custom
webhookConfigs:
- sendResolved: true
url: https://example.com
我通过使用这个 yaml 生成名为 alertmanager-main
的 Kubernetes secret
解决了这个问题:
global:
#skipped
route:
group_by: ['job']
receiver: Default
routes:
- receiver: Watchdog
repeat_interval: 1m
match:
alertname: Watchdog
receivers:
- name: Watchdog
webhook_configs:
- url: https://my.watchdog.webhook.url
# Other things
这是警报管理器配置。
我会在一段时间后回答我的问题,Prometheus Operator CRD 的这个问题现在可能已经解决了。
应用这些清单后https://github.com/prometheus-operator/kube-prometheus/blob/main/kustomization.yaml我想创建AlertManager
webhook:
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: custom
spec:
route:
receiver: custom
groupBy: ['job']
groupWait: 30s
groupInterval: 5m
repeatInterval: 12h
receivers:
- name: custom
webhook_configs:
- send_resolved: true
url: https://example.com
出现错误:
error: error validating "alertmanagerconfig.yaml": error validating data: ValidationError(AlertmanagerConfig.spec.receivers[0]): unknown field "webhook_configs" in com.coreos.monitoring.v1alpha1.AlertmanagerConfig.spec.receivers; if you choose to ignore these errors, turn validation off with --validate=false
如何解决?
以此link为参考,
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: custom
spec:
receivers:
- name: custom
webhookConfigs:
- send_resolved: true
url: https://example.com
您还可以使用 kubectl explain
命令检查字段
kubectl explain alertmanagerconfig.spec.receivers
问题是您使用的是实际 AlertManager 应用程序的配置参考,而不是 Prometheus Operator 提供的 Kubernetes 自定义资源的配置参考。
Prometheus Operator 采用以 AlertManagerConfig 等自定义资源形式提供的配置,并将它们转换为实际的 AlertManager 配置,并更新应用程序使用的配置文件。这就是您首先使用运算符的部分原因。它使这些事情对您来说很方便。
所以您在这里应该使用的实际配置参考是 this。 Prometheus Operator github 自述文件的 part 列出了您可以使用它的可用自定义资源。
除了 Kiran 的回答(谢谢!),还有一个小的更正 - 它实际上是 sendResolved
而不是 send_resolved
。
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: custom
spec:
receivers:
- name: custom
webhookConfigs:
- sendResolved: true
url: https://example.com
我通过使用这个 yaml 生成名为 alertmanager-main
的 Kubernetes secret
解决了这个问题:
global:
#skipped
route:
group_by: ['job']
receiver: Default
routes:
- receiver: Watchdog
repeat_interval: 1m
match:
alertname: Watchdog
receivers:
- name: Watchdog
webhook_configs:
- url: https://my.watchdog.webhook.url
# Other things
这是警报管理器配置。
我会在一段时间后回答我的问题,Prometheus Operator CRD 的这个问题现在可能已经解决了。