æ¦è¦
Prometheusæªçµé¨ã®éã¤ã³ãã©ã¨ã³ã¸ãã¢ããGrafanaã§ãµã¼ãã¢ãã¿ãªã³ã°ãã§ããããã«ãªãã¾ã§ã®
è»è·¡ãè¨é²ãã¾ãã
ã¨ãããããã¢ãã¿ãªã³ã°ãã§ãããã¨ãç®æ¨ãªã®ã§éç¨é¢ã®èæ
®çã¯ãã¦ãã¾ããããåèã«ãªãã°å¹¸
ãã§ãã
- æ¦è¦
- â prometheus serverã®ã¤ã³ã¹ãã¼ã«
- â¢Grafanaã®ã¤ã³ã¹ãã¼ã«
- ãã£ã¦ããã£ããã¨
- ã¾ã¨ã
ãã£ãã
æ¤è¨¼ç°å¢ã®ã¨ãããµã¼ããçªç¶æ»ãã¾ããã
ãªãæ»ãã ã®ãã¯åããã¾ããã§ããã
ã¨ããã®ããOSã¨å¿ è¦æä½éã®ããã«ã¦ã§ã¢ãã¤ã³ã¹ãã¼ã«ããã ãã®ãµã¼ãã ã£ãã®ã§ãã
ããã¯è¯ããªããªã¨æãããµã¼ããã¢ãã¿ãªã³ã°ããããªã¨æãã¾ããã
sysstatã¨ã使ãã°è¯ãã®ããããã¾ãããããã£ãããªã®ã§Prometheusã使ã£ã¦ã¿ããã¨ã«ãã¾ããã
Prometheusã¨ã¯
ã·ã¹ãã ããã³ãµã¼ãã¹ã®ã¢ãã¿ãªã³ã°ã·ã¹ãã ã§ãã
è¨å®ãããã¿ã¼ã²ããããå®æçã«ãã¼ã¿ãåéãã¦
- èç©
- å¯è¦åï¼Prometheusã§ã®å¯è¦åã¯ãä»åã¯è§¦ãã¾ããï¼
- ã¢ã©ã¼ãã®éç¥ï¼ä»åã¯è§¦ãã¾ããï¼
ãè¡ããã¨ãå¯è½ã§ãã
Grafanaã¨ã¯
Grafanaã¯ãæ§ã
ãªãã¼ã¿ã½ã¼ã¹ããåå¾ãããã¼ã¿ãå¯è¦åãããã¼ã«ã§ãã
Prometheusèªä½ã§ãå¯è¦åã¯å¯è½ã§ãããã¢ãããã¯ãªç«ã¡ä½ç½®ã§å©ç¨ããããã®ã ããã§ãã
å¯è¦åã«ã¯ãGrafanaã使ãããå ¬å¼ãµã¤ãã«è¨è¼ããã¦ãã¾ãã
ä»åæ§ç¯ããç°å¢ã®æ§æ
â prometheus server
ããããPrometheusã¨å¼ã°ãããã®ã§ãï¼ã ã¨æã£ã¦ãã¾ãï¼ã
â¡exporter
ç£è¦ã¨ã¼ã¸ã§ã³ãã§ãï¼ã ã¨æã£ã¦ãã¾ãï¼ã åå¾ãããæ å ±ã«å¿ãã¦ãexporterãã¤ã³ã¹ãã¼ã«ãã¾ãã
主ãªexporterã¯ãPrometheusã®ããã¥ã¢ã«ã«è¨è¼ããã¦ãã¾ãã
â prometheus serverãã¯ããâ¡exporterãã«å¯¾ãã¦å®æçã«æ å ±ãåå¾ãã«è¡ãããã¼ã¿ãèç©ãã¾ãã
â¢Grafana
â¢Grafanaãã¯ããâ prometheus serverããããã¼ã¿ãåå¾ããå¯è¦åãè¡ãã¾ãã
ã¤ã³ã¹ãã¼ã«
é çªã¯åå¾ãã¾ããã
- â¡exporter
- â prometheus server
- â¢Grafana
ã®é çªã§ã¤ã³ã¹ãã¼ã«ãã¾ãã
åææ¡ä»¶
- OS: AlmaLinux 8.8
â¡exporterã®ã¤ã³ã¹ãã¼ã«
ä»åã¯ããµã¼ãã®ç¶æ³ãç¥ãããã®ã§ãnode_exporterãã¤ã³ã¹ãã¼ã«ãã¾ãã
ï¼ï¼ï¼ã½ã¼ã¹ããã¦ã³ãã¼ã
Prometheusã®ãã¦ã³ãã¼ããã¼ã¸ã®ãªã³ã¯ãããnode_exporter-1.7.0.linux-amd64.tar.gzãããã¦ã³ãã¼ããã¾ããã
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
ï¼ï¼ï¼ãã¦ã³ãã¼ãããã½ã¼ã¹ã解åãã
tar xzvf node_exporter-1.7.0.linux-amd64.tar.gz
ï¼ï¼ï¼node_exporterãèµ·åãã
cd node_exporter-1.7.0.linux-amd64 ./node_exporter
ï¼ï¼ï¼node_exporterã®èµ·å確èª
node_exporterãèµ·åãã¦ãããã¨ã確èªãã¾ãã
- node_exporterã®ãã¼ãçªå·
- 9100
- exporterã®ã¨ã³ããã¤ã³ã
- /metrics
ã³ãã³ã
curl -s http://localhost:9100/metrics
å®è¡çµæ
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 3.0043e-05 go_gc_duration_seconds{quantile="0.25"} 4.12e-05 go_gc_duration_seconds{quantile="0.5"} 4.6299e-05 ã» ã» ã»
â prometheus serverã®ã¤ã³ã¹ãã¼ã«
ï¼ï¼ï¼ã½ã¼ã¹ããã¦ã³ãã¼ã
Prometheusã®ãã¦ã³ãã¼ããã¼ã¸ã®ãªã³ã¯ãããprometheus-2.45.2.linux-amd64.tar.gzãããã¦ã³ãã¼ããã¾ããã
# wget https://github.com/prometheus/prometheus/releases/download/v2.45.2/prometheus-2.45.2.linux-amd64.tar.gz
ï¼ï¼ï¼ãã¦ã³ãã¼ãããã½ã¼ã¹ã解åãã
tar xzvf prometheus-2.45.2.linux-amd64.tar.gz
ï¼ï¼ï¼Prometheusã®è¨å®ãã¡ã¤ã«ãç·¨éãã
cd prometheus-2.45.2.linux-amd64 vi prometheus.yml
prometheus.ymlãã®æ«å°¾ã«ãnode_exporterãã®æ å ±ã追è¨ãã¾ãã
- job_name: "node_exporter" static_configs: - targets: ["localhost:9100"]
ï¼ï¼ï¼prometheus serverãèµ·åãã
./prometheus --config.file=prometheus.yml
â¢Grafanaã®ã¤ã³ã¹ãã¼ã«
Grafanaã¯ã
- cloud
- on-premises
- Enterprise
- OSS
ã¨ãã£ã·ã§ã³ãããã¾ãããä»åã¯on-premisesã®OSSãã¤ã³ã¹ãã¼ã«ãã¾ãã
ï¼ï¼ï¼Grafanaã®ã¤ã³ã¹ãã¼ã«
Grafanaã®OSSãã¦ã³ãã¼ããã¼ã¸ãéã
Red Hat, CentOS, RHEL, and Fedora
ãã®ã³ãã³ããå®è¡ãã¾ãã
ä»åã¯ä»¥ä¸ã®ã³ãã³ããå®è¡ãã¾ããã
sudo dnf install -y https://dl.grafana.com/oss/release/grafana-10.3.1-1.x86_64.rpm
ï¼ï¼ï¼grafana-serverã®èµ·åã¨èµ·å確èªããã
sudo systemctl start grafana-server sudo systemctl status grafana-server
ï¼ï¼ï¼Grafanaã«ãã©ã¦ã¶ã§ã¢ã¯ã»ã¹ãã
http://<IPã¢ãã¬ã¹>:3000
ãã«ã¢ã¯ã»ã¹ãã¾ãã
Email or username
adminPassword
admin
ã§ãã°ã¤ã³ã§ãã¾ãã
â»ååãã°ã¤ã³æã«ãã¹ã¯ã¼ãã®å¤æ´ãæ±ãããã¾ãã
ãSkipãå¯è½ã§ãã
ï¼ï¼ï¼Data Sourceã®è¨å®
ç»é¢å·¦ä¸ã®ãã°ã«ã¡ãã¥ã¼ãã
- Home
- Connections
- Data sources
- Connections
ãé¸æãã¾ãã
ï¼Add new data source
ããã¯ãªãã¯ãã¦ãPrometheus
ããé¸æãã¾ãã
- Nameï¼ãä»»æã®åå
- HTTP
- Prometheus server URLï¼ã
http://<IPã¢ãã¬ã¹>:9090
- Prometheus server URLï¼ã
ãå
¥åãããSave & Test
ããã¯ãªãã¯ãã¾ãã
ï¼ï¼ï¼dashboardã®è¨å®
Grafanaã®dashboardã®è¨å®ã§ããããã³ãã¬ã¼ããå ¬éããã¦ãã¾ãã
ä»åã¯ãNode Exporter Fullã使ããã¦ããã ãã¾ããã
ç»é¢å³ä¸ã® ï¼
ããã¯ãªãã¯ãã¦ãImport dashboard
ããé¸æãã¾ãã
å ç¨ã¨ã¯ã¹ãã¼ããããã³ãã¬ã¼ããã¢ãããã¼ããã¾ãã
- Options
- Nameï¼ãä»»æã®åå
- Unique identifier(UID)ï¼ãä»»æã®å¤
- Prometheusï¼ãå
ç¨è¿½å ããã
data source
ããé¸æ
ãè¨å®ããImport
ããã¯ãªãã¯ãã¾ãã
表示ãããããã·ã¥ãã¼ãã®ä¸é¨ã§ããããã³ãã¬ã¼ããåãè¾¼ãã ãã§ç°¡åã«ã¢ãã¿ãªã³ã°ãåºæ¥ã¦ãã¾ãã
ãã£ããã£ã«ã¯å ¥ã£ã¦ãã¾ãããã
- ãã£ã¹ã¯ä½¿ç¨é
- ãã£ã¹ã¯IO
- ãã¼ãã¢ãã¬ã¼ã¸
çãã°ã©ãåããã¦ãã¾ãã
ãã£ã¦ããã£ããã¨
ãµã¼ãã®ã¢ãã¿ãªã³ã°ãã§ããããã«ãªã£ã
- çµæ§ç°¡åã«ã§ãã
- ã¤ã³ã¹ãã¼ã«ãç°¡å
- ããã·ã¥ãã¼ãã®è¨å®ããã³ãã¬ã¼ããå©ç¨ããã ã
- æ¡å¼µæ§ãé«ããã¨ãããã£ã
- exporterã追å ãããã¨ã§ãå¥ã®ã¢ãã¿ãªã³ã°ãå¯è½
- 対象ãµã¼ãã®è¿½å ã容æã«ã§ããã
- çµæ§ç°¡åã«ã§ãã
ãã£ã¹ã¯æ¯æ¸ãäºåã«æ¤ç¥ã§ãã
- æ¥ã
ãã£ã¹ã¯ä½¿ç¨éãå¢å ãã¦ãããã¨ãåãã£ã
- ä½æ¥ãã¡ã¤ã«ã®åé¤æ¼ããè¦ã¤ããå®æçã«åé¤ããããã«ãã
- æ¥ã
ãã£ã¹ã¯ä½¿ç¨éãå¢å ãã¦ãããã¨ãåãã£ã
å®è¡ããJobã®æ°ã調æ´ãã
- ã¡ã¢ãªä½¿ç¨éã確èªãé©åãªå®è¡æ°ã¨ãªããã調æ´ãã
ã¾ã¨ã
ç°å¢æ§ç¯ããã¢ãã¿ãªã³ã°ãè¡ããã¨ããã¾ã§ãç´¹ä»ãã¾ããã
ä»åã¯ã1ãµã¼ãã§1é
ç®ã ãã®ã¢ãã¿ãªã³ã°ãç´¹ä»ãã¾ãããã対象ãµã¼ããã¢ãã¿ãªã³ã°é
ç®ã®è¿½å ã
容æã«è¡ãã¾ãã®ã§ãæ°ã«ãªãæ¹ã¯ãã²è©¦ãã¦é ããã°ã¨æãã¾ãã