Docker デプロイメント Prometheus の手順:
1. Node Exporterをインストールする
docker run -d -p 9100:9100 \ -v "/proc:/host/proc" \ -v "/sys:/host/sys" \ -v "/:/rootfs" \ -v "/etc/localtime:/etc/localtime" \ --net=ホスト\ prom/ノードエクスポーター \ --path.procfs /ホスト/proc \ --path.sysfs /ホスト/sys \ --collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)" [root@k8s-m1 ~]# docker ps|grep エクスポーター ee30add8d207 prom/node-exporter "/bin/node_exporter …" 約 1 分前 約 1 分前 condescending_shirley 2. cAdvisorをインストールする
docker run -d \ -v "/etc/localtime:/etc/localtime" \ --volume=/:/rootfs:ro \ --volume=/var/run:/var/run:rw \ --volume=/sys:/sys:ro \ --volume=/var/lib/docker/:/var/lib/docker:ro \ --volume=/dev/disk/:/dev/disk:ro \ --publish=18104:8080 \ --detach=true \ --name=cadvisor \ --privileged=true \ google/cadvisor:最新 [root@k8s-m1 ~]# docker ps|grep cadvisor cf6af6118055 google/cadvisor:latest "/usr/bin/cadvisor -…" 38 秒前 37 秒前にアップ 0.0.0.0:18104->8080/tcp cadvisor コンテナに入ると次のものが表示されます: [root@agent ~]# sudo docker exec -it コンテナID /bin/sh 3. Prometheusサーバーをインストールする監視端末設置 1) 設定ファイルを編集する
# 私のグローバル設定 グローバル: scrape_interval: 15s # スクレイプ間隔を 15 秒ごとに設定します。デフォルトは 1 分ごとです。 evaluation_interval: 15s # 15 秒ごとにルールを評価します。デフォルトは 1 分ごとです。 # scrape_timeout はグローバルデフォルト (10 秒) に設定されています。 # アラートマネージャの設定 警告: アラートマネージャー: - 静的設定: - ターゲット: # - アラートマネージャー:9093 # ルールを一度読み込み、グローバル 'evaluation_interval' に従って定期的に評価します。 ルールファイル: # - "first_rules.yml" # - "second_rules.yml" # スクレイピングするエンドポイントを 1 つだけ含むスクレイピング設定: # ここでは Prometheus そのもの。 scrape_configs: # ジョブ名は、この設定から取得されたすべての時系列にラベル `job=<job_name>` として追加されます。 - ジョブ名: 'プロメテウス' # metrics_path のデフォルトは '/metrics' です # スキームのデフォルトは 'http' です。 静的設定: #リスニングアドレス - ターゲット: ['localhost:9090','172.23.0.241:8088','172.23.0.241:9090'] 2) コンテナを起動する 1> prometheus.yml 設定ファイル 外部ネットワーク IP は prometheus.yml で設定する必要があります。内部ネットワーク IP は、ローカル マシンを除いて Grafana では認識されません。 # 私のグローバル設定 グローバル: scrape_interval: 15s # スクレイプ間隔を 15 秒ごとに設定します。デフォルトは 1 分ごとです。 evaluation_interval: 15s # 15 秒ごとにルールを評価します。デフォルトは 1 分ごとです。 # scrape_timeout はグローバルデフォルト (10 秒) に設定されています。 # アラートマネージャの設定 警告: アラートマネージャー: - 静的設定: - ターゲット: # - アラートマネージャー:9093 # ルールを一度読み込み、グローバル 'evaluation_interval' に従って定期的に評価します。 ルールファイル: # - "first_rules.yml" # - "second_rules.yml" # スクレイピングするエンドポイントを 1 つだけ含むスクレイピング設定: # ここでは Prometheus そのもの。 scrape_configs: # ジョブ名は、この設定から取得されたすべての時系列にラベル `job=<job_name>` として追加されます。 - ジョブ名: 'プロメテウス' # metrics_path のデフォルトは '/metrics' です # スキームのデフォルトは 'http' です。 静的設定: #リスニング アドレス (サーバーのイントラネット IP です) - ターゲット: ['10.27.158.33:9090','10.27.158.33:9100','10.27.158.33:18104'] - ターゲット: ['10.29.46.54:9100','10.29.46.54:18104'] - ターゲット: ['10.27.163.172:9100','10.27.163.172:18104'] # - ジョブ名: 'GitLab' # metrics_path: '/-/metrics' # 静的設定: # - ターゲット: ['172.23.0.241:10101'] - ジョブ名: 'jenkins' メトリックパス: '/prometheus/' スキーム: http ベアラートークン: ベアラートークン 静的設定: - ターゲット: ['172.23.0.242:8080'] - ジョブ名: "Nginx" メトリックスパス: '/status/format/prometheus' 静的設定: - ターゲット: ['172.23.0.242:8088'] 2>開始コマンド –net=host、これによりPrometheusサーバーはExporterおよびGrafanaと直接通信できるようになります。 docker run -d -p 9090:9090 \ ディレクトリ名: Prometheus ディレクトリのパス名 -v "/etc/localtime:/etc/localtime" \ --name プロメテウス \ --net=ホスト\ prom/プロメテウス:最新 # Prometheus コンテナが正常に起動した後のアクセス# PS: ブラウザを使用して 9090 0.0.0.0 にアクセスする前に、サーバーは eth0 の外部ネットワーク ポートを開く必要があります。 106.15.0.11:9090 4. Grafanaを作成して実行する
docker run -d -i -p 3000:3000 \ -v "/etc/localtime:/etc/localtime" \ -e "GF_SERVER_ROOT_URL=http://grafana.server.name" \ -e "GF_SECURITY_ADMIN_PASSWORD=admin8888" \ --net=ホスト\ グラファナ/グラファナ # PS: ブラウザでアクセスする前に、サーバーは eth0 の外部ネットワーク ポートを開く必要があります: 3000 0.0.0.0 Grafana が起動したら、ブラウザで 172.23.0.241:3000 ログイン インターフェイスを開き、ログインします。 ユーザー名: admin パスワード: admin8888 1) Prometheusサーバーを追加する 次に、追加したデータソースをグラフィカルに表示します。 5. 監視テンプレートを追加する
この時点で、対応するテンプレートをコンパイルし、Prometheus から値を取得して Grafana に転送することを選択できます。それでおしまい。とても便利です! 6. キー値クエリインジケーター io_namespace_http_requests_total を通じて次のことが可能になります。 アプリケーションの合計リクエスト数を照会する sum(io_namespace_http_requests_total) 1秒あたりのHTTPリクエスト数を照会する sum(rate(io_wise2c_gateway_requests_total[5m])) 現在のアプリケーションリクエストの上位N個のURIを照会する topk(10、io_namespace_http_requests_total の合計、パスによる) Nginxを監視するためにPrometheusを設定する
公式ソースのインストールは次のとおりです。 [root@web01 ~]# vim /etc/yum.repos.d/nginx.repo [nginx-安定版] name=nginx 安定リポジトリ ベースURL=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=1 有効=1 gpgkey=https://nginx.org/keys/nginx_signing.key モジュール_hotfixes=true 2) 依存関係をインストールする yum install -y gcc gcc-c++ autoconf pcre pcre-devel make automake wget httpd-tools vim ツリー 3) nginxをインストールする [root@web01 ~]# yum install -y nginx 4) nginxを設定する [root@web01 ~]# vim /etc/nginx/nginx.conf ユーザー www; 5) サービスを開始する 1. 方法1: 直接起動します。エラーがある場合 ==》重大なエラー、ポート80が占有されています ==》ポートを占有しているサービスHTTPDを確認し、停止してnginxを再起動します [root@web01 ~]# systemctl nginxを起動します 2. 方法2: [root@web01 ~]# nginx 1. 現在のNginxインストールオプションを表示する [root@db01 nginx-1.12.2]# nginx -V [root@db01 nginx-1.12.2]# ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' 2. モジュールを準備する # 新しいパッケージをダウンロードして解凍します [root@k8s-n1 パッケージ]# wget http://nginx.org/download/nginx-1.16.1.tar.gz [root@k8s-n1 パッケージ]# tar xf nginx-1.16.1.tar.gz # nginx-module-vts モジュール [root@k8s-n1 パッケージ] をクローンしてダウンロードします。# git clone https://github.com/vozlt/nginx-module-vts # .GeoIP モジュールをインストールします [root@k8s-n1 パッケージ]# yum -y install epel-release geoip-devel 3. Nginxサービスを停止する # nginx サービスを停止します [root@k8s-n1 パッケージ]# nginx -s stop #元のnginx起動ファイルをバックアップする[root@k8s-n1パッケージ]# which nginx nginx のディレクトリは /usr/sbin/nginx です。 [root@k8s-n1 パッケージ]# mv /usr/sbin/nginx /usr/sbin/nginx.bak # 元のnignxディレクトリをバックアップします [root@k8s-n1 パッケージ]# mv /etc/nginx nginx-1.12.2.bak 4. コンパイルしてインストールする 1> 必要な依存関係をインストールする コンパイルおよびインストール時に、「make: *** No rule to create target 'build' required by 'default'」というエラーが表示される場合があります。 stop` のエラーは依存関係の不足が原因です。# とにかくインストールしてからコンパイルしてください。そうしないと、依存関係をインストールした後に再度 ./configure を実行する必要があります。~ yum install -y gcc gcc++ bash-completion vim lrzsz wget expect net-tools nc nmap tree dos2unix htop iftop iotop unzip telnet sl psmisc nethogs glances bc pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-dev libxslt-devel gd gd-devel perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data pcre-devel 2> コンパイルしてインストールする
–add-module=/root/packages/nginx-module-vts [root@db01 nginx-1.12.2]# ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --add-module=/root/package/nginx-module-vts --with-http_geoip_module # コンパイルしてインストール# -j マルチコアコンパイル (低設定ではこのパラメータの使用は推奨されません。スタックしてしまいます~) [root@k8s-n1 nginx-1.12.2]# make -j && make install 5. Nginxを設定する [root@k8s-n1 パッケージ]# cp -r nginx-1.12.2.bak/conf.d/ /etc/nginx/ [root@k8s-n1 パッケージ]# cp -r nginx-1.12.2.bak/nginx.conf /etc/nginx/ [root@k8s-n1 パッケージ]# rm -f /etc/nginx/conf.d/default.conf Nginx 設定ファイルを構成する HTTP レイヤー サーバー層 ··· http { ··· /etc/nginx/conf.d/*.conf を含めます。 ##################### 1.http レイヤー: 3 行の設定を追加します###################### vhost_traffic_status_zone; vhost_traffic_status_filter_by_host がオン; geoip_country /usr/share/GeoIP/GeoIP.dat; ##################### 2. サーバー層: サーバー層のポート番号を指定します。ポート 8088 が推奨されます。競合がない場合は、コピーして貼り付けるだけです。######################## サーバー{ 聞く 8088; server_name ローカルホスト; # 次の vhost 設定はこの場所に書き込まれます location /status { vhost_traffic_status on; # トラフィックステータス、デフォルトはオン、この行は省略可能 vhost_traffic_status_display; vhost_traffic_status_display_format html; vhost_traffic_status_filter_by_set_key $uri uri::$server_name; # URI ごとの訪問数 vhost_traffic_status_filter_by_set_key $geoip_country_code country::$server_name; # 国/地域ごとのリクエスト数 vhost_traffic_status_filter_by_set_key $status $server_name; # http コード統計 vhost_traffic_status_filter_by_set_key $upstream_addr upstream::backend; # バックエンド > 転送統計 vhost_traffic_status_filter_by_set_key $remote_port client::ports::$server_name; # リクエスト ポート統計 vhost_traffic_status_filter_by_set_key $remote_addr client::addr::$server_name; # リクエスト IP 統計の場所 ~ ^/storage/(.+)/.*$ { $volumeを$1に設定します。 vhost_traffic_status_filter_by_set_key $volume storage::$server_name; #リクエストパス統計} } } ####################### サーバー層: 新しいサーバーを作成したり、元の構成を変更したりできます####################### } 6. Nginxを起動する [root@k8s-n1 パッケージ]# nginx [root@k8s-n1 パッケージ]# netstat -lntp|grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 62214/nginx: マスター tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN 62214/nginx: マスター ブラウザアクセス: 172.23.0.243:80 # nginx デフォルト公式ページ 172.23.0.243:8088/status # nignx 監視項目ページ 7. Prometheusによる監視
[root@k8s-m1 ~]# vim prometheus.yml ··· scrape_configs: - ジョブ名: "Nginx" メトリックスパス: '/status/format/prometheus' 静的設定: - ターゲット: ['172.23.0.243:8088'] ··· [root@k8s-m1 ~]# docker で prometheus を再起動します # このとき、Prometheus 管理ページに入り、nginx の監視項目を照会します。 8. 各モニタリング項目の意味Nginx-module-vts はさまざまな監視項目を提供します。監視項目の意味を理解することで、必要なチャートを生成するのに役立ちます。 # ヘルプ nginx_vts_info Nginx 情報 # タイプ nginx_vts_info ゲージ nginx_vts_info{ホスト名="hbhly_21_205",バージョン="1.16.1"} 1 # ヘルプ nginx_vts_start_time_seconds Nginx の起動時間 # タイプ nginx_vts_start_time_seconds ゲージ nginx_vts_start_time_seconds 1584268136.439 # ヘルプ nginx_vts_main_connections Nginx 接続 # タイプ nginx_vts_main_connections ゲージ # ステータス別の nginx 接続数 nginx_vts_main_connections{status="accepted"} 9271 nginx_vts_main_connections{ステータス="アクティブ"} 7 nginx_vts_main_connections{ステータス="処理済み"} 9271 nginx_vts_main_connections{ステータス="読み取り中"} 0 nginx_vts_main_connections{ステータス="リクエスト"} 438850 nginx_vts_main_connections{ステータス="待機中"} 6 nginx_vts_main_connections{ステータス="書き込み中"} 1 # ヘルプ nginx_vts_main_shm_usage_bytes 共有メモリ [ngx_http_vhost_traffic_status] 情報 # タイプ nginx_vts_main_shm_usage_bytes ゲージ # メモリ使用量 nginx_vts_main_shm_usage_bytes{shared="max_size"} 1048575 nginx_vts_main_shm_usage_bytes{共有="使用サイズ"} 24689 nginx_vts_main_shm_usage_bytes{shared="used_node"} 7 # HELP nginx_vts_server_bytes_total リクエスト/レスポンスバイト数 # タイプ nginx_vts_server_bytes_total カウンター # HELP nginx_vts_server_requests_total リクエストカウンタ # タイプ nginx_vts_server_requests_total カウンター # HELP nginx_vts_server_request_seconds_total リクエストの処理時間(秒) # タイプ nginx_vts_server_request_seconds_total カウンター # HELP nginx_vts_server_request_seconds リクエスト処理時間の平均(秒単位) # タイプ nginx_vts_server_request_seconds ゲージ # HELP nginx_vts_server_request_duration_seconds リクエスト処理時間のヒストグラム # タイプ nginx_vts_server_request_duration_seconds ヒストグラム # HELP nginx_vts_server_cache_total リクエストキャッシュカウンタ # タイプ nginx_vts_server_cache_total カウンター # ホストの入出力トラフィック nginx_vts_server_bytes_total{host="10.160.21.205",direction="in"} 22921464 nginx_vts_server_bytes_total{ホスト="10.160.21.205",方向="out"} 1098196005 # ステータスコード別のリクエスト数 1** 2** 3** 4** 5** nginx_vts_server_requests_total{ホスト="10.160.21.205",コード="1xx"} 0 nginx_vts_server_requests_total{ホスト="10.160.21.205",コード="2xx"} 86809 nginx_vts_server_requests_total{ホスト="10.160.21.205",コード="3xx"} 0 nginx_vts_server_requests_total{ホスト="10.160.21.205",コード="4xx"} 2 nginx_vts_server_requests_total{ホスト="10.160.21.205",コード="5xx"} 0 nginx_vts_server_requests_total{ホスト="10.160.21.205",コード="合計"} 86811 # 応答時間 nginx_vts_server_request_seconds_total{host="10.160.21.205"} 0.000 nginx_vts_server_request_seconds{ホスト="10.160.21.205"} 0.000 #ステータス別のキャッシュの統計 nginx_vts_server_cache_total{host="10.160.21.205",status="miss"} 0 nginx_vts_server_cache_total{ホスト="10.160.21.205",ステータス="バイパス"} 0 nginx_vts_server_cache_total{ホスト="10.160.21.205",ステータス="期限切れ"} 0 nginx_vts_server_cache_total{ホスト="10.160.21.205",ステータス="古い"} 0 nginx_vts_server_cache_total{ホスト="10.160.21.205",ステータス="更新中"} 0 nginx_vts_server_cache_total{ホスト="10.160.21.205",ステータス="再検証済み"} 0 nginx_vts_server_cache_total{ホスト="10.160.21.205",ステータス="ヒット"} 0 nginx_vts_server_cache_total{host="10.160.21.205",status="不足"} 0 nginx_vts_server_bytes_total{ホスト="devapi.feedback.test",方向="in"} 3044526 nginx_vts_server_bytes_total{ホスト="devapi.feedback.test",方向="out"} 41257028 # 状態別の接続数の統計 nginx_vts_server_requests_total{host="devapi.feedback.test",code="1xx"} 0 nginx_vts_server_requests_total{ホスト="devapi.feedback.test",コード="2xx"} 3983 nginx_vts_server_requests_total{ホスト="devapi.feedback.test",コード="3xx"} 0 nginx_vts_server_requests_total{ホスト="devapi.feedback.test",コード="4xx"} 24 nginx_vts_server_requests_total{ホスト="devapi.feedback.test",コード="5xx"} 11 nginx_vts_server_requests_total{ホスト="devapi.feedback.test",コード="total"} 4018 nginx_vts_server_request_seconds_total{ホスト="devapi.feedback.test"} 327.173 nginx_vts_server_request_seconds{host="devapi.feedback.test"} 0.000 # nginx キャッシュ計算機、ステータスとタイプを正確に計算 nginx_vts_server_cache_total{ホスト="devapi.feedback.test",ステータス="miss"} 0 nginx_vts_server_cache_total{ホスト="devapi.feedback.test",ステータス="バイパス"} 0 nginx_vts_server_cache_total{ホスト="devapi.feedback.test",ステータス="期限切れ"} 0 nginx_vts_server_cache_total{host="devapi.feedback.test",status="stale"} 0 nginx_vts_server_cache_total{ホスト="devapi.feedback.test",ステータス="更新中"} 0 nginx_vts_server_cache_total{ホスト="devapi.feedback.test",ステータス="再検証済み"} 0 nginx_vts_server_cache_total{ホスト="devapi.feedback.test",ステータス="ヒット"} 0 nginx_vts_server_cache_total{host="devapi.feedback.test",status="scarce"} 0 nginx_vts_server_bytes_total{host="testapi.feedback.test",direction="in"} 55553573 nginx_vts_server_bytes_total{host="testapi.feedback.test",direction="out"} 9667561188 nginx_vts_server_requests_total{ホスト="testapi.feedback.test",コード="1xx"} 0 nginx_vts_server_requests_total{ホスト="testapi.feedback.test",コード="2xx"} 347949 nginx_vts_server_requests_total{ホスト="testapi.feedback.test",コード="3xx"} 31 nginx_vts_server_requests_total{ホスト="testapi.feedback.test",コード="4xx"} 7 nginx_vts_server_requests_total{ホスト="testapi.feedback.test",コード="5xx"} 33 nginx_vts_server_requests_total{host="testapi.feedback.test",code="total"} 348020 nginx_vts_server_request_seconds_total{host="testapi.feedback.test"} 2185.177 nginx_vts_server_request_seconds{host="testapi.feedback.test"} 0.001 nginx_vts_server_cache_total{host="testapi.feedback.test",status="miss"} 0 nginx_vts_server_cache_total{ホスト="testapi.feedback.test",ステータス="バイパス"} 0 nginx_vts_server_cache_total{ホスト="testapi.feedback.test",ステータス="期限切れ"} 0 nginx_vts_server_cache_total{host="testapi.feedback.test",status="stale"} 0 nginx_vts_server_cache_total{ホスト="testapi.feedback.test",ステータス="更新中"} 0 nginx_vts_server_cache_total{host="testapi.feedback.test",ステータス="再検証済み"} 0 nginx_vts_server_cache_total{ホスト="testapi.feedback.test",ステータス="ヒット"} 0 nginx_vts_server_cache_total{host="testapi.feedback.test",status="scarce"} 0 nginx_vts_server_bytes_total{host="*",direction="in"} 81519563 nginx_vts_server_bytes_total{ホスト="*",方向="out"} 10807014221 # ホスト別のリクエスト統計 nginx_vts_server_requests_total{host="*",code="1xx"} 0 nginx_vts_server_requests_total{ホスト="*",コード="2xx"} 438741 nginx_vts_server_requests_total{ホスト="*",コード="3xx"} 31 nginx_vts_server_requests_total{ホスト="*",コード="4xx"} 33 nginx_vts_server_requests_total{ホスト="*",コード="5xx"} 44 nginx_vts_server_requests_total{host="*",code="total"} 438849 nginx_vts_server_request_seconds_total{ホスト="*"} 2512.350 nginx_vts_server_request_seconds{ホスト="*"} 0.007 # ホストキャッシュ統計 nginx_vts_server_cache_total{host="*",status="miss"} 0 nginx_vts_server_cache_total{ホスト="*",ステータス="バイパス"} 0 nginx_vts_server_cache_total{ホスト="*",ステータス="期限切れ"} 0 nginx_vts_server_cache_total{host="*",status="stale"} 0 nginx_vts_server_cache_total{ホスト="*",ステータス="更新中"} 0 nginx_vts_server_cache_total{host="*",status="再検証済み"} 0 nginx_vts_server_cache_total{ホスト="*",ステータス="ヒット"} 0 nginx_vts_server_cache_total{host="*",status="scarce"} 0 # HELP nginx_vts_upstream_bytes_total リクエスト/レスポンスバイト数 # タイプ nginx_vts_upstream_bytes_total カウンター # HELP nginx_vts_upstream_requests_total アップストリームリクエストカウンタ # タイプ nginx_vts_upstream_requests_total カウンター # HELP nginx_vts_upstream_request_seconds_total アップストリームを含むリクエストの処理時間(秒単位) # タイプ nginx_vts_upstream_request_seconds_total カウンター # HELP nginx_vts_upstream_request_seconds アップストリームを含むリクエスト処理時間の平均(秒単位) # タイプ nginx_vts_upstream_request_seconds ゲージ # HELP nginx_vts_upstream_response_seconds_total 秒単位のアップストリーム応答処理時間のみ # タイプ nginx_vts_upstream_response_seconds_total カウンター # HELP nginx_vts_upstream_response_seconds アップストリーム応答処理時間のみの平均(秒単位) # タイプ nginx_vts_upstream_response_seconds ゲージ # HELP nginx_vts_upstream_request_duration_seconds アップストリームを含むリクエスト処理時間のヒストグラム # タイプ nginx_vts_upstream_request_duration_seconds ヒストグラム # HELP nginx_vts_upstream_response_duration_seconds アップストリームレスポンス処理時間のみのヒストグラム # タイプ nginx_vts_upstream_response_duration_seconds ヒストグラム # アップストリームトラフィック統計 nginx_vts_upstream_bytes_total{upstream="::nogroups",backend="10.144.227.162:80",direction="in"} 12296 nginx_vts_upstream_bytes_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80",方向="out"} 13582924 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80",コード="1xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80",コード="2xx"} 25 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80",コード="3xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80",コード="4xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80",コード="5xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80",コード="total"} 25 nginx_vts_upstream_request_seconds_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80"} 1.483 nginx_vts_upstream_request_seconds{アップストリーム="::nogroups",バックエンド="10.144.227.162:80"} 0.000 nginx_vts_upstream_response_seconds_total{アップストリーム="::nogroups",バックエンド="10.144.227.162:80"} 1.484 nginx_vts_upstream_response_seconds{アップストリーム="::nogroups",バックエンド="10.144.227.162:80"} 0.000 nginx_vts_upstream_bytes_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80",方向="in"} 12471 nginx_vts_upstream_bytes_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80",方向="out"} 11790508 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80",コード="1xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80",コード="2xx"} 24 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80",コード="3xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80",コード="4xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80",コード="5xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80",コード="total"} 24 nginx_vts_upstream_request_seconds_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80"} 1.169 nginx_vts_upstream_request_seconds{アップストリーム="::nogroups",バックエンド="10.152.218.149:80"} 0.000 nginx_vts_upstream_response_seconds_total{アップストリーム="::nogroups",バックエンド="10.152.218.149:80"} 1.168 nginx_vts_upstream_response_seconds{アップストリーム="::nogroups",バックエンド="10.152.218.149:80"} 0.000 nginx_vts_upstream_bytes_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081",方向="in"} 3036924 nginx_vts_upstream_bytes_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081",方向="out"} 33355357 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081",コード="1xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081",コード="2xx"} 3971 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081",コード="3xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081",コード="4xx"} 24 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081",コード="5xx"} 11 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081",コード="total"} 4006 nginx_vts_upstream_request_seconds_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081"} 326.427 nginx_vts_upstream_request_seconds{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081"} 0.000 nginx_vts_upstream_response_seconds_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081"} 300.722 nginx_vts_upstream_response_seconds{アップストリーム="::nogroups",バックエンド="10.160.21.205:8081"} 0.000 nginx_vts_upstream_bytes_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082",方向="in"} 55536408 nginx_vts_upstream_bytes_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082",方向="out"} 9650089427 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082",コード="1xx"} 0 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082",コード="2xx"} 347912 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082",コード="3xx"} 31 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082",コード="4xx"} 7 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082",コード="5xx"} 33 nginx_vts_upstream_requests_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082",コード="total"} 347983 nginx_vts_upstream_request_seconds_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082"} 2183.271 nginx_vts_upstream_request_seconds{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082"} 0.001 nginx_vts_upstream_response_seconds_total{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082"} 2180.893 nginx_vts_upstream_response_seconds{アップストリーム="::nogroups",バックエンド="10.160.21.205:8082"} 0.001 9. Prometheus UIでのターゲット式クエリ1) CAdvisorから得られる典型的なモニタリング指標
2) コンテナ関連 # コンテナのCPU使用率 sum(irate(container_cpu_usage_seconds_total{image!=""}[1m])) (cpu)なし # コンテナのメモリ使用量(単位:バイト) コンテナメモリ使用量バイト{画像!=""} # コンテナネットワーク受信速度(単位:バイト/秒) sum(rate(container_network_receive_bytes_total{image!=""}[1m])) (インターフェースなし) # コンテナネットワーク転送速度 sum(rate(container_network_transmit_bytes_total{image!=""}[1m])) (インターフェースなし) # コンテナファイルシステムの読み取り速度 sum(rate(container_fs_reads_bytes_total{image!=""}[1m])) (デバイスなし) # コンテナファイルシステムの書き込み速度(単位:バイト/秒) sum(rate(container_fs_writes_bytes_total{image!=""}[1m])) (デバイスなし) 3) HTTP関連 # HTTPリクエストの総数 prometheus_http_requests_total #HTTP リクエスト期間秒数バケット prometheus_http_request_duration_seconds_bucket # HTTP リクエストの継続時間(秒単位) prometheus_http_request_duration_seconds_count # HTTP リクエストの継続時間の合計(秒単位) prometheus_http_request_duration_seconds_sum # HTTP レスポンスサイズ(バイト単位) prometheus_http_response_size_bytes_bucket # HTTP レスポンスのサイズ バイト数 count prometheus_http_response_size_bytes_count # HTTPレスポンスサイズの合計バイト数 prometheus_http_response_size_bytes_sum 4) Nginx関連 # Nginxvts フィルターバイト合計 nginx_vts_filter_bytes_total # Nginx VTS フィルターキャッシュの合計 nginx_vts_filter_cache_total # Nginx VTS フィルターリクエスト秒数 nginx_vts_filter_request_seconds # Nginx VTS フィルターリクエストの合計秒数 nginx_vts_filter_request_seconds_total # Nginx VTS フィルターリクエストの総数 nginx_vts_filter_requests_total # nginx 情報 nginx_vts_info # Nginx VTS メイン接続 nginx_vts_main_connections # Nginx VTS メイン SHM 使用バイト nginx_vts_main_shm_usage_bytes # Nginx VTS サーバーの合計バイト数 nginx_vts_server_bytes_total # Nginx VTS サーバー キャッシュの合計 nginx_vts_server_cache_total # Nginx_vts サーバーリクエスト秒数 nginx_vts_server_request_seconds # Nginx_vts サーバーリクエストの合計秒数 nginx_vts_server_request_seconds_total #NGINX_VTSサービスの総数NGINX_VTS_SERVER_REQUESTS_TOTAL #nginx vts秒単位の開始時間nginx_vts_start_time_seconds 10。BlackBox_Exporterをインストールします
関数: HTTPテスト定義要求ヘッダー情報判断HTTPステータス / HTTP応答ヘッダー / HTTPボディコンテンツTCPテストビジネスコンポーネントポートステータス監視アプリケーションレイヤープロトコル定義と監視ICMPテストホスト検出メカニズム テスト後のインターフェイス接続 SSL証明書の有効期限#ダウンロードと減圧[root@11 prometheus] [root@11 prometheus]#tar -xvf blackbox_exporter-0.14.0.linux-amd64.tar.gz [root@11 prometheus] #インストールが成功しているかどうかを確認します[root@11 prometheus] Blackbox_exporter、バージョン0.14.0(Branch:Head、Revision:BBA7EF76193948A333A5868A1AB38B864F7D968A) ビルドユーザー:root@63d11aa5b6c6 ビルド日:20190315-13:32:31 GOバージョン:go1.11.5 #SystemD Management [root@11 Prometheus] #Cat /usr/lib/systemd/system/blackbox_exporter.service [ユニット] 説明= blackbox_exporter [サービス] ユーザー=root タイプ=シンプル execstart =/usr/local/blackbox_exporter/blackbox_exporter -config.file =/usr/local/blackbox_exporter/blackbox.yml 再起動=失敗時 [root@11 prometheus]# #start [root@11 prometheus] #SystemCtl Daemon-Reload [root@11 prometheus] #SystemCtl enable - now blackbox_exporter 11.DockerはNginx-Module-VTSモジュールを展開しますYumにインストールされているNginxには、デフォルトでNginx-Module-VTSモジュールがないため、対応するNginxソースコードをダウンロードして再コンパイルする必要があります。 DockerはConsul Clusterを構築します(完成していません)1。最初の協議サービスを開始:相談1 Docker run -Name Consul1 -D -P 8500:8500 -P 8300:8300 -P 8301:8301 -P 8302:8302 -P 8600:8600:Always Consul:最新のエージェント-Server -Server -Server -Server -Server -Server -Server -Serte #consult server1 docker InspectのIPアドレスを取得 - -format '{{.networksettings.ipaddress}}' Consult1 172.17.0.2 #PS: HTTPインターフェイスとWeb UI用の8500 HTTPポート 8300サーバーRPCポート、同じデータセンターコンサルテーションサーバーがこのポート8301 SERF LANポートを介して通信し、同じデータセンターコンサルテーションクライアントがこのポート8302 SERF WANポートを通じて通信し、このポート8600 DNSポートを介して通信します。 -UI:Webコンソールを実行します - バインド:ネットワークポートをリッスン、0.0.0.0はすべてのネットワークポートを意味します。 2。2番目の領事サービスを開始:Consul2とConsul1を追加します(Joinコマンドを使用) docker run -d -name consul2 -d -p 8501:8500 consul agent -server -ui -bind = 0.0.0.0 -client = 0.0.0.0 -Join 172.17.0.2 docker run -d -p 8501:8500 - Restart = Always -v/xilife/consul/data/server3:/consul/data -v/xilife/consul/confer2:/consul/consul_bind_interface XDP_DC -DATA -DIR /CONSUL /DATA -CONFIG -DIR /CONSUL /CONFIG -JOIN = 172.17.0.2 3。3番目の領事サービスを開始:Consul3とConsul1を追加 docker run -name consul3 -d -p 8502:8500 consul agent -server -ui -bind = 0.0.0.0 -client = 0.0.0.0 -Join 172.17.0.2 4.実行中のコンテナを確認します(Consul Clusterステータス) [root@k8s -m1 Consult] ノードアドレスステータスタイプビルドプロトコルDCセグメント 013A4A7E74D2 172.17.0.4:8301 Alive Server 1.10.0 2 DC1 <All> 3C118FA83D47 172.17.0.3:8301 Alive Server 1.10.0 2 DC1 <All> 4B5123C97C2B 172.17.0.5:8301 Alive Server 1.10.0 2 DC1 <All> A7D272AD157A 172.17.0.2:8301 Alive Server 1.10.0 2 DC1 <All> 5。サービス登録と削除
# 注冊241的node-exporter 服務信息curl -X PUT -d '{"id": "node-exporter","name": "node-exporter-172.23.0.241","address": "172.23.0.241","port": 9100,"tags": ["prometheus"],"checks": [{"http": "http://172.23.0.241:9100/metrics", "interval": "5s"}]}' http://172.23.0.241:8500/v1/agent/service/register #242のノードエクスポーターサービス情報を登録し、上記のすべてのIPアドレスを242に変更すると、ポートは変更されません。 サービスをログアウトする場合は、上記の curl -xはhttp:///172.23.0.241:8500/v1/agent/service/deregister/node-exporterを入れます 添付ファイル:CentOS6カーネルのアップグレード RPM -UVH https://hkg.mirror.rackspace.com/elrepo/kernel/el6/x86_64/rpms/elrepo-release-6-12.el6.elrepo.noarch.rpm YUMソースエラー応答:ミラーソースCD /ETC/YUM.REPOS.Dが見つかりません MV CENTOS-BASE.REPOCENTOS-BASE.REPO.BACKUP http://mirrors.163.com/.help/CentOS6-Base-163.repo を取得します。 mv CentOS6-Base-163.repo CentOS-Base.repo おいしい、すべてきれい wget -o/etc/yum.repos.d/centos-base.repo http://file.kangle.odata.cc/repo/centos-6.repo http://file.kangle.odata.cc/repo/ wget -o/etc/yum.repos.d/epel.repo http://file.kangle.odata.cc/repo/epel-6.repo http://file.kangle.ordata.cc/repo/epel-6.repo yum メイクキャッシュ これは、Prometheusを展開するDockerの展開に関するこの記事の終わりです。 以下もご興味があるかもしれません:
|
<<: Vue要素ツリーコントロールに点線を追加する詳細な説明
>>: ウェブページの内部アンカーポイントを実現するための純粋なCSSの上下オフセットコード例
目次1. 浅いコピー1. Object.assign(ターゲット、ソース、ソース...) 2. スプ...
【背景】最近勉強中に非常に恥ずかしいことに遭遇しました。MySQL のパスワードを忘れてしまい、My...
HTML でアンカーの位置を設定する方法はいくつかあるので、ここで紹介します。 1. ID ポジショ...
この記事の例では、vue ElementUI の非同期読み込みツリーを実装するための具体的なコードを...
目次前面に書かれた解決策 1: グローバル スタイル オーバーライドを使用する (フロントエンドに共...
この実験のテスト環境: Windows 10+cmd+MySQL5.6.36+InnoDB 1. ト...
目次1. app.vueページを修正する2. ログインページを作成する (/views/login/...
MySQLにおける静的変数の役割の詳細な説明静的変数の使用 静的変数サンプルコード: 関数テスト()...
この記事では、簡単な虫眼鏡効果を実現するためのjsの具体的なコードを参考までに共有します。具体的な内...
目次1. 開発前にエンティティの種類を決定する2. インターフェースをリクエストするときは、使用する...
まずプロジェクトの成果物を構成するスタートアップ項目の設定 Tomcatサービスを作成する開始したい...
クーパー氏は、一般的に上から下、左から右に向かうユーザーの視覚経路について話しました。優れたビジュア...
序文:私の知る限り、現在 CSS で制御できるのは、タグをホバーしたときにそのタグの下の兄弟タグとサ...
背景事業が発展するにつれ、会社の事業内容や規模は拡大し続け、ウェブサイトには大量のユーザー情報やデー...
フロートはWebページのレイアウトでよく使用されますが、フローティングブロックレベル要素は標準のドキ...