プロメテウスのインストール
ダウンロードしてインストール
#官网下载 解压即可使用
https://prometheus.io/download/
#docker 方式安装
sudo docker run -n prometheus -d -p 9090:9090 prom/prometheus
プロファイル
/etc/prometheus/prometheus.yml 或 可执行文件当前目录下/prometheus.yml
プロフィール
scheme: http
static_configs:
- targets:
- localhost:9090
- job_name: node1_self
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- 192.168.3.103:9100
- job_name: mysql
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- 192.168.3.103:9104
labels:
instance: db1
- job_name: nginx
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /status/format/prometheus
scheme: http
static_configs:
- targets:
- 192.168.3.139:80
labels:
instance: web1
basic_auth:
username: UserName
password: PassWord
サービスの再起動
サービスを再起動するか、コンフィギュレーションをリロード信号
killall -HUP prometheus
Daquanの公式の輸出
https://prometheus.io/docs/instrumenting/exporters/
Linuxサーバの設定
ダウンロードしてnode_exporterをインストールする(ダウンロードエキスを使用することができます)
https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
./node_exporter
测试node_exporter
カールます。http:// localhostを:9100 /メトリック
MySQLのダウンロードおよび輸出を設定
MySQLはまた、他のマシンにインストールすることができるマシンにインストールすることができます
`抽出する必要があります古い方法
https://github.com/prometheus/mysqld_exporter/releases
- MySQLのアカウントに監視されているものの情報を設定するには
、個別に最高のconfigure権限を
別のユーザーを作成mysqld_exporterする
と、それに限定された権限を与える(プロセス、複製CLIENTを、SELECT)
(MAX_USER_CONNECTIONS)接続好ましく、また、その最大数を制限
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'password' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
$猫.my.cnf
[クライアント]
ホスト=ローカルホスト
ポート= 3306
ユーザー=ルート
パスワード= 123456
运行mysqld_exporter
`./mysqld_exporter --config.my-CNF = " my.cnfファイル"- プロメテウスでは、サーバの設定ファイルが
prometheus.yml
で見つかったscrape_config
追加の子の仕事
などを:
- job_name: mysql
static_configs:
- targets: ['192.168.1.7:9104']
labels:
instance: db1
- 過負荷信号伝送プロファイル
killall -SIGHUP prometheus
- プロメテウスは、ページへの
导航栏->status->target
追加したばかりの成功を参照してください!
インストールおよび構成nginxの輸出国
多くの方法は、スクリプト、openrestyを.luaできるので
、私たちはnginxのコンパイルすることを選択したnginx-module-vts
。これは、我々は手動で自分自身をコンパイルする必要があることを意味します。
- 解凍後nginxのソースをダウンロードしてください。
wget https://github.com/nginx/nginx/releases/tag/release-1.17.1
tar -xvf nginx-release-1.17.1.tar.gz
cd nginx-release-1.17.1
- ダウンロードまたはクローニング
nginx-module-vts
モジュールhttps://github.com/vozlt/nginx-module-vts - nginxのコンパイルとインストール
コンパイルはスキップ頼る
...
./auto/configure --add-module=/home/pi/nginx-module-vts --with-http_ssl_module --with-debug
nginxのを殺す
make -j4
4つのスレッドのコンパイラを使用して。ラズベリーPiは4つのスレッドが持っている
make install
nginxのデフォルトインストール
4.設定のnginxの設定ファイルを
vim /usr/local/nginx/conf/nginx.conf
user root;
#user nobody;
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
vhost_traffic_status_zone;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root html;
auth_basic "needAuth";
auth_basic_user_file /usr/local/nginx/conf/passwd.db;
}
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
HTTPパスワードの設定
apt install apache2-utils -y
htpasswd -c /usr/local/nginx/conf/passwd.db UserName
nginxの起動する
モジュールの下に見てすることはでコンパイルされていません
cd /usr/local/nginx/
/usr/local/nginx/sbin/nginx -V |grep nginx-module-vts
あなたは成功したコンパイラモジュールに代わって情報を見ることができます。
- nginxの実行
/usr/local/nginx/sbin/nginx
4.1ビューのIP nginxのマシンを
ip a
- nginxのは、プロメテウスで監視ミッションを追加し
たコンテンツ構成プロファイルの追加prometheus.yml
それ以外のアクセスをサポートしています方法はありません。我々は、構成の検証をnginxのため、彼らは追加する必要がありますので、検証プロメテウスの注意を
- job_name: nginx
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /status/format/prometheus
scheme: http
static_configs:
- targets:
- 192.168.3.139:80
labels:
instance: web1
basic_auth:
username: UserName
password: PassWord
- 過負荷信号伝送プロファイル
killall -SIGHUP prometheus
- プロメテウスは、ページへの
导航栏->status->target
追加したばかりの成功を参照してください!
そして、楽しみを持つことができGrafanaに続くこと。