この記事は?
タイトル通りです。
PrometheusOperatorのServiceMonitorを書いているときに、「relabel configuration for replace action requires 'target_label' value"」と怒られるときの話です。
症状
ServiceMonitorの設定のrelabelingを変更し、PrometheusのPodを再起動したが起動してこないとき、ログを見ると以下のような記載があります。
level=info ts=2019-06-07T05:27:07.605342963Z caller=notifier.go:521 component=notifier msg="Stopping notification manager..."
level=info ts=2019-06-07T05:27:07.605372036Z caller=main.go:679 msg="Notifier manager stopped"
level=error ts=2019-06-07T05:27:07.605757827Z caller=main.go:688 err="error loading config from \"/etc/prometheus/config_out/prometheus.env.yaml\": couldn't load configuration (--config.file=\"/etc/prometheus/config_out/prometheus.env.yaml\"): parsing YAML file /etc/prometheus/config_out/prometheus.env.yaml: relabel configuration for replace action requires 'target_label' value"
これ
relabel configuration for replace action requires 'target_label' value"
一見、action: replace
は使っていないのになぜ???となります。
原因
target_label
もしくはsource_label
と定義している。
Prometheus | PrometheusOperator |
---|---|
target_label | targetLabel |
source_label | sourceLabel |
多くは、prometheus.ymlの内容をそのままコピーしてきたときに発生します。PrometheusOperatorでは上記のようなアンダースコア付きのsnake_case
ではなく、単語の先頭を大文字にするCamelCase
を利用します。これは、Kubernetsのベストプラクティスに準拠するためにこのような仕様になっています。
該当のIssueもありました。
https://github.com/coreos/prometheus-operator/issues/2503
終わりに
これに1時間近く時間を使ってしまったので、次の被害者を出さないために書きました。
これ統一してほしいんですよね…。