国产一区二区精品-国产一区二区精品久-国产一区二区精品久久-国产一区二区精品久久91-免费毛片播放-免费毛片基地

千鋒教育-做有情懷、有良心、有品質的職業教育機構

手機站
千鋒教育

千鋒學習站 | 隨時隨地免費學

千鋒教育

掃一掃進入千鋒手機站

領取全套視頻
千鋒教育

關注千鋒學習站小程序
隨時隨地免費學習課程

當前位置:首頁  >  技術干貨  > Prometheus 通過將數據遠程寫入InfluxDB 1.x存儲

Prometheus 通過將數據遠程寫入InfluxDB 1.x存儲

來源:千鋒教育
發布人:yyy
時間: 2023-06-27 11:41:00 1687837260

  安裝influxdb1.x

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.0.x86_64.rpm
yum -y localinstall influxdb-1.8.0.x86_64.rpm

   編輯配置文件

  最終修改效果項如下所示

bind-address = "0.0.0.0:8088"
[meta]
dir = "/var/lib/influxdb/meta"
[data]
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
cache-max-memory-size = "8g"
series-id-set-cache-size = 100
[coordinator]
max-concurrent-queries = 0
query-timeout = "0s"
log-queries-after = "10s"
max-select-series = 0
max-select-buckets = 0
[retention]
[shard-precreation]
advance-period = "10m"
[monitor]
[http]
enabled = true
bind-address = ":8086"
log-enabled = false
max-row-limit = 10000

   啟動服務

systemctl start influxdb
systemctl enable influxdb

建庫
curl -XPOST http://192.168.241.13:8086/query --data-urlencode "q=CREATE DATABASE prometheus"
或者
influx -precision rfc3339
create database prometheus;
show databases;

   準備remote_storage_adapter

  對于業務比較大的環境Local storage是絕對滿足不了的,那么就要用remote storage了。

  Prometheus的remote storage需要借助adapter實現,adapter會提供write url和read url給Prometheus,這樣Prometheus獲取到數據后就會先寫到本地然后再調用write url寫到遠端。

  下載一個可執行文件remote_storage_adapter。

  GitHub地址:

https://github.com/prometheus/prometheus/blob/main/documentation/examples/remote_storage/remote_storage_adapter/README.md

   需要安裝一個go環境并進行build。我已經build好了,下載下面的地址可以直接用。

wget https://github.com/zyiqian/charts/blob/main/prometheus/remote_storage_adapter
chmod +x remote_storage_adapter

   手工啟動

nohup /usr/local/sbin/remote_storage_adapter 
--influxdb-url=http://192.168.241.13:8086
--influxdb.database=prometheus
--influxdb.retention-policy=autogen >/var/log/remote_storage_adapter.log 2>&1 &

   將remote_storage_adapter注冊為系統服務

cat>/lib/systemd/system/remote_storage_adapter.service<<EOF
[Service]
Restart=on-failure
WorkingDirectory=/root/
ExecStart=/usr/local/sbin/remote_storage_adapter --influxdb-url=http://192.168.241.13:8086/ --influxdb.database="prometheus" --influxdb.retention-policy=autogen
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable remote_storage_adapter
systemctl start remote_storage_adapter
systemctl status remote_storage_adapter

   配置prometheus遠程寫入

  修改prometheus.yml中的配置remoteWrite和remoteRead

remote_write:
- url: "http://192.168.241.13:8086/api/v1/prom/write?db=prometheus"
remote_read:
- url: "http://192.168.241.13:8086/api/v1/prom/read?db=prometheus"

   查看Influxdb

# influx
Connected to http://localhost:8086 version 1.8.0
influxdb shell version: 1.8.0
> show databases;
name: databases
name
----

prometheus
_internal
> use prometheus
Using database prometheus
> SHOW MEASUREMENTS;
name: measurements
name
----
ALERTS
ALERTS_
FOR_STATE
aggregator_
openapi_v2_regeneration_count

 

tags: prometheus
聲明:本站稿件版權均屬千鋒教育所有,未經許可不得擅自轉載。
10年以上業內強師集結,手把手帶你蛻變精英
請您保持通訊暢通,專屬學習老師24小時內將與您1V1溝通
免費領取
今日已有369人領取成功
劉同學 138****2860 剛剛成功領取
王同學 131****2015 剛剛成功領取
張同學 133****4652 剛剛成功領取
李同學 135****8607 剛剛成功領取
楊同學 132****5667 剛剛成功領取
岳同學 134****6652 剛剛成功領取
梁同學 157****2950 剛剛成功領取
劉同學 189****1015 剛剛成功領取
張同學 155****4678 剛剛成功領取
鄒同學 139****2907 剛剛成功領取
董同學 138****2867 剛剛成功領取
周同學 136****3602 剛剛成功領取
相關推薦HOT