プロメテウスについて
プロメテウスとは何ですか
プロメテウスは、オープンソース監視及び警報システム配列データベースであります
主な機能
- 多次元データモデリング(シーケンス名で構成され、メトリックのk / Vのラベル)の
- 柔軟なクエリ(PromQL)
- 信頼保存しない、ローカルおよびリモートの異なるモデルをサポートしませ
- httpプロトコル、プルモードの使用、プルデータを用いて、簡単な
- モニタリングの目的、サービスの発見や静的構成方法を使用することができます
- 複数のダッシュボードのサポート、グラフィカルに優しいです
コアコンポーネント
- プロメテウスServerは、主にデータの取り込みや時系列データの保存のためともクエリと警告ルール設定の管理を提供します。
- クライアントライブラリは、プロメテウスサーバーをドッキングするために、クエリでデータを報告することができます。
- プッシュ・ゲートウェイ、バルクため、加算ノードが短期主として事業報告及び他のデータのために、データを監視します。
- そのような機械node_exporterデータ報告などの様々なデータを報告輸出業者は、輸出のMongoDB MongoDBは等、情報を報告します。
- アラーム通知のAlertManager管理のため。
インフラ
主要なモジュールが含まれます:サーバー、輸出業者、Pushgateway、PromQL、のAlertManagerは、WebUIなどを。
- プロメテウスサーバー:ストレージ、キャプチャ、集計、クエリ用語の主な原因であります
- AlertManager:アラームを実現するために主に責任を負います
- Pushgateway:インデックスデータを受信し、主にメインプログラムによって捕捉するために、指定された時間間隔で、オーバークライアントプッシュすることによって達成されます
- 輸出:データサンプラ
研究の参照サイト(この章では、次のWebサイトを参照してください - ブログは、学習を使用しています)
技術的な牛のブログ: https://www.k8stech.net/
中文技术文档:https://www.prometheus.wang/visualiztion/grafana.html
Prometheus+node_exporter+Grafana资源监控架构图
Centos7.x安装Prometheus
下载安装Prometheus
PROM_PATH='/data/prometheus' mkdir -p ${PROM_PATH} mkdir -p ${PROM_PATH}/{data,conf,logs,bin} useradd prometheus cd /usr/local/src wget https://github.com/prometheus/prometheus/releases/download/v2.13.0/prometheus-2.13.0.linux-amd64.tar.gz tar -xvf prometheus-2.13.0.linux-amd64.tar.gz cd prometheus-2.13.0.linux-amd64/ cp prometheus promtool ${PROM_PATH}/bin/ cp prometheus.yml ${PROM_PATH}/conf/ chown -R prometheus.prometheus /data/prometheus # Setting Variables cat >> /etc/profile <<EOF PATH=/data/prometheus/bin:$PATH:$HOME/bin EOF
将Prometheus配置系统服务
cat >>/etc/systemd/system/prometheus.service <<EOF [Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/data/prometheus/bin/prometheus --config.file=/data/prometheus/conf/prometheus.yml --storage.tsdb.path=/data/prometheus/data --storage.tsdb.retention=90d Restart=on-failure [Install] WantedBy=multi-user.target EOF
现在使用下面的systemctl命令重新加载systemd系统,并查看服务是否启动
systemctl daemon-reload
systemctl enable prometheus.service
systemctl start prometheus.service
systemctl status prometheus.servic
查看端口是否正常
netstat -plntu |grep 9090
这里需要放行9090端口,也可以直接关闭防火墙
systemctl stop firewalld
systemctl status firewall
访问http://IP:9090
出现上图就是成功了!!
Centos7.x安装Node_exporter
下载安装Node_exporter
NODE_PATH='/data/prometheus/node_exporter/' cd /usr/local/src/ mkdir -p ${NODE_PATH} wget https://github.com/prometheus/node_exporter/releases/download/v0.18.0/node_exporter-0.18.0.linux-amd64.tar.gz
tar -xvf node_exporter-0.18.0.linux-amd64.tar.gz
cp node_exporter-0.18.0.linux-amd64/node_exporter ${NODE_PATH}
chown -R prometheus.prometheus ${NODE_PATH}
配置Node_exporter系统服务
cat > /lib/systemd/system/node_exporter.service <<EOF [Unit] Description=node_exporter Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/data/prometheus/node_exporter/node_exporter Restart=on-failure [Install] WantedBy=multi-user.target EOF
现在使用下面的systemctl命令重新加载systemd系统,并查看服务是否启动
systemctl daemon-reload
systemctl enable node_exporter.service
systemctl start node_exporter.service
systemctl status node_exporter.service
查看端口是否正常
netstat -plntu |grep 9100
这里需要放行9100端口
访问http://IP:9100/metrics
如果出现上图,就成功啦!!!
最后一步,配置prometheus.yml
如果是跟着我的安装步骤走的话,它的路径是 /data/prometheus/conf
# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090'] # 主要是新增了node_exporter的job,如果有多个node_exporter,在targets数组后面加即可 - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100']
配置Grafana
这里就不展开如何安装Grafana了哈,不懂的可以查看这篇博客:https://www.cnblogs.com/poloyy/p/12219145.html
配置完之后,就能自动读取prometheus存储的数据,然后就dengdengdengdeng!!厉酷炫吧!!
如果你读取失败,请务必检查自己的prometheus和Node_exporter是否有安装成功,通过访问9090和9100端口的网址来判断即可!