作業メモ
環境
- Juniper vMX on AWS EC2(BYOL/Trial)
- JUNOS 19.4R1.9
- fluentd
したいこと
Junosから送られてくるJuniper Telemetry Interface(over UDP)をfluentdで受けたい。とりあえずはテキストでローカルに吐いてくれれば良い
作業
前提条件
- fluentdはパッケージでインストール済み
- Installation: Install by RPM Package (Red Hat Linux) - Fluentd
- EC2でAMIにてインスタンスを立てていたのでので、AMIのセクションの記載でインストール(といってもcurlでshellとってきてパイプでsh叩いてるだけなので、何もすることはないが)
Junosの設定
AWS Marketplaceで取得したJunos vMXにはrootパスワードが設定されておらず、commitが出来ないのでよしなに設定
普段、Junosを触らないが、ドキュメント通りに設定すれば出来た
- Configuring a Junos Telemetry Interface Sensor (CLI Procedure) | Junos OS | Juniper Networks
- Export Profile, Streaming Server Profile, Sensor Profileの設定が必要
- Export Profile
- Junos自身がどういうIP/ポート...でテレメトリを出すか?を指定
set local-address
にはJunosのマネジメントIPを指定したset local-port
は適当に12345
set transport
は今回、UDPにした- DSCP, forwarding class, packet loss priorityはoptionalで今回は作り込む気はないので、スキップ
- Streaming Server Profile
- Sensor Profile
- どういう情報を持つテレメトリを出すかの設定
resource
には/junos/system/linecard/cpu/memory/
をとりあえず指定- その他のものの詳細はこのへん(Understanding OpenConfig and gRPC on Junos Telemetry Interface | Junos OS | Juniper Networks)を見れば良さそう
- Configuring a Junos Telemetry Interface Sensor (CLI Procedure) | Junos OS | Juniper Networks
最終的には以下の感じのconfigになった
services { analytics { streaming-server ec2 { remote-address 10.0.1.63; remote-port 22000; } export-profile fluentd { local-address 10.0.1.164; local-port 12345; reporting-rate 5; format gpb; transport udp; } sensor interface-1 { server-name ec2; export-name fluentd; resource /junos/system/linecard/cpu/memory/; } } }
Pluginのインストール
- fluent-plugin-udp-native-sensorsを使う
- JTI Plug-ins for Open Source Data Collectors | Junos OS | Juniper Networksでリストアップされているが、UDP/gRPC版も2021/5現在ほぼ更新がないどっこいどっこいの状態。UDP版はPull Requestで最新版のfluentdに対応するようなものが他の人から出ているので、それを使う
git clone https://github.com/Juniper/fluent-plugin-udp-native-sensors # 普通にclone git fetch origin pull/3/head:with_keys_1.0 # fluentd最新版に対応したPRを取得 git checkout with_keys_1.0 sudo td-agent-gem build fluent-plugin-udp-native-sensors.gemspec # fluentd内蔵のgemでビルド sudo td-agent-gem install fluent-plugin-udp-native-sensors-0.0.1.gem # fluentd内蔵のgemでインストール
Pluginの設定
- GithubのREADME通りだが、
/etc/td-agent/td-agent.conf
に以下を追記- もしJunosの設定でStreaming Server Profileにあるremote-portを22000以外にしていたら、その変更したポートを指定する
<source> @type udp tag juniperNetworks format juniper_udp_native port 22000 bind 0.0.0.0 </source> <match juniperNetworks> @type file path /home/ec2-user/junos/ </match>
- td-agentを再起動
参考文献
- パッケージでインストールしたfluentdで自前ビルドしたpluginをインストールしたい
- td-agentとrbenv/gemでインストールしたfluentdのディレクトリ構成の比較 - suzuki-navi’s blog