{"id":15009,"date":"2017-12-07T09:00:08","date_gmt":"2017-12-07T00:00:08","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=15009"},"modified":"2018-11-14T16:33:42","modified_gmt":"2018-11-14T07:33:42","slug":"prometheus-monitoring-setting","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2017\/12\/07\/prometheus-monitoring-setting\/","title":{"rendered":"Prometheus \u76e3\u8996\u3092\u307e\u308b\u3063\u3068\u8a2d\u5b9a"},"content":{"rendered":"<p>\u3053\u308c\u306f <a href=\"\/blog\/2017\/11\/28\/techscore-advent-calendar-2017\/\">TECHSCORE Advent Calendar 2017<\/a>\u306e7\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n<h2>\u80cc\u666f<\/h2>\n<p>\u3053\u3093\u306b\u3061\u306f\u3002\u571f\u5c4b\u3067\u3059\u3002<br \/>\n\u7686\u3055\u3093\u306f\u30b5\u30fc\u30d0\u30fc\u76e3\u8996\u306e\u30c4\u30fc\u30eb\u3068\u3057\u3066\u4eba\u6c17\u304c\u4e0a\u304c\u3063\u3066\u304d\u3066\u3044\u308b\u3001 <a href=\"https:\/\/prometheus.io\/\">Prometheus<\/a> \u3092\u3054\u5b58\u77e5\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\n\u3069\u306e\u304f\u3089\u3044\u4eba\u6c17\u304b\u3001Google \u30c8\u30ec\u30f3\u30c9\u3067\u4ed6\u306e\u76e3\u8996\u30c4\u30fc\u30eb\u3068\u5408\u308f\u305b\u3066\u8abf\u3079\u3066\u307f\u307e\u3057\u305f(\u203b)\u3002<br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/google_trendv3-e1512451864991.png\" rel=\"facebox\"><img src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/google_trendv3-e1512451864991.png\" width=\"650\" class=\"aligncenter\" \/><\/a><br \/>\n\u203b\"[\u76e3\u8996\u30c4\u30fc\u30eb] monitoring\" \u3067\u691c\u7d22\u3057\u3066\u3044\u307e\u3059<\/p>\n<p>\u56f3\u304b\u3089\u898b\u3066\u3082\u308f\u304b\u308b\u901a\u308a\u3001Prometheus \u306e\u30d0\u30fc\u30b8\u30e7\u30f3 1.0 \u304c\u51fa\u3066\u304b\u3089\u73fe\u5728\u307e\u3067\u53f3\u80a9\u4e0a\u304c\u308a\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3053\u308c\u306f\u4f7f\u3063\u3066\u307f\u306a\u3051\u308c\u3070\uff01\u3068\u3044\u3046\u3053\u3068\u3067\u3001Prometheus \u3092\u4f7f\u3063\u3066\u30b5\u30fc\u30d0\u30fc\u76e3\u8996\u3092\u8a2d\u5b9a\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057\u79c1\u306f\u307b\u3093\u306e\uff11\u30f6\u6708\u524d\u307e\u3067\u5168\u304f\u30b5\u30fc\u30d0\u30fc\u76e3\u8996\u3092\u3057\u305f\u3053\u3068\u304c\u306a\u304f\u3001\u8a2d\u5b9a\u5468\u308a\u3067\u6163\u308c\u306c\u3053\u3068\u3082\u3042\u308a\u3001\u74b0\u5883\u69cb\u7bc9\u306b\u601d\u3044\u306e\u307b\u304b\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<br \/>\n\u57fa\u672c\u7684\u306a\u76e3\u8996\u65b9\u6cd5\u3067\u3001\u304b\u3064 Prometheus \u3084 Alertmanager \u306a\u3069\u306e\u5404\u7a2e\u8a2d\u5b9a\u304c1\u3064\u306b\u307e\u3068\u307e\u3063\u3066\u3044\u308b\u30b5\u30a4\u30c8\u304c\u3042\u308c\u3070\u3044\u3044\u306a\u3001\u3068\u601d\u3044\u4eca\u56de\u306e\u8a18\u4e8b\u3092\u66f8\u304f\u306b\u81f3\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>\u30b4\u30fc\u30eb<\/h2>\n<p>Prometheus \u3067\u76e3\u8996\u304c\u3067\u304d\u308b\u3088\u3046\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304b\u3089\u8d77\u52d5\u3001\u30b0\u30e9\u30d5\u3092\u898b\u308b\u3068\u3053\u308d\u307e\u3067\u884c\u3044\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/2a797df863d82001402e2d038c879fa2-e1512523883317.png\" rel=\"facebox\"><img src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/2a797df863d82001402e2d038c879fa2-e1512523883317.png\" width=\"650\" \/><\/a><\/p>\n<p>\u4e0a\u56f3\u306e\u3088\u3046\u306a\u8981\u671b\u304c\u3042\u3063\u305f\u3068\u3057\u3066\u3001\u3053\u308c\u3089\u306e\u8981\u671b\u3092\u6e80\u305f\u3059\u305f\u3081\u3001\u4eca\u56de\u306f\u6b21\u306e\u3088\u3046\u306a\u74b0\u5883\u69cb\u7bc9\u3092\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/da7d1d92255b33e5feaf8557f6206a77-e1512524079660.png\" rel=\"facebox\"><img src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/da7d1d92255b33e5feaf8557f6206a77-e1512524079660.png\" width=\"700\" \/><\/a><\/p>\n<p>\u306a\u304a\u3001\u74b0\u5883\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002Prometheus, Node exporter, Alertmanager Apache exporter, Blackbox exporter \u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u57f7\u7b46\u6642\u70b9\u3067\u6700\u65b0\u306e\u3082\u306e\u3067\u3059\u3002<\/p>\n<ul>\n<li>OS: macOS Sierra<\/li>\n<li>Prometheus: v2.0.0<\/li>\n<li>Node exporter: v0.15.1<\/li>\n<li>Alertmanager: v0.11.0<\/li>\n<li>Apache exporter: v0.5.0<\/li>\n<li>Blackbox exporter: v0.11.0<\/li>\n<\/ul>\n<h2>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h2>\n<p>\u516c\u5f0f\u304b\u3089\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u3001Prometheus, Node exporter, Alertmanager, Blackbox exporter\u306e\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059(<a href=\"https:\/\/prometheus.io\/download\/\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30da\u30fc\u30b8\u306f\u3053\u3061\u3089<\/a>)\u3002<\/p>\n<p>Apache exporter \u306e\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb\u306f\u3001\u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u300c<a href=\"https:\/\/prometheus.io\/docs\/instrumenting\/exporters\">EXPORTERS AND INTEGRATIONS<\/a> -&gt; Third-party exporters -&gt; <a href=\"https:\/\/prometheus.io\/docs\/instrumenting\/exporters\/#http\">HTTP<\/a>\u300d\u304b\u3089 Apache exporter \u3092\u8fbf\u308a\u3001Apache exporter\u306e<a href=\"https:\/\/github.com\/Lusitaniae\/apache_exporter\/releases\">\u30ea\u30ea\u30fc\u30b9\u30da\u30fc\u30b8<\/a>\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306f Prometheus, Alertmanager, Blackbox exporter \u306e\u307f\u3067OK\u3067\u3059\u3002<\/p>\n<h2>Prometheus \u306e\u8a2d\u5b9a<\/h2>\n<p>Prometheus \u306b\u306f\u3001\u76e3\u8996\u5bfe\u8c61\u306e\u8a2d\u5b9a\u3001\u76e3\u8996\u65b9\u6cd5\u306e\u8a2d\u5b9a\u3001\u30a2\u30e9\u30fc\u30c8\u306e\u8a2d\u5b9a\u304c\u5fc5\u8981\u3067\u3059\u3002<br \/>\n\u4eca\u56de\u306f Prometheus \u306e\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u968e\u5c64\u306b\u6b21\u306e2\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>alert_rules.yml\uff1aalert push \u3059\u308b\u6761\u4ef6\u306e\u8a2d\u5b9a<\/li>\n<li>prometheus.yml(\u203b)\uff1a\u76e3\u8996\u5bfe\u8c61\u3001\u76e3\u8996\u65b9\u6cd5\u3001alert push \u306e\u8a2d\u5b9a<\/li>\n<\/ul>\n<p>\u203b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u6642\u306b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u542b\u307e\u308c\u3066\u3044\u308b prometheus.yml \u306e\u30d5\u30a1\u30a4\u30eb\u306f\u4f7f\u308f\u306a\u3044\u306e\u3067\u3001\u9069\u5f53\u306b\u540d\u524d\u3092\u5909\u66f4\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044<\/p>\n<pre class=\"toolbar:1 decode:true\" title=\"alert_rules.yml\">groups:\r\n- name: node_exporter\r\n  rules:\r\n  # alert: \u30a2\u30e9\u30fc\u30c8\u540d\r\n  - alert: InstanceDown\r\n    # expr: alert push \u306e\u95be\u5024\r\n    # \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30c0\u30a6\u30f3 (\u4eca\u56de\u306e\u8a2d\u5b9a\u3067\u306f node_exporter, apache_exporter, blackbox_exporter \u304c\r\n    # \u8d77\u52d5\u3055\u308c\u3066\u3044\u306a\u3044\u3053\u3068\u3068\u540c\u5024) \u3092\u6761\u4ef6\u306b\u3057\u3066\u3044\u307e\u3059\r\n    expr: up == 0\r\n    # for: alert push \u306e expr \u306e\u6642\u9593\u3002\r\n    # \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30c0\u30a6\u30f3\u3057\u305f\u72b6\u614b\u304c 5 \u5206\u9593\u7d9a\u3044\u305f\u6642\u306b\u3001alert push \u3055\u308c\u307e\u3059\r\n    for: 5m \r\n    labels:\r\n      severity: critical\r\n    # annotations: \u30a2\u30e9\u30fc\u30c8\u306e\u901a\u77e5\u5185\u5bb9\r\n    annotations:\r\n      summary: \"Instance {{ $labels.instance }} down\"\r\n      description: \"{{ $labels.instance }} has been down for more than 5 minutes.\" \r\n  - alert: cpu_used\r\n    # CPU \u4f7f\u7528\u7387\u304c 90% \u3092\u8d85\u3048\u305f\u6642\u3092\u6761\u4ef6\u306b\u3057\u3066\u3044\u307e\u3059\r\n    expr: 100 * (1 - avg(rate(node_cpu{job='node',mode='idle'}[5m])) BY (instance)) &gt; 90\r\n    for: 5m\r\n    labels:\r\n      severity: critical\r\n    annotations:\r\n      summary: \"cpu {{ $labels.instance }} used over 90%\"\r\n      description: \"cpu of {{ $labels.instance }} has been used over 90% for more than 5 minutes.\"\r\n  - alert: memory_used\r\n    # \u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c 90% \u3092\u8d85\u3048\u305f\u6642\u3092\u6761\u4ef6\u306b\u3057\u3066\u3044\u307e\u3059\r\n    expr: 100 * (1 - node_memory_MemFree{job='node'} \/ node_memory_MemTotal{job='node'}) &gt; 90 \r\n    for: 5m\r\n    labels:\r\n      severity: critical\r\n    annotations:\r\n      summary: \"memory {{ $labels.instance }} used over 90%\"\r\n      description: \"memory of {{ $labels.instance }} has been used over 90% for more than 5 minutes.\"\r\n\r\n# \u30a2\u30e9\u30fc\u30c8\u306e\u30b0\u30eb\u30fc\u30d7\u306f\u8907\u6570\u6307\u5b9a\u3067\u304d\u307e\u3059\r\n- name: apache_exporter\r\n  rules:\r\n  - alert: apache_workers\r\n    # \u3053\u306e\u8a2d\u5b9a\u3067\u306f Apache \u306e worker \u30d7\u30ed\u30bb\u30b9\u304c 30 \u3092\u8d85\u3048\u305f\u6642\u3092\u6761\u4ef6\u306b\u3057\u3066\u3044\u307e\u3059\r\n    expr: apache_workers{job=\"apache\",state=\"busy\"} &gt; 30\r\n    for: 5m\r\n    labels:\r\n      severity: critical\r\n    annotations:\r\n      summary: \"apache {{ $labels.instance }} workers over 30\"\r\n      description: \"apache server {{ $labels.instance }} has been used over 30 workers for more than 5 minutes.\"\r\n\r\n- name: blackbox_exporter\r\n  rules:\r\n  - alert: http_status_200\r\n    # \u3053\u306e\u8a2d\u5b9a\u3067\u306f\u8fd4\u3063\u3066\u304d\u305f http \u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u304c 200 \u4ee5\u5916\u306e\u6642\u3092\u6761\u4ef6\u306b\u3057\u3066\u3044\u307e\u3059(\u5916\u5f62\u76e3\u8996)\r\n    expr: probe_http_status_code{job='http_200'} != 200\r\n    for: 10s\r\n    labels:\r\n      severity: critical\r\n    annotations:\r\n      summary: \"{{ $labels.instance }}: http request not return 200\"\r\n      description: \"{{ $labels.instance }} http request not return 200 for more than 10 seconds.\"<\/pre>\n<p>expr \u3067\u6307\u5b9a\u3059\u308b\u30a2\u30e9\u30fc\u30c8\u306e\u6761\u4ef6\u306f\u3001\u516c\u5f0f\u30b5\u30a4\u30c8\u306b\u8a18\u8f09\u3057\u3066\u3042\u308b<a href=\"https:\/\/prometheus.io\/docs\/prometheus\/2.0\/querying\/functions\/\">\u95a2\u6570<\/a> \u3084<a href=\"https:\/\/prometheus.io\/docs\/prometheus\/2.0\/querying\/operators\/\">\u6f14\u7b97\u5b50<\/a>\u3092\u7528\u3044\u3066\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\" title=\"prometheus.yml\">global:\r\n # scrape_interval: Prometheus\u304cexporter\u306a\u3069\u306b\u60c5\u5831\u3092\u53d6\u308a\u306b\u884c\u304f\u9593\u9694\r\n # \u4eca\u56de\u306f Prometheus \u304c \u5404\u7a2e exporter \u306b\u5bfe\u3057\u3066\u60c5\u5831\u3092 15 \u79d2\u9593\u9694\u3067\u53d6\u308a\u306b\u884c\u304d\u307e\u3059\r\n scrape_interval:     15s\r\n # evaluation_interval: \u30eb\u30fc\u30eb\u306e\u8a55\u4fa1\u3092\u884c\u3046\u9593\u9694\r\n # \u4eca\u56de\u306e\u30eb\u30fc\u30eb\u30d5\u30a1\u30a4\u30eb\u306f alert_rules.yml \u306b\u306a\u308a\u307e\u3059\r\n evaluation_interval: 15s \r\n\r\nalerting:\r\n alertmanagers:\r\n - static_configs:\r\n   # targets: alert push \u3059\u308b\u5bfe\u8c61\r\n   # \u4eca\u56de\u306f\u30ed\u30fc\u30ab\u30eb\u306e AlertManager (\u30dd\u30fc\u30c8\u756a\u53f7:9093) \u306b\u5bfe\u3057\u3066 push \u3057\u307e\u3059\r\n   - targets:\r\n     - 'localhost:9093' \r\n\r\n# prometheus \u304c\u53d6\u5f97\u3057\u305f\u60c5\u5831\u3092\u8a55\u4fa1\u3059\u308b\u30eb\u30fc\u30eb\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\r\nrule_files:\r\n - \"alert_rules.yml\"\r\n\r\n# \u76e3\u8996\u5bfe\u8c61\u306e\u8a2d\u5b9a\r\nscrape_configs:\r\n - job_name: 'node'\r\n   static_configs:\r\n     # targets: Prometheus \u304c\u60c5\u5831\u3092 pull \u3059\u308b\u5bfe\u8c61\u306e\u30db\u30b9\u30c8\u540d\u3082\u3057\u304f\u306fIP\u30a2\u30c9\u30ec\u30b9\u3068\u3001\u30dd\u30fc\u30c8\u756a\u53f7\u3092\u8a2d\u5b9a\r\n     # \u3053\u3053\u3067\u306f node_exporter (\u30dd\u30fc\u30c8\u756a\u53f7:9100) \u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\r\n     - targets:\r\n       - 'example.com:9100'\r\n\r\n - job_name: 'apache'\r\n   static_configs:\r\n     # targets: Prometheus \u304c\u60c5\u5831\u3092 pull \u3059\u308b\u5bfe\u8c61\u306e\u30db\u30b9\u30c8\u540d\u3082\u3057\u304f\u306fIP\u30a2\u30c9\u30ec\u30b9\u3068\u3001\u30dd\u30fc\u30c8\u756a\u53f7\u3092\u8a2d\u5b9a\r\n     # \u3053\u3053\u3067\u306f apache_exporter (\u30dd\u30fc\u30c8\u756a\u53f7:9117) \u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\r\n     - targets:\r\n       - 'example.com:9117'\r\n\r\n - job_name: 'http_200'\r\n   metrics_path: \/probe\r\n   params:\r\n     # \u4eca\u56de\u306f http \u30a2\u30af\u30bb\u30b9\u3092\u3059\u308b\u306e\u3067\u3001 http_2xx \u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\r\n     module: ['http_2xx']\r\n   static_configs:\r\n     # \u76e3\u8996\u5bfe\u8c61\u306e\u30b5\u30fc\u30d3\u30b9\u306eURL\u3092\u6307\u5b9a\r\n     - targets:\r\n       - 'http:\/\/example.com'\r\n   relabel_configs:\r\n     - source_labels: [__address__]\r\n       target_label: __param_target\r\n     - source_labels: [__param_target]\r\n       target_label: instance\r\n     - target_label: __address__\r\n       # Prometheus \u304c\u60c5\u5831\u3092 pull \u5bfe\u8c61\u306e\u30db\u30b9\u30c8\u540d\u3082\u3057\u304f\u306fIP\u30a2\u30c9\u30ec\u30b9\u3068\u3001\u30dd\u30fc\u30c8\u756a\u53f7\u3092\u8a2d\u5b9a\r\n       # \u3053\u3053\u3067\u306f \u30ed\u30fc\u30ab\u30eb\u306e blackbox_exporter (\u30dd\u30fc\u30c8\u756a\u53f7:9115) \u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\r\n       replacement: localhost:9115<\/pre>\n<h2>Alertmanager \u306e\u8a2d\u5b9a<\/h2>\n<p>Alertmanager \u3067\u306f\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30a2\u30e9\u30fc\u30c8\u3059\u308b\u30c4\u30fc\u30eb\u3001\u30a2\u30e9\u30fc\u30c8\u5148<\/li>\n<li>\u30a2\u30e9\u30fc\u30c8\u306e\u30b0\u30eb\u30fc\u30d7\u5316<\/li>\n<\/ul>\n<p>Prometheus \u306e\u30a2\u30e9\u30fc\u30c8\u306b\u306f\u3001\u985e\u4f3c\u3057\u305f\u30a2\u30e9\u30fc\u30c8\u30921\u3064\u306b\u307e\u3068\u3081\u308b\u30b0\u30eb\u30fc\u30d7\u5316\u306e\u6982\u5ff5\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/prometheus.io\/docs\/alerting\/alertmanager\/#grouping\">https:\/\/prometheus.io\/docs\/alerting\/alertmanager\/#grouping<\/a><\/p>\n<blockquote><p>Grouping categorizes alerts of similar nature into a single notification. This is especially useful during larger outages when many systems fail at once and hundreds to thousands of alerts may be firing simultaneously.<\/p><\/blockquote>\n<p>\u30e6\u30fc\u30b6\u30fc\u306b\u3068\u3063\u3066\u7121\u99c4\u306a\u901a\u77e5\u3092\u7701\u304f\u305f\u3081\u3001Prometheus \u306e\u30a2\u30e9\u30fc\u30c8\u3067\u306f\u3001\u540c\u3058\u7a2e\u985e\u306e\u30a2\u30e9\u30fc\u30c8\u306f\u4e00\u3064\u306b\u307e\u3068\u3081\u3066\u901a\u77e5\u3059\u308b\u306e\u304c\u826f\u3044\u3068\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u30e1\u30fc\u30eb\u3068 Slack \u5b9b\u306b\u901a\u77e5\u3092\u9001\u308b\u3088\u3046\u8a2d\u5b9a\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\nAlertmanager \u306e\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u968e\u5c64\u306b\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb alert.yml \u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\" title=\"alert.yml\">global:\r\n # Slack \u306e webhook URL \u306e\u6307\u5b9a\r\n slack_api_url: 'https:\/\/hooks.slack.com\/************'\r\n # SMTP \u63a5\u7d9a\u5148\r\n smtp_smarthost: 'localhost:25'\r\n smtp_require_tls: false\r\n # \u30a2\u30e9\u30fc\u30c8\u901a\u77e5\u4e3b\u306e\u6307\u5b9a\r\n smtp_from: 'Alertmanager &lt;alert_from@example.com&gt;'\r\n\r\nroute:\r\n # receiver: \u30eb\u30fc\u30c8\u540d\u306e\u6307\u5b9a\r\n receiver: 'test-route'\r\n # group_by: \u30a2\u30e9\u30fc\u30c8\u3092\u540c\u3058\u7a2e\u985e\u3068\u307f\u306a\u3059\u6761\u4ef6\r\n # \u3053\u306e\u5834\u5408\u3001\u30a2\u30e9\u30fc\u30c8\u540d\u3067\u5224\u5b9a\u3055\u308c\u307e\u3059\r\n group_by: [alertname]\r\n # group_wait: \u540c\u3058\u7a2e\u985e\u306e\u30a2\u30e9\u30fc\u30c8\u30921\u3064\u306e\u30a2\u30e9\u30fc\u30c8\u7fa4\u3068\u3057\u3066\u306b\u307e\u3068\u3081\u308b\u6642\u9593\r\n group_wait:      10s\r\n # group_interval: \u540c\u3058\u7a2e\u985e\u306e\u30a2\u30e9\u30fc\u30c8\u304c\u767a\u751f\u3057\u305f\u6642\u306b\u6b21\u56de\u901a\u77e5\u3059\u308b\u307e\u3067\u306e\u6642\u9593\r\n group_interval:  5m\r\n # repeat_interval:\u6b63\u5e38\u306b\u767a\u7832\u3055\u308c\u305f\u30a2\u30e9\u30fc\u30c8\u304c\u518d\u5ea6\u901a\u77e5\u3055\u308c\u308b\u307e\u3067\u306e\u6642\u9593\r\n repeat_interval: 1h\r\n\r\nreceivers:\r\n- name: 'test-route'\r\n slack_configs:\r\n # Slack \u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u540d\u306e\u6307\u5b9a\r\n - channel: '#alert_test'\r\n email_configs:\r\n # \u30e1\u30fc\u30eb\u306e\u5b9b\u5148\r\n - to: \"alert_to@example.com\"<\/pre>\n<p>\u30a2\u30e9\u30fc\u30c8\u306e\u30b0\u30eb\u30fc\u30d7\u5316\u306e\u5b9a\u7fa9\u306b\u3064\u3044\u3066\u3001\u6587\u3060\u3051\u3067\u306f\u7406\u89e3\u3057\u306b\u304f\u3044\u306e\u3067\u3001\u56f3\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/d417d36942ffc163e04e6cab21e01d92-e1512611727884.png\" rel=\"facebox\"><img src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/d417d36942ffc163e04e6cab21e01d92-e1512611727884.png\" width=\"800\" \/><\/a><\/p>\n<h2>Blackbox exporter \u306e\u8a2d\u5b9a<\/h2>\n<p>Blackbox exporter \u3067\u306f\u5916\u5f62\u76e3\u8996\u306e\u65b9\u6cd5\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\nBlackbox exporter \u306e\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u968e\u5c64\u306b\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb blackbox.yml(\u203b) \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3067\u306f\u3001http \u3092\u4f7f\u3063\u3066\u30b5\u30fc\u30d3\u30b9\u3092\u76e3\u8996\u3059\u308b\u8a2d\u5b9a\u3092\u884c\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u203b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u6642\u306b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u542b\u307e\u308c\u3066\u3044\u308b blackbox.yml \u306e\u30d5\u30a1\u30a4\u30eb\u306f\u4f7f\u308f\u306a\u3044\u306e\u3067\u3001\u9069\u5f53\u306b\u540d\u524d\u3092\u5909\u66f4\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044<\/p>\n<pre class=\"toolbar:1 decode:true\" title=\"alert.yml\">modules:\r\n  http_2xx:\r\n    # prober: \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u6307\u5b9a\r\n    prober: http\r\n    http:\r\n      # method: http\u30e1\u30bd\u30c3\u30c9\u306e\u6307\u5b9a\r\n      # GET \u3067\u30a2\u30af\u30bb\u30b9\u3057\u3066\u30b5\u30fc\u30d3\u30b9\u76e3\u8996\u3092\u884c\u3044\u307e\u3059\r\n      method: GET<\/pre>\n<h2>Apache \u306e\u8a2d\u5b9a<\/h2>\n<p>Apache exporter \u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f http:\/\/localhost\/server-status\/?auto \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001Apache \u306e\u6d3b\u52d5\u72b6\u6cc1\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/github.com\/Lusitaniae\/apache_exporter#apache-exporter-for-prometheus-\">https:\/\/github.com\/Lusitaniae\/apache_exporter#apache-exporter-for-prometheus-<\/a><\/p>\n<blockquote><p>-scrape_uri string<br \/>\nURI to apache stub status page. (default \"http:\/\/localhost\/server-status\/?auto\")<\/p><\/blockquote>\n<p>Apache exporter \u81ea\u8eab\u306e\u8a2d\u5b9a\u306f\u5fc5\u8981\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u6d3b\u52d5\u72b6\u6cc1\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b Apache \u306b mod_status \u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u8d77\u52d5<\/h2>\n<p>\u76e3\u8996\u5bfe\u8c61\u306e\u30b5\u30fc\u30d0\u30fc\u3067\u3001Node exporter, Apache exporter \u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\"># Node exporter \u306e\u8d77\u52d5 (\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb node_exporter \u304c\u3042\u308b\u3068\u3053\u308d\u3067\u5b9f\u884c)\r\n.\/node_exporter\r\n\r\n# Apache exporter \u306e\u8d77\u52d5 (\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb apache_exporter \u304c\u3042\u308b\u3068\u3053\u308d\u3067\u5b9f\u884c)\r\n.\/apache_exporter<\/pre>\n<p>\u30ed\u30fc\u30ab\u30eb\u30b5\u30fc\u30d0\u30fc\u3067 Prometheus, Alertmanager, Blackbox exporter \u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\"># Alertmanager \u306e\u8d77\u52d5 (\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb alertmanager \u304c\u3042\u308b\u3068\u3053\u308d\u3067\u5b9f\u884c)\r\n.\/alertmanager -config.file=alert.yml\r\n\r\n# Blackbox exporter \u306e\u8d77\u52d5 (blackbox_exporter \u306e\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u3068\u3053\u308d\u3067\u5b9f\u884c)\r\n.\/blackbox_exporter --config.file=blackbox.yml\r\n\r\n# Prometheus \u306e\u8d77\u52d5 (\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb prometheus \u304c\u3042\u308b\u3068\u3053\u308d\u3067\u5b9f\u884c)\r\n.\/prometheus --config.file=prometheus.yml<\/pre>\n<p>http:\/\/localhost:9090\/targets\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u76e3\u8996\u5bfe\u8c61\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/0e5f8a20e65e910f96a37c63d4f3828e-e1512452587985.png\" rel=\"facebox\"><img src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/0e5f8a20e65e910f96a37c63d4f3828e-e1512452587985.png\" width=\"800\" \/><\/a><\/p>\n<p>\u307e\u305f\u3001 Graph \u30bf\u30b0\u3092\u8868\u793a\u3057\u3001\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a55\u4fa1\u5f0f\u3092\u5165\u529b\u3057\u305f\u5f8c\u306b\u300cExecute\u300d\u3092\u62bc\u3059\u3068\u3001\u30b0\u30e9\u30d5\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br \/>\n\u4f8b\u3068\u3057\u3066\u3001CPU \u4f7f\u7528\u7387\u3092\u30b0\u30e9\u30d5\u5316\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/3ec7a9b4b673a2407cc9b57d90aed676-e1512452709689.png\" rel=\"facebox\"><img src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/3ec7a9b4b673a2407cc9b57d90aed676-e1512452709689.png\" width=\"800\" \/><\/a><br \/>\nCPU\u4f7f\u7528\u7387\u306f\u8a55\u4fa1\u5f0f\u300c100 * (1 - avg(irate(node_cpu{job='node',mode='idle'}[5m])) BY (instance))\u300d\u3067\u8868\u793a\u3067\u304d\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3067\u4f7f\u7528\u3059\u308b\u8a55\u4fa1\u5f0f\u306e\u95a2\u6570\u306f\u3001\u30eb\u30fc\u30eb\u30d5\u30a1\u30a4\u30eb\uff08alert_rules.yml\uff09\u306e expr \u306b\u8a18\u8ff0\u3057\u305f\u3082\u306e\u3068\u540c\u69d8\u306e\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u305f\u3060\u3057\u3001\u30eb\u30fc\u30eb\u30d5\u30a1\u30a4\u30eb\u3067\u306f\u6761\u4ef6\u5f0f\u3068\u3059\u308b\u305f\u3081\u306b\u4e0d\u7b49\u53f7\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u3053\u3067\u306e\u8a55\u4fa1\u5f0f\u3067\u306f\u4e0d\u7b49\u53f7\u306f\u4e0d\u8981\u3067\u3059\u3002<\/p>\n<p>\u3082\u3057\u3001CPU \u4f7f\u7528\u7387\u304c 90% \u3092\u8d85\u3048\u305f\u5834\u5408\u3001\u6b21\u306e\u3088\u3046\u306b\u30e1\u30fc\u30eb\u3068 Slack \u306b\u901a\u77e5\u304c\u6765\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/97fa77d51388678fbc89a0dc2343ae7b-e1512452845872.png\" rel=\"facebox\"><img src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/97fa77d51388678fbc89a0dc2343ae7b-e1512452845872.png\" \/><\/a><\/p>\n<p><img src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/12\/edb85c7d8ba0f212f14f9eb986096e1a.png\" width=\"650\" \/><\/p>\n<p>\u4ee5\u4e0a\u3067\u3001Prometheus \u306e\u4e00\u901a\u308a\u306e\u76e3\u8996\u8a2d\u5b9a\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u6700\u8fd1\u30db\u30c3\u30c8\u306a Prometheus \u76e3\u8996\u3092\u307e\u308b\u3063\u3068\u8a2d\u5b9a\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u53d6\u308a\u4e0a\u3052\u305f\u5185\u5bb9\u306f\u6b21\u306e\u901a\u308a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>Prometheus, Node exporter, Alertmanager, Apache exporter, Blackbox exporter \u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/li>\n<li>Prometheus \u306e\u8a2d\u5b9a\n<ul>\n<li>alert push \u3059\u308b\u6761\u4ef6\u306e\u8a2d\u5b9a<\/li>\n<li>\u76e3\u8996\u5bfe\u8c61\u3001\u76e3\u8996\u65b9\u6cd5\u3001alert push \u306e\u8a2d\u5b9a<\/li>\n<\/ul>\n<\/li>\n<li>Alertmanager \u306e\u8a2d\u5b9a\n<ul>\n<li>\u30a2\u30e9\u30fc\u30c8\u3059\u308b\u30c4\u30fc\u30eb\u3001\u30a2\u30e9\u30fc\u30c8\u5148\u3001\u30a2\u30e9\u30fc\u30c8\u306e\u30b0\u30eb\u30fc\u30d7\u5316\u306e\u8a2d\u5b9a<\/li>\n<\/ul>\n<\/li>\n<li>Blackbox exporter \u306e\u8a2d\u5b9a\n<ul>\n<li>\u5916\u5f62\u76e3\u8996\u306e\u8a2d\u5b9a<\/li>\n<\/ul>\n<\/li>\n<li>Apache exporter \u306e\u8a2d\u5b9a\n<ul>\n<li>mod_status \u306e\u8a2d\u5b9a<\/li>\n<\/ul>\n<\/li>\n<li>Prometheus, Node exporter, Alertmanager, Apache exporter, Blackbox exporter \u306e\u8d77\u52d5<\/li>\n<li>CPU \u4f7f\u7528\u7387\u306e\u7c21\u5358\u306a\u30b0\u30e9\u30d5\u5316<\/li>\n<\/ul>\n<p>\u3053\u308c\u304b\u3089 Prometheus \u3092\u4f7f\u3063\u3066\u307f\u3088\u3046\u3068\u601d\u3063\u3066\u3044\u308b\u65b9\u306b\u3001\u5c11\u3057\u3067\u3082\u53c2\u8003\u306b\u3057\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<br \/>\n\u6700\u5f8c\u307e\u3067\u8aad\u3093\u3067\u3044\u305f\u3060\u304d\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u308c\u306f TECHSCORE Advent Calendar 2017\u306e7\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<br \/>\n\u80cc\u666f<br \/>\n\u3053\u3093\u306b\u3061\u306f\u3002\u571f\u5c4b\u3067\u3059\u3002<br \/>\n\u7686\u3055\u3093\u306f\u30b5\u30fc\u30d0\u30fc\u76e3\u8996\u306e\u30c4\u30fc\u30eb\u3068\u3057\u3066\u4eba\u6c17\u304c\u4e0a\u304c\u3063\u3066\u304d\u3066\u3044\u308b\u3001 Prometheus \u3092\u3054\u5b58\u77e5\u3067\u3057\u3087\u3046\u304b\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2017\/12\/07\/prometheus-monitoring-setting\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":64,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[276],"tags":[283],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/15009"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=15009"}],"version-history":[{"count":135,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/15009\/revisions"}],"predecessor-version":[{"id":15577,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/15009\/revisions\/15577"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=15009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=15009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=15009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}