---
title: Wavefront ProxyをRocky Linuxにインストールするメモ
tags: ["OrbStack", "Wavefront", "Tanzu", "Telegraf", "Rocky"]
categories: ["Observability", "Wavefront"]
date: 2024-06-04T17:28:49Z
updated: 2024-07-12T04:48:12Z
---

Wavefront ProxyをRocky Linuxにインストールします。

この記事ではRocky Linux環境として、[OrbStack](https://orbstack.dev/)の[Linux Machine](https://docs.orbstack.dev/machines/)を使用します。


**目次**
<!-- toc -->

### Linux Machineの作成

```
orb create -a amd64 rocky:8 wf-proxy
```

シェルにアクセスします。

```
orb shell -m wf-proxy
```

作業に使用するCLIをインストールします。

```
sudo yum update -y && sudo yum install wget less vim jq -y
```

### JDKのインストール

Java 11が推奨のようです。

```
sudo yum install java-11-openjdk-headless -y
```

```
$ java -version
openjdk version "11.0.23" 2024-04-16 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.23.0.9-2) (build 11.0.23+9-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.23.0.9-2) (build 11.0.23+9-LTS, mixed mode, sharing)
```

### Wavefront Proxyのインストール

https://docs.wavefront.com/proxies_manual_install.html を参考に、yumでインストールします。

```
curl -s https://packagecloud.io/install/repositories/wavefront/proxy/script.rpm.sh | sudo bash
sudo yum install wavefront-proxy -y
```

`/etc/wavefront/wavefront-proxy/wavefront.conf`にWavefront Proxyの設定を行います。

WAVEFRONT_URLと、[API Token](https://docs.wavefront.com/api_tokens.html)を設定します。OTLP (OpenTelemetry Protocol)でも受信できるようにしておきます。

```
WAVEFRONT_URL=https://<tanent_id>.wavefront.com/api
WAVEFRONT_TOKEN=*******
WAVEFRONT_PROXY_NAME=${HOSTNAME}

sudo sed -i.bak \
  -e "s|server=SERVER_URL_HERE|server=${WAVEFRONT_URL}|" \
  -e "s|#proxyname=my.proxy.name.com|proxyname=${WAVEFRONT_PROXY_NAME}|" \
  -e "s|#token=WF_TOKEN_HERE|token=${WAVEFRONT_TOKEN}|" \
  -e "s|#otlpGrpcListenerPorts=4317|otlpGrpcListenerPorts=4317|" \
  -e "s|#otlpHttpListenerPorts=4318|otlpHttpListenerPorts=4318|" \
  /etc/wavefront/wavefront-proxy/wavefront.conf
```

Wavefront Proxyを起動します。

```
sudo service wavefront-proxy start
```

StatusがrunningになっていればOKです。

```
$ sudo service wavefront-proxy status
Wavefront Proxy is running (PID 3731)
```

ログは次のコマンドで確認できます。

```
tail -f /var/log/wavefront/wavefront.log
```

```
2024-06-04 17:32:18,500 INFO  [proxy:main] Wavefront Proxy version 13.5 (pkg:jar), runtime: OpenJDK Runtime Environment (BellSoft) 11.0.23
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
SLF4J: Ignoring binding found at [jar:file:/opt/wavefront/wavefront-proxy/bin/wavefront-proxy.jar!/BOOT-INF/lib/log4j-slf4j-impl-2.23.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation.
2024-06-04 17:32:18,629 INFO  [Utils:detectLocalHostName] Hostname: 'wf-proxy' (detected using 'hostname' command)
2024-06-04 17:32:18,830 INFO  [proxy:start] Wavefront Proxy version 13.5 (pkg:jar), runtime: OpenJDK Runtime Environment (BellSoft) 11.0.23
2024-06-04 17:32:18,832 INFO  [proxy:start] OS Max File Descriptors: 1048576
2024-06-04 17:32:20,008 INFO  [ProxyConfig:parseArguments] modifyByArgs: pushConfigFile
2024-06-04 17:32:20,072 INFO  [ProxyConfig:parseArguments] modifyByFile: server, pushListenerPorts, otlpHttpListenerPorts, proxyname, otlpGrpcListenerPorts, token
2024-06-04 17:32:20,080 INFO  [ProxyConfig:constructTenantInfoObject] Wavefront api token for further authentication. For the server https://vmware.wavefront.com/api
2024-06-04 17:32:20,093 INFO  [ProxyConfig:parseArguments] Unparsed arguments: 
2024-06-04 17:32:20,094 INFO  [ProxyConfig:parseArguments] Using proxyname:'wf-proxy' hostname:'wf-proxy'
2024-06-04 17:32:20,103 INFO  [ProxyConfig:parseArguments] Config: (* command line argument)
2024-06-04 17:32:20,104 INFO  [ProxyConfig:parseArguments] 	* pushConfigFile = /etc/wavefront/wavefront-proxy/wavefront.conf
2024-06-04 17:32:20,104 INFO  [ProxyConfig:parseArguments] 	  server = https://vmware.wavefront.com/api
2024-06-04 17:32:20,104 INFO  [ProxyConfig:parseArguments] 	  pushListenerPorts = 2878
2024-06-04 17:32:20,105 INFO  [ProxyConfig:parseArguments] 	  otlpHttpListenerPorts = 4318
2024-06-04 17:32:20,105 INFO  [ProxyConfig:parseArguments] 	  proxyname = wf-proxy
2024-06-04 17:32:20,105 INFO  [ProxyConfig:parseArguments] 	  otlpGrpcListenerPorts = 4317
2024-06-04 17:32:20,105 INFO  [ProxyConfig:parseArguments] 	  token = ******
2024-06-04 17:32:20,189 INFO  [proxy:getOrCreateProxyId] Ephemeral proxy id created: 300fcde5-6d59-467c-b227-5a4b17f01ed3
2024-06-04 17:32:22,284 INFO  [proxy:checkin] Checking in tenants: https://vmware.wavefront.com/api
2024-06-04 17:32:24,290 INFO  [proxy:<init>] initial configuration is available, setting up proxy
2024-06-04 17:32:24,299 INFO  [proxy:processConfiguration] Proxy trace span sampling rate set to 0.05
2024-06-04 17:32:24,449 INFO  [proxy:scheduleCheckins] scheduling regular check-ins
2024-06-04 17:32:24,923 INFO  [ProxySendConfigScheduler:lambda$new$0] Configuration sent to the server successfully.
2024-06-04 17:32:26,002 INFO  [proxy:lambda$startListeners$8] listening on port: 2878 for Wavefront metrics
2024-06-04 17:32:26,086 INFO  [proxy:startOtlpGrpcListener] listening on port: 4317 for OTLP data over gRPC
2024-06-04 17:32:27,834 INFO  [proxy:startOtlpHttpListener] listening on port: 4318 for OTLP data over HTTP
2024-06-04 17:32:32,869 INFO  [proxy:run] setup complete
...
```

次のコマンドでWavefrontのSaaS側にProxyが登録されているかチェックできます。

```
curl -s -H "Authorization: Bearer ${WAVEFRONT_TOKEN}" "${WAVEFRONT_URL}/v2/proxy?offset=0&limit=100" | jq '.response.items | map(select(.hostname == "wf-proxy" and .status == "ACTIVE"))'
```

Wavefront Proxy自体のメトリクスは"Operations for Applications Service and Proxy Data"ダッシュボード (`https://<tenant_id>.wavefront.com/dashboards/integration-system`) で確認できます。

"Filter"に`source=wf-proxy`を入力して絞ります。

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/14265546-42ee-4947-91c8-4d2257d2964d">

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/6b6bad10-7010-4a1b-839d-88fb7dff649e">

テストデータを送信してみます。

```
$ curl -sv http://localhost:2878 -X POST -d "test.metric 100 source=test.source"
> POST / HTTP/1.1
> Host: localhost:2878
> User-Agent: curl/7.61.1
> Accept: */*
> Content-Length: 34
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 202 Accepted
< content-type: text/plain
< content-length: 0
< connection: keep-alive
< 
```

SaaS側でデータが受信できていることをダッシュボードから確認できます。

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/528e9fc9-e843-45e0-bb7a-a974a70cd0cb">

"Browse" -> "Metrics"から送信したメトリクスを確認します。"Metrics"に`test.metrics`を入力してフィルタリングします。

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/d82c9f9c-9481-4700-bf7f-5bd5379ee5a2">

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/8e23d875-a455-4ea9-b3ac-ea78abe75fa3">

### Telegrafのインストール

Wavefront Proxyにメトリクスを送信するAgentとして、[Telegraf](https://www.influxdata.com/time-series-platform/telegraf/)をインストールします。
今回はWavefront Proxyと同じ環境にTelegrafをインストールします。

https://docs.wavefront.com/proxies_manual_install.html#installing-telegraf-manually を参考にyumでtelegrafをインストールします。

```
curl -s https://packagecloud.io/install/repositories/wavefront/telegraf/script.rpm.sh | sudo bash
sudo yum install telegraf -y
```

Wavefront Proxy向けのoutput pluginを使用します。
https://github.com/influxdata/telegraf/blob/master/plugins/outputs/wavefront/README.md 

```toml
cat <<EOF | sudo tee -a /etc/telegraf/telegraf.d/10-wavefront.conf
[[outputs.wavefront]]
  url = "http://localhost:2878"
  metric_separator = "."
  source_override = ["proxyname", "agent_host", "node_host"]
  convert_paths = true
EOF
```

Wavefront Proxyとは別の環境にインストールする場合は`localhost`の代わりにWavefront ProxyのIPまたはホスト名を使用してください。

telegrafを起動します。

```
sudo service telegraf start
```

ログは次のコマンドで確認できます。

```
$ journalctl -u telegraf
-- Logs begin at Tue 2024-06-04 16:32:31 JST, end at Wed 2024-06-05 00:53:00 JST. --
 6月 05 00:52:51 wf-proxy systemd[1]: Starting Telegraf...
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Loading config: /etc/telegraf/telegraf.conf
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Loading config: /etc/telegraf/telegraf.d/10-wavefront.conf
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Starting Telegraf 1.28.2 brought to you by InfluxData the makers of InfluxDB
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Available plugins: 240 inputs, 9 aggregators, 29 processors, 24 parsers, 59 outputs, 5 secret-stores
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Loaded inputs: cpu disk diskio kernel mem processes swap system
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Loaded aggregators:
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Loaded processors:
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Loaded secretstores:
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Loaded outputs: wavefront
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! Tags enabled: host=wf-proxy
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"wf-proxy", Flush Interval:10s
 6月 05 00:52:52 wf-proxy systemd[1]: Started Telegraf.
 6月 05 00:52:52 wf-proxy telegraf[7751]: 2024-06-04T15:52:52Z I! The Wavefront SDK will communicate with a Wavefront Proxy.
 6月 05 00:53:00 wf-proxy telegraf[7751]: 2024-06-04T15:53:00Z I! [inputs.processes] Unknown state "0" in file "/proc/7751/stat"
```

"Linux Host"ダッシュボード (`https://<tenant_id>.wavefront.com/dashboards/integration-linux-host`) でTelegrafがインストールされたHostのメトリクスを確認できます。

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/75025a83-658d-49af-b0bb-8906309e32de">

デフォルトのintervalが`10s`と短いので、`/etc/telegraf/telegraf.conf`を変更して、間隔をもっと伸ばした方が良いです。

```
# ...
[agent]
  ## Default data collection interval for all inputs
  interval = "60s"
# ...
```
