LoginSignup
0
0

More than 1 year has passed since last update.

Flink task managerのhostnameをGrafana Dashboardで表示する

Posted at

想定読者

事象

Flinkのtask managerがtaskmanager-hostname.com上にホストされていると仮定。

task managerのhostnametaskmanager-hostname)が見えて欲しいが、代わりにハイフン区切りのIPアドレス(100-XX-XX-XX)が見える。

アップグレード前のFlink 1.8では特に問題なく見れていた。

Job managerは問題ない。

Grafana関連の設定

flink-conf.yaml
metrics.reporter.grph.factory.class: org.apache.flink.metrics.graphite.GraphiteReporterFactory
metrics.reporter.grph.host: grafana-hostname.com
metrics.reporter.grph.port: 2003
metrics.reporter.grph.protocol: TCP

参考リンク

Re: Hostname for taskmanagers when running in docker

There is no convenient cosmetic way to achieve what you want.
The only approach that would currently work is hard-coding the host into
the configuration of each taskmanager via the metrics.scope.*
configuration options.

As it is there are 2 ways to configure the hostname 1) using docker's
hostname property under a service 2) using flink's explicit
taskmanager.host configuration.
Prior to 1.11 the taskmanager.host variable was not needed. ...

I will try to use the metrics scope and pass the name of the hostname there
instead.

解決策: metrics.scope.*にホストネームを設定

metrics.scope.*にホストネームを設定する。Task managerに関係するのは以下。

上記設定のデフォルト値に含まれる<host>という文字列は、task managerの実行時に実際のホストに置き換わるようだが、Flink 1.11ではIPアドレスになってしまう模様。

Task manager上で実行した$(hostname)の実行結果を取得して利用したいので、mesos-taskmanager.shこのあたりに処理を追加する。

mesos-taskmanager.sh
...
TASKMANAGER_HOSTNAME=$(hostname)
METRICS_SCOPE_OPERATOR="${TASKMANAGER_HOSTNAME}.taskmanager.<tm_id>.<job_name>.<operator_name>.<subtask_index>"
METRICS_SCOPE_TASK="${TASKMANAGER_HOSTNAME}.taskmanager.<tm_id>.<job_name>.<task_name>.<subtask_index>"
METRICS_SCOPE_TM=...
METRICS_SCOPE_TM_JOB=...
export FLINK_ENV_JAVA_OPTS_TM="${FLINK_ENV_JAVA_OPTS_TM} -Dmetrics.scope.operator=${METRICS_SCOPE_OPERATOR} -Dmetrics.scope.task=${METRICS_SCOPE_TASK} ..."
...

その他検討したアイデア

taskmanager.host

The external address of the network interface where the TaskManager is exposed. Because different TaskManagers need different values for this option, usually it is specified in an additional non-shared TaskManager-specific config file.

影響範囲が大きくなりそうなので不採用。

mesos.resourcemanager.tasks.bootstrap-cmd

A command which is executed before the TaskManager is started.

flink-conf.yamlmetrics.scope.*を記載しておき、このオプション内で$hostnameの実行結果を使って置換(sedコマンド等)することも検討したが、上記の解決策がワークしたので詳細に検討していない。

mesos.resourcemanager.tasks.taskmanager-cmd

default "$FLINK_HOME/bin/mesos-taskmanager.sh"

flink-conf.yamlの置換」という方向でこちらは試してみた。
置換自体はうまくできたが、task managerが起動した時点でflink-conf.yamlが既に読み込まれているようで、置換した結果をtask managerが使っていない模様。

0
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
0
0