1. 下载二进制文件
1
2
3
4
|
wget https://github.com/thanos-io/thanos/releases/download/v0.26.0/thanos-0.26.0.linux-amd64.tar.gz
tar xvf thanos-0.26.0.linux-amd64.tar.gz
mv thanos-0.26.0.linux-amd64/thanos /usr/bin/
rm -rf thanos-0.26.0.linux-amd64*
|
2. 安装 Thanos Query
1
|
vim /etc/systemd/system/thanos-query.service
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
[Unit]
Description=Thanos Query
After=network-online.target
[Service]
Restart=on-failure
ExecStart=/usr/bin/thanos query \
--log.level=debug \
--query.auto-downsampling \
--grpc-address=0.0.0.0:30091 \
--http-address=0.0.0.0:30092 \
--query.partial-response \
--query.replica-label=prometheus_replica \
--query.replica-label=rule_replica \
--store=1.0.0.0:30091 \
--store=2.0.0.0:30091
[Install]
WantedBy=multi-user.target
|
--store
参数添加需要聚合的全部源。
1
|
systemctl daemon-reload && systemctl enable thanos-query
|
1
|
systemctl start thanos-query && systemctl status thanos-query
|
3. 安装 Thanos Sidecar
1
|
vim /etc/systemd/system/thanos-sidecar.service
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[Unit]
Description=Thanos SideCar
After=network-online.target
[Service]
Restart=on-failure
ExecStart=/usr/bin/thanos sidecar \
--grpc-address=0.0.0.0:30091 \
--tsdb.path /var/lib/prometheus \
--prometheus.url "http://localhost:9090"
[Install]
WantedBy=multi-user.target
|
这里如果需要上传到对象存储还需要加上 --objstore.config-file /etc/thanos/bucket_config.yaml
,指定对象存储相关的参数。
1
|
systemctl daemon-reload && systemctl enable thanos-sidecar
|
1
|
systemctl start thanos-sidecar && systemctl status thanos-sidecar
|