LoginSignup
2
0

More than 3 years have passed since last update.

PrometheusOperatorのServiceMonitorでrelabelingすると「relabel configuration for replace action requires 'target_label' value"」と怒られる

Last updated at Posted at 2019-06-19

この記事は?

タイトル通りです。
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時間近く時間を使ってしまったので、次の被害者を出さないために書きました。
これ統一してほしいんですよね…。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0