{"id":4523,"date":"2026-06-20T00:00:59","date_gmt":"2026-06-19T17:00:59","guid":{"rendered":"https:\/\/technest.com.vn\/?p=4523"},"modified":"2026-05-29T16:49:29","modified_gmt":"2026-05-29T09:49:29","slug":"prometheus","status":"publish","type":"post","link":"https:\/\/technest.com.vn\/vi\/prometheus\/","title":{"rendered":"Prometheus l\u00e0 g\u00ec? Gi\u1ea3i ph\u00e1p gi\u00e1m s\u00e1t hi\u1ec7n \u0111\u1ea1i cho DevOps"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Trong th\u1ebf gi\u1edbi DevOps ng\u00e0y c\u00e0ng ph\u1ee9c t\u1ea1p, vi\u1ec7c gi\u00e1m s\u00e1t h\u1ec7 th\u1ed1ng kh\u00f4ng c\u00f2n l\u00e0 t\u00f9y ch\u1ecdn m\u00e0 \u0111\u00e3 tr\u1edf th\u00e0nh y\u00eau c\u1ea7u b\u1eaft bu\u1ed9c. C\u00e1c \u0111\u1ed9i k\u1ef9 thu\u1eadt c\u1ea7n bi\u1ebft ch\u00ednh x\u00e1c \u0111i\u1ec1u g\u00ec \u0111ang x\u1ea3y ra b\u00ean trong h\u1ec7 th\u1ed1ng c\u1ee7a m\u00ecnh theo th\u1eddi gian th\u1ef1c &#8211; t\u1eeb t\u1ea3i CPU, l\u01b0\u1ee3ng request, \u0111\u1ed9 tr\u1ec5, cho \u0111\u1ebfn tr\u1ea1ng th\u00e1i c\u1ee7a t\u1eebng microservice. \u0110\u00e2y l\u00e0 b\u00e0i to\u00e1n m\u00e0 <a title=\"Prometheus\" href=\"https:\/\/technest.com.vn\/vi\/prometheus\/\"><strong>Prometheus<\/strong><\/a> ra \u0111\u1eddi \u0111\u1ec3 gi\u1ea3i quy\u1ebft.<\/span><\/p>\n<h2><b>Prometheus l\u00e0 g\u00ec?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Prometheus l\u00e0 m\u1ed9t h\u1ec7 th\u1ed1ng gi\u00e1m s\u00e1t m\u00e3 ngu\u1ed3n m\u1edf v\u00e0 b\u1ed9 c\u00f4ng c\u1ee5 c\u1ea3nh b\u00e1o \u0111\u01b0\u1ee3c ph\u00e1t tri\u1ec3n ban \u0111\u1ea7u b\u1edfi SoundCloud v\u00e0o n\u0103m 2012. \u0110\u1ebfn n\u0103m 2016, Prometheus tr\u1edf th\u00e0nh d\u1ef1 \u00e1n th\u1ee9 hai \u0111\u01b0\u1ee3c Cloud Native Computing Foundation (CNCF) ch\u1ea5p nh\u1eadn, ch\u1ec9 sau Kubernetes. Ng\u00e0y nay, Prometheus \u0111\u01b0\u1ee3c xem l\u00e0 ti\u00eau chu\u1ea9n ng\u00e0nh cho vi\u1ec7c gi\u00e1m s\u00e1t c\u00e1c h\u1ec7 th\u1ed1ng cloud-native v\u00e0 microservices.<\/span><\/p>\n<figure id=\"attachment_4524\" aria-describedby=\"caption-attachment-4524\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4524 size-full\" title=\"Prometheus l\u00e0 g\u00ec?\" src=\"https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-1.png\" alt=\"Prometheus l\u00e0 g\u00ec?\" width=\"600\" height=\"400\" srcset=\"https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-1.png 600w, https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-1-300x200.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><figcaption id=\"caption-attachment-4524\" class=\"wp-caption-text\">Prometheus l\u00e0 g\u00ec?<\/figcaption><\/figure>\n<p><span style=\"font-weight: 400;\">\u0110i\u1ec3m kh\u00e1c bi\u1ec7t c\u1ed1t l\u00f5i c\u1ee7a Prometheus so v\u1edbi c\u00e1c c\u00f4ng c\u1ee5 gi\u00e1m s\u00e1t truy\u1ec1n th\u1ed1ng n\u1eb1m \u1edf m\u00f4 h\u00ecnh thu th\u1eadp d\u1eef li\u1ec7u. Thay v\u00ec \u0111\u1ec3 c\u00e1c \u1ee9ng d\u1ee5ng &#8220;\u0111\u1ea9y&#8221; (push) s\u1ed1 li\u1ec7u l\u00ean m\u1ed9t server t\u1eadp trung, Prometheus ch\u1ee7 \u0111\u1ed9ng &#8220;k\u00e9o&#8221; (pull) d\u1eef li\u1ec7u t\u1eeb c\u00e1c endpoint \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a s\u1eb5n theo chu k\u1ef3 th\u1eddi gian nh\u1ea5t \u0111\u1ecbnh. D\u1eef li\u1ec7u \u0111\u01b0\u1ee3c thu th\u1eadp d\u01b0\u1edbi d\u1ea1ng <\/span><b>time-series<\/b><span style=\"font-weight: 400;\"> &#8211; t\u1ee9c l\u00e0 c\u00e1c chu\u1ed7i gi\u00e1 tr\u1ecb s\u1ed1 \u0111\u01b0\u1ee3c g\u1eafn nh\u00e3n th\u1eddi gian v\u00e0 nh\u00e3n metadata (labels), cho ph\u00e9p truy v\u1ea5n linh ho\u1ea1t v\u00e0 ph\u00e2n t\u00edch \u0111a chi\u1ec1u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Prometheus s\u1eed d\u1ee5ng ng\u00f4n ng\u1eef truy v\u1ea5n ri\u00eang g\u1ecdi l\u00e0 <\/span><b>PromQL (Prometheus Query Language)<\/b><span style=\"font-weight: 400;\"> &#8211; m\u1ed9t ng\u00f4n ng\u1eef m\u1ea1nh m\u1ebd cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng l\u1ecdc, t\u1ed5ng h\u1ee3p v\u00e0 bi\u1ec3u di\u1ec5n d\u1eef li\u1ec7u metrics theo nhi\u1ec1u c\u00e1ch kh\u00e1c nhau. Nh\u1edd PromQL, \u0111\u1ed9i k\u1ef9 thu\u1eadt c\u00f3 th\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c bi\u1ec3u \u0111\u1ed3 ph\u1ee9c t\u1ea1p, thi\u1ebft l\u1eadp ng\u01b0\u1ee1ng c\u1ea3nh b\u00e1o th\u00f4ng minh v\u00e0 ph\u00e2n t\u00edch xu h\u01b0\u1edbng h\u1ec7 th\u1ed1ng m\u1ed9t c\u00e1ch hi\u1ec7u qu\u1ea3.<\/span><\/p>\n<h2><b>Prometheus ho\u1ea1t \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 hi\u1ec3u c\u00e1ch Prometheus v\u1eadn h\u00e0nh, h\u00e3y h\u00ecnh dung m\u1ed9t v\u00f2ng l\u1eb7p li\u00ean t\u1ee5c v\u00e0 c\u00f3 h\u1ec7 th\u1ed1ng. C\u1ee9 m\u1ed7i kho\u1ea3ng th\u1eddi gian \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh (th\u01b0\u1eddng l\u00e0 15\u201330 gi\u00e2y), Prometheus server s\u1ebd g\u1eedi HTTP request \u0111\u1ebfn c\u00e1c endpoint <\/span><span style=\"font-weight: 400;\">\/metrics<\/span><span style=\"font-weight: 400;\"> c\u1ee7a t\u1eebng target \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u0103ng k\u00fd. C\u00e1c target n\u00e0y c\u00f3 th\u1ec3 l\u00e0 \u1ee9ng d\u1ee5ng web, database, server v\u1eadt l\u00fd, hay b\u1ea5t k\u1ef3 d\u1ecbch v\u1ee5 n\u00e0o \u0111\u00e3 t\u00edch h\u1ee3p th\u01b0 vi\u1ec7n Prometheus ho\u1eb7c exporter t\u01b0\u01a1ng \u1ee9ng.<\/span><\/p>\n<figure id=\"attachment_4525\" aria-describedby=\"caption-attachment-4525\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4525 size-full\" title=\"Prometheus ho\u1ea1t \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?\" src=\"https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-2.png\" alt=\"Prometheus ho\u1ea1t \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?\" width=\"600\" height=\"400\" srcset=\"https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-2.png 600w, https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-2-300x200.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><figcaption id=\"caption-attachment-4525\" class=\"wp-caption-text\">Prometheus ho\u1ea1t \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?<\/figcaption><\/figure>\n<p><span style=\"font-weight: 400;\">D\u1eef li\u1ec7u nh\u1eadn v\u1ec1 l\u00e0 c\u00e1c d\u00f2ng text theo \u0111\u1ecbnh d\u1ea1ng chu\u1ea9n, v\u00ed d\u1ee5:<\/span><\/p>\n<p><i><span style=\"font-weight: 400;\">http_requests_total{method=&#8221;GET&#8221;, status=&#8221;200&#8243;} 1027<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">http_requests_total{method=&#8221;POST&#8221;, status=&#8221;500&#8243;} 3<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">M\u1ed7i d\u00f2ng ch\u1ee9a t\u00ean metric, m\u1ed9t t\u1eadp h\u1ee3p labels (nh\u00e3n) trong ngo\u1eb7c nh\u1ecdn v\u00e0 gi\u00e1 tr\u1ecb s\u1ed1 t\u01b0\u01a1ng \u1ee9ng. Prometheus l\u01b0u to\u00e0n b\u1ed9 d\u1eef li\u1ec7u n\u00e0y v\u00e0o c\u01a1 s\u1edf d\u1eef li\u1ec7u time-series n\u1ed9i b\u1ed9 v\u1edbi timestamp c\u1ee7a th\u1eddi \u0111i\u1ec3m scrape. Theo th\u1eddi gian, h\u00e0ng tri\u1ec7u \u0111i\u1ec3m d\u1eef li\u1ec7u n\u00e0y h\u00ecnh th\u00e0nh n\u00ean c\u00e1c chu\u1ed7i l\u1ecbch s\u1eed phong ph\u00fa &#8211; n\u1ec1n t\u1ea3ng \u0111\u1ec3 ph\u00e2n t\u00edch hi\u1ec7u su\u1ea5t, ph\u00e1t hi\u1ec7n s\u1ef1 c\u1ed1 v\u00e0 d\u1ef1 b\u00e1o t\u00e0i nguy\u00ean.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Song song v\u1edbi vi\u1ec7c scrape, Prometheus li\u00ean t\u1ee5c \u0111\u00e1nh gi\u00e1 c\u00e1c <\/span><b>recording rules<\/b><span style=\"font-weight: 400;\"> v\u00e0 <\/span><b>alerting rules<\/b><span style=\"font-weight: 400;\"> \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a. Khi m\u1ed9t \u0111i\u1ec1u ki\u1ec7n c\u1ea3nh b\u00e1o \u0111\u01b0\u1ee3c k\u00edch ho\u1ea1t, Prometheus g\u1eedi th\u00f4ng b\u00e1o \u0111\u1ebfn Alertmanager \u0111\u1ec3 x\u1eed l\u00fd v\u00e0 ph\u00e2n ph\u1ed1i \u0111\u1ebfn \u0111\u00fang k\u00eanh nh\u1eadn &#8211; email, Slack, PagerDuty hay b\u1ea5t k\u1ef3 webhook n\u00e0o kh\u00e1c.<\/span><\/p>\n<h2><b>Ki\u1ebfn tr\u00fac c\u1ee7a Prometheus<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Ki\u1ebfn tr\u00fac c\u1ee7a Prometheus \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf theo h\u01b0\u1edbng <\/span><b>modular v\u00e0 phi t\u1eadp trung<\/b><span style=\"font-weight: 400;\">, trong \u0111\u00f3 m\u1ed7i th\u00e0nh ph\u1ea7n \u0111\u1ea3m nhi\u1ec7m m\u1ed9t vai tr\u00f2 ri\u00eang bi\u1ec7t nh\u01b0ng ph\u1ed1i h\u1ee3p ch\u1eb7t ch\u1ebd v\u1edbi nhau. Kh\u00f4ng c\u00f3 m\u1ed9t th\u00e0nh ph\u1ea7n \u0111\u01a1n l\u1ebb n\u00e0o l\u00e0 \u0111i\u1ec3m ch\u1ecbu l\u1ed7i duy nh\u1ea5t (single point of failure) trong m\u1ed9t h\u1ec7 th\u1ed1ng \u0111\u01b0\u1ee3c tri\u1ec3n khai \u0111\u00fang c\u00e1ch. H\u00e3y c\u00f9ng \u0111i s\u00e2u v\u00e0o t\u1eebng th\u00e0nh ph\u1ea7n c\u1ea5u th\u00e0nh n\u00ean h\u1ec7 sinh th\u00e1i Prometheus.<\/span><\/p>\n<figure id=\"attachment_4526\" aria-describedby=\"caption-attachment-4526\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4526 size-full\" title=\"Ki\u1ebfn tr\u00fac c\u1ee7a Prometheus\" src=\"https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-3.png\" alt=\"Ki\u1ebfn tr\u00fac c\u1ee7a Prometheus\" width=\"600\" height=\"400\" srcset=\"https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-3.png 600w, https:\/\/technest.com.vn\/wp-content\/uploads\/2026\/05\/prometheus-3-300x200.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><figcaption id=\"caption-attachment-4526\" class=\"wp-caption-text\">Ki\u1ebfn tr\u00fac c\u1ee7a Prometheus<\/figcaption><\/figure>\n<h3><b>Th\u01b0 vi\u1ec7n Client (Client Libraries)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Client Libraries l\u00e0 \u0111i\u1ec3m kh\u1edfi \u0111\u1ea7u c\u1ee7a to\u00e0n b\u1ed9 pipeline gi\u00e1m s\u00e1t. \u0110\u00e2y l\u00e0 c\u00e1c th\u01b0 vi\u1ec7n \u0111\u01b0\u1ee3c nh\u00fang tr\u1ef1c ti\u1ebfp v\u00e0o m\u00e3 ngu\u1ed3n \u1ee9ng d\u1ee5ng, cho ph\u00e9p developer \u0111\u1ecbnh ngh\u0129a v\u00e0 expose c\u00e1c metrics t\u00f9y ch\u1ec9nh ra endpoint <\/span><span style=\"font-weight: 400;\">\/metrics<\/span><span style=\"font-weight: 400;\">. Prometheus h\u1ed7 tr\u1ee3 ch\u00ednh th\u1ee9c c\u00e1c th\u01b0 vi\u1ec7n cho Go, Java, Python, Ruby v\u00e0 nhi\u1ec1u ng\u00f4n ng\u1eef kh\u00e1c th\u00f4ng qua c\u1ed9ng \u0111\u1ed3ng m\u00e3 ngu\u1ed3n m\u1edf. V\u1edbi Client Libraries, developer c\u00f3 th\u1ec3 theo d\u00f5i b\u1ea5t k\u1ef3 ch\u1ec9 s\u1ed1 kinh doanh n\u00e0o &#8211; t\u1eeb s\u1ed1 l\u01b0\u1ee3ng \u0111\u01a1n h\u00e0ng \u0111\u01b0\u1ee3c x\u1eed l\u00fd, th\u1eddi gian ph\u1ea3n h\u1ed3i c\u1ee7a t\u1eebng API endpoint, cho \u0111\u1ebfn s\u1ed1 l\u01b0\u1ee3ng cache hit\/miss trong h\u1ec7 th\u1ed1ng.<\/span><\/p>\n<h3><b>Exporters<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Kh\u00f4ng ph\u1ea3i l\u00fac n\u00e0o b\u1ea1n c\u0169ng c\u00f3 th\u1ec3 ch\u1ec9nh s\u1eeda m\u00e3 ngu\u1ed3n c\u1ee7a \u1ee9ng d\u1ee5ng mu\u1ed1n gi\u00e1m s\u00e1t &#8211; \u0111\u1eb7c bi\u1ec7t v\u1edbi c\u00e1c ph\u1ea7n m\u1ec1m b\u00ean th\u1ee9 ba nh\u01b0 MySQL, Redis, Nginx hay h\u1ec7 \u0111i\u1ec1u h\u00e0nh Linux. \u0110\u00e2y l\u00e0 l\u00fac Exporters ph\u00e1t huy t\u00e1c d\u1ee5ng. Exporter l\u00e0 c\u00e1c ch\u01b0\u01a1ng tr\u00ecnh trung gian ch\u1ea1y song song v\u1edbi \u1ee9ng d\u1ee5ng \u0111\u00edch, thu th\u1eadp metrics t\u1eeb c\u00e1c giao di\u1ec7n s\u1eb5n c\u00f3 (API, file h\u1ec7 th\u1ed1ng, c\u00e2u l\u1ec7nh h\u1ec7 th\u1ed1ng&#8230;) r\u1ed3i chuy\u1ec3n \u0111\u1ed5i ch\u00fang sang \u0111\u1ecbnh d\u1ea1ng Prometheus chu\u1ea9n. Node Exporter l\u00e0 v\u00ed d\u1ee5 ph\u1ed5 bi\u1ebfn nh\u1ea5t, cung c\u1ea5p h\u00e0ng tr\u0103m metrics v\u1ec1 CPU, RAM, disk I\/O v\u00e0 network c\u1ee7a m\u00e1y ch\u1ee7 Linux ch\u1ec9 v\u1edbi m\u1ed9t l\u1ec7nh kh\u1edfi \u0111\u1ed9ng \u0111\u01a1n gi\u1ea3n.<\/span><\/p>\n<h3><b>Kh\u00e1m ph\u00e1 d\u1ecbch v\u1ee5 (Service Discovery)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong m\u00f4i tr\u01b0\u1eddng \u0111\u1ed9ng nh\u01b0 Kubernetes hay cloud, danh s\u00e1ch c\u00e1c instance c\u1ea7n gi\u00e1m s\u00e1t thay \u0111\u1ed5i li\u00ean t\u1ee5c &#8211; container \u0111\u01b0\u1ee3c t\u1ea1o ra v\u00e0 h\u1ee7y b\u1ecf theo t\u1eebng gi\u00e2y. Vi\u1ec7c c\u1ea5u h\u00ecnh th\u1ee7 c\u00f4ng t\u1eebng target l\u00e0 b\u1ea5t kh\u1ea3 thi. Service Discovery gi\u1ea3i quy\u1ebft v\u1ea5n \u0111\u1ec1 n\u00e0y b\u1eb1ng c\u00e1ch cho ph\u00e9p Prometheus t\u1ef1 \u0111\u1ed9ng ph\u00e1t hi\u1ec7n c\u00e1c target m\u1edbi th\u00f4ng qua t\u00edch h\u1ee3p v\u1edbi <strong><a title=\"Kubernetes API\" href=\"https:\/\/en.wikipedia.org\/wiki\/Kubernetes\" target=\"_blank\" rel=\"nofollow noopener\">Kubernetes API<\/a><\/strong>, Consul, EC2, Azure, GCP v\u00e0 nhi\u1ec1u n\u1ec1n t\u1ea3ng kh\u00e1c. Khi m\u1ed9t pod Kubernetes m\u1edbi \u0111\u01b0\u1ee3c t\u1ea1o v\u1edbi annotation ph\u00f9 h\u1ee3p, Prometheus s\u1ebd t\u1ef1 \u0111\u1ed9ng th\u00eam n\u00f3 v\u00e0o danh s\u00e1ch scrape m\u00e0 kh\u00f4ng c\u1ea7n b\u1ea5t k\u1ef3 thao t\u00e1c th\u1ee7 c\u00f4ng n\u00e0o.<\/span><\/p>\n<h3><b>Thu th\u1eadp d\u1eef li\u1ec7u (Scraping)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Scraping l\u00e0 tr\u00e1i tim c\u1ee7a Prometheus &#8211; qu\u00e1 tr\u00ecnh m\u00e0 server \u0111\u1ecbnh k\u1ef3 g\u1eedi HTTP GET request \u0111\u1ebfn t\u1eebng target v\u00e0 thu th\u1eadp metrics tr\u1ea3 v\u1ec1. M\u1ed7i l\u1ea7n scrape th\u00e0nh c\u00f4ng t\u1ea1o ra m\u1ed9t snapshot c\u1ee7a tr\u1ea1ng th\u00e1i h\u1ec7 th\u1ed1ng t\u1ea1i th\u1eddi \u0111i\u1ec3m \u0111\u00f3. Prometheus l\u01b0u l\u1ea1i c\u1ea3 metadata v\u1ec1 qu\u00e1 tr\u00ecnh scrape nh\u01b0 <\/span><span style=\"font-weight: 400;\">up<\/span><span style=\"font-weight: 400;\"> (target c\u00f3 online kh\u00f4ng) v\u00e0 <\/span><span style=\"font-weight: 400;\">scrape_duration_seconds<\/span><span style=\"font-weight: 400;\"> (m\u1ea5t bao l\u00e2u \u0111\u1ec3 scrape), gi\u00fap \u0111\u1ed9i v\u1eadn h\u00e0nh ph\u00e1t hi\u1ec7n s\u1edbm c\u00e1c target b\u1ecb ch\u1eadm ho\u1eb7c ng\u1eebng ho\u1ea1t \u0111\u1ed9ng. Kho\u1ea3ng c\u00e1ch gi\u1eefa c\u00e1c l\u1ea7n scrape c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c \u0111i\u1ec1u ch\u1ec9nh linh ho\u1ea1t t\u1eeb v\u00e0i gi\u00e2y \u0111\u1ebfn v\u00e0i ph\u00fat t\u00f9y theo y\u00eau c\u1ea7u \u0111\u1ed9 ch\u00ednh x\u00e1c v\u00e0 t\u1ea3i h\u1ec7 th\u1ed1ng.<\/span><\/p>\n<h3><b>L\u01b0u tr\u1eef (Storage)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Prometheus s\u1eed d\u1ee5ng m\u1ed9t c\u01a1 s\u1edf d\u1eef li\u1ec7u time-series t\u00f9y ch\u1ec9nh \u0111\u01b0\u1ee3c t\u1ed1i \u01b0u \u0111\u1eb7c bi\u1ec7t cho workload gi\u00e1m s\u00e1t &#8211; ghi nhanh, n\u00e9n hi\u1ec7u qu\u1ea3 v\u00e0 truy v\u1ea5n theo kho\u1ea3ng th\u1eddi gian c\u1ef1c k\u1ef3 nhanh. D\u1eef li\u1ec7u \u0111\u01b0\u1ee3c t\u1ed5 ch\u1ee9c th\u00e0nh c\u00e1c block theo th\u1eddi gian, m\u1ed7i block ch\u1ee9a d\u1eef li\u1ec7u c\u1ee7a m\u1ed9t kho\u1ea3ng th\u1eddi gian nh\u1ea5t \u0111\u1ecbnh c\u00f9ng v\u1edbi index cho ph\u00e9p t\u00ecm ki\u1ebfm nhanh theo labels. B\u1ed9 nh\u1edb \u0111\u1ec7m (WAL &#8211; Write-Ahead Log) \u0111\u1ea3m b\u1ea3o d\u1eef li\u1ec7u kh\u00f4ng b\u1ecb m\u1ea5t khi server restart \u0111\u1ed9t ng\u1ed9t. M\u1eb7c \u0111\u1ecbnh, Prometheus l\u01b0u d\u1eef li\u1ec7u c\u1ee5c b\u1ed9 trong 15 ng\u00e0y &#8211; \u0111\u1ee7 cho h\u1ea7u h\u1ebft nhu c\u1ea7u v\u1eadn h\u00e0nh h\u00e0ng ng\u00e0y.<\/span><\/p>\n<h3><b>B\u1ea3ng \u0111i\u1ec1u khi\u1ec3n (Dashboards)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">D\u1eef li\u1ec7u metrics s\u1ebd kh\u00f4ng c\u00f3 nhi\u1ec1u gi\u00e1 tr\u1ecb n\u1ebfu kh\u00f4ng \u0111\u01b0\u1ee3c tr\u1ef1c quan h\u00f3a m\u1ed9t c\u00e1ch hi\u1ec7u qu\u1ea3. Prometheus \u0111i k\u00e8m m\u1ed9t giao di\u1ec7n Expression Browser \u0111\u01a1n gi\u1ea3n cho ph\u00e9p ch\u1ea1y PromQL query v\u00e0 xem k\u1ebft qu\u1ea3 d\u1ea1ng b\u1ea3ng ho\u1eb7c \u0111\u1ed3 th\u1ecb. Tuy nhi\u00ean, trong th\u1ef1c t\u1ebf, h\u1ea7u h\u1ebft c\u00e1c \u0111\u1ed9i k\u1ef9 thu\u1eadt k\u1ebft h\u1ee3p Prometheus v\u1edbi <\/span><b>Grafana<\/b><span style=\"font-weight: 400;\"> &#8211; c\u00f4ng c\u1ee5 dashboard m\u1ea1nh m\u1ebd nh\u1ea5t trong h\u1ec7 sinh th\u00e1i cloud-native. Grafana k\u1ebft n\u1ed1i tr\u1ef1c ti\u1ebfp v\u1edbi Prometheus l\u00e0m data source v\u00e0 cho ph\u00e9p x\u00e2y d\u1ef1ng c\u00e1c dashboard ph\u1ee9c t\u1ea1p v\u1edbi nhi\u1ec1u lo\u1ea1i bi\u1ec3u \u0111\u1ed3, b\u1ea3ng, gauge v\u00e0 alert panel, t\u1ea5t c\u1ea3 c\u00f3 th\u1ec3 chia s\u1ebb v\u00e0 t\u00e1i s\u1eed d\u1ee5ng trong to\u00e0n t\u1ed5 ch\u1ee9c.<\/span><\/p>\n<h3><b>Quy t\u1eafc ghi l\u1ea1i v\u00e0 c\u1ea3nh b\u00e1o (Recording Rules &amp; Alerts)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Recording Rules cho ph\u00e9p t\u00ednh to\u00e1n tr\u01b0\u1edbc c\u00e1c bi\u1ec3u th\u1ee9c PromQL ph\u1ee9c t\u1ea1p v\u00e0 l\u01b0u k\u1ebft qu\u1ea3 d\u01b0\u1edbi d\u1ea1ng time-series m\u1edbi. Thay v\u00ec t\u00ednh to\u00e1n l\u1ea1i m\u1ed9t aggregation ph\u1ee9c t\u1ea1p m\u1ed7i l\u1ea7n dashboard \u0111\u01b0\u1ee3c t\u1ea3i, k\u1ebft qu\u1ea3 \u0111\u00e3 \u0111\u01b0\u1ee3c t\u00ednh s\u1eb5n theo \u0111\u1ecbnh k\u1ef3, gi\u00fap gi\u1ea3m \u0111\u00e1ng k\u1ec3 th\u1eddi gian truy v\u1ea5n. Alerting Rules ho\u1ea1t \u0111\u1ed9ng theo nguy\u00ean t\u1eafc t\u01b0\u01a1ng t\u1ef1 &#8211; \u0111\u1ecbnh ngh\u0129a m\u1ed9t \u0111i\u1ec1u ki\u1ec7n PromQL v\u00e0 ng\u01b0\u1ee1ng th\u1eddi gian duy tr\u00ec (for duration). Ch\u1ec9 khi \u0111i\u1ec1u ki\u1ec7n \u0111\u01b0\u1ee3c th\u1ecfa m\u00e3n li\u00ean t\u1ee5c trong kho\u1ea3ng th\u1eddi gian \u0111\u00f3, c\u1ea3nh b\u00e1o m\u1edbi \u0111\u01b0\u1ee3c k\u00edch ho\u1ea1t, tr\u00e1nh c\u00e1c false alarm do bi\u1ebfn \u0111\u1ed9ng t\u1ee9c th\u1eddi.<\/span><\/p>\n<h3><b>Qu\u1ea3n l\u00fd c\u1ea3nh b\u00e1o (Alert Management)<\/b><\/h3>\n<p><b>Alertmanager<\/b><span style=\"font-weight: 400;\"> l\u00e0 th\u00e0nh ph\u1ea7n ri\u00eang bi\u1ec7t chuy\u00ean x\u1eed l\u00fd c\u00e1c c\u1ea3nh b\u00e1o t\u1eeb Prometheus. N\u00f3 cung c\u1ea5p c\u00e1c t\u00ednh n\u0103ng tinh vi m\u00e0 Prometheus server kh\u00f4ng c\u00f3: <\/span><b>grouping<\/b><span style=\"font-weight: 400;\"> (g\u1ed9p nhi\u1ec1u c\u1ea3nh b\u00e1o li\u00ean quan th\u00e0nh m\u1ed9t th\u00f4ng b\u00e1o duy nh\u1ea5t), <\/span><b>routing<\/b><span style=\"font-weight: 400;\"> (g\u1eedi \u0111\u00fang c\u1ea3nh b\u00e1o \u0111\u1ebfn \u0111\u00fang ng\u01b0\u1eddi\/team), <\/span><b>silencing<\/b><span style=\"font-weight: 400;\"> (t\u1eaft t\u1ea1m th\u1eddi c\u00e1c c\u1ea3nh b\u00e1o trong c\u1eeda s\u1ed5 b\u1ea3o tr\u00ec) v\u00e0 <\/span><b>inhibition<\/b><span style=\"font-weight: 400;\"> (ng\u0103n kh\u00f4ng g\u1eedi c\u1ea3nh b\u00e1o ph\u1ee5 khi c\u1ea3nh b\u00e1o ch\u00ednh \u0111\u00e3 \u0111\u01b0\u1ee3c k\u00edch ho\u1ea1t). Alertmanager h\u1ed7 tr\u1ee3 t\u00edch h\u1ee3p s\u1eb5n v\u1edbi Slack, PagerDuty, OpsGenie, email v\u00e0 nhi\u1ec1u k\u00eanh th\u00f4ng b\u00e1o kh\u00e1c th\u00f4ng qua webhook linh ho\u1ea1t.<\/span><\/p>\n<h3><b>L\u01b0u tr\u1eef d\u00e0i h\u1ea1n (Long-Term Storage)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Gi\u1edbi h\u1ea1n l\u01b0u tr\u1eef c\u1ee5c b\u1ed9 15 ng\u00e0y c\u1ee7a Prometheus \u0111\u1eb7t ra th\u00e1ch th\u1ee9c khi c\u1ea7n ph\u00e2n t\u00edch xu h\u01b0\u1edbng d\u00e0i h\u1ea1n hay tu\u00e2n th\u1ee7 y\u00eau c\u1ea7u l\u01b0u tr\u1eef d\u1eef li\u1ec7u. Prometheus gi\u1ea3i quy\u1ebft v\u1ea5n \u0111\u1ec1 n\u00e0y th\u00f4ng qua <\/span><b>Remote Write API<\/b><span style=\"font-weight: 400;\"> &#8211; cho ph\u00e9p \u0111\u1ed3ng th\u1eddi ghi d\u1eef li\u1ec7u sang c\u00e1c h\u1ec7 th\u1ed1ng l\u01b0u tr\u1eef b\u00ean ngo\u00e0i. C\u00e1c gi\u1ea3i ph\u00e1p ph\u1ed5 bi\u1ebfn bao g\u1ed3m Thanos (m\u00e3 ngu\u1ed3n m\u1edf, s\u1eed d\u1ee5ng object storage nh\u01b0 S3), Cortex (ph\u00e2n t\u00e1n, multi-tenant), VictoriaMetrics (hi\u1ec7u n\u0103ng cao, t\u00e0i nguy\u00ean th\u1ea5p) v\u00e0 nhi\u1ec1u d\u1ecbch v\u1ee5 managed kh\u00e1c. V\u1edbi ki\u1ebfn tr\u00fac n\u00e0y, b\u1ea1n c\u00f3 th\u1ec3 l\u01b0u tr\u1eef h\u00e0ng n\u0103m d\u1eef li\u1ec7u metrics trong khi v\u1eabn duy tr\u00ec kh\u1ea3 n\u0103ng truy v\u1ea5n nhanh.<\/span><\/p>\n<h2><b>Khi n\u00e0o n\u00ean s\u1eed d\u1ee5ng Prometheus<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Prometheus kh\u00f4ng ph\u1ea3i l\u00e0 gi\u1ea3i ph\u00e1p ph\u00f9 h\u1ee3p cho m\u1ecdi t\u00ecnh hu\u1ed1ng, nh\u01b0ng n\u00f3 l\u00e0 l\u1ef1a ch\u1ecdn t\u1ed1i \u01b0u trong m\u1ed9t lo\u1ea1t c\u00e1c k\u1ecbch b\u1ea3n ph\u1ed5 bi\u1ebfn c\u1ee7a DevOps hi\u1ec7n \u0111\u1ea1i.<\/span><\/p>\n<p><b>M\u00f4i tr\u01b0\u1eddng Kubernetes v\u00e0 microservices<\/b><span style=\"font-weight: 400;\"> l\u00e0 &#8220;s\u00e2n nh\u00e0&#8221; c\u1ee7a Prometheus. Khi h\u1ec7 th\u1ed1ng g\u1ed3m h\u00e0ng ch\u1ee5c \u0111\u1ebfn h\u00e0ng tr\u0103m service ch\u1ea1y tr\u00ean Kubernetes, kh\u1ea3 n\u0103ng Service Discovery t\u1ef1 \u0111\u1ed9ng v\u00e0 model pull-based c\u1ee7a Prometheus tr\u1edf th\u00e0nh l\u1ee3i th\u1ebf tuy\u1ec7t \u0111\u1ed1i. Kubernetes th\u1eadm ch\u00ed c\u00f3 Prometheus Operator &#8211; m\u1ed9t c\u00e1ch tri\u1ec3n khai v\u00e0 qu\u1ea3n l\u00fd Prometheus ho\u00e0n to\u00e0n khai b\u00e1o (declarative) th\u00f4ng qua Custom Resource Definitions.<\/span><\/p>\n<p><b>Khi c\u1ea7n c\u1ea3nh b\u00e1o th\u00f4ng minh v\u00e0 \u0111\u00e1ng tin c\u1eady<\/b><span style=\"font-weight: 400;\">, Prometheus v\u00e0 Alertmanager l\u00e0 c\u1eb7p \u0111\u00f4i ho\u00e0n h\u1ea3o. V\u1edbi kh\u1ea3 n\u0103ng \u0111\u1ecbnh ngh\u0129a ng\u01b0\u1ee1ng c\u1ea3nh b\u00e1o d\u1ef1a tr\u00ean d\u1eef li\u1ec7u l\u1ecbch s\u1eed, t\u00ednh to\u00e1n t\u1ef7 l\u1ec7 l\u1ed7i, hay ph\u00e1t hi\u1ec7n b\u1ea5t th\u01b0\u1eddng qua PromQL, \u0111\u1ed9i v\u1eadn h\u00e0nh c\u00f3 th\u1ec3 x\u00e2y d\u1ef1ng h\u1ec7 th\u1ed1ng c\u1ea3nh b\u00e1o v\u1eeba nh\u1ea1y c\u1ea3m v\u1eeba kh\u00f4ng g\u00e2y &#8220;alert fatigue&#8221;.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ng\u01b0\u1ee3c l\u1ea1i, b\u1ea1n n\u00ean c\u00e2n nh\u1eafc c\u00e1c gi\u1ea3i ph\u00e1p kh\u00e1c n\u1ebfu c\u1ea7n <\/span><b>gi\u00e1m s\u00e1t log<\/b><span style=\"font-weight: 400;\"> (Prometheus ch\u1ec9 x\u1eed l\u00fd metrics s\u1ed1, kh\u00f4ng ph\u1ea3i logs &#8211; h\u00e3y d\u00f9ng Loki ho\u1eb7c Elasticsearch cho log), ho\u1eb7c n\u1ebfu \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n ch\u1ea1y tr\u00ean m\u00f4i tr\u01b0\u1eddng kh\u00f4ng \u1ed5n \u0111\u1ecbnh n\u01a1i Prometheus kh\u00f4ng th\u1ec3 \u0111\u1ea3m b\u1ea3o scrape li\u00ean t\u1ee5c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Prometheus l\u00e0 x\u01b0\u01a1ng s\u1ed1ng c\u1ee7a observability stack hi\u1ec7n \u0111\u1ea1i. S\u1ef1 \u0111\u01a1n gi\u1ea3n trong c\u00e0i \u0111\u1eb7t, t\u00ednh m\u1ea1nh m\u1ebd c\u1ee7a PromQL, v\u00e0 h\u1ec7 sinh th\u00e1i phong ph\u00fa v\u1edbi h\u00e0ng tr\u0103m exporter s\u1eb5n c\u00f3 khi\u1ebfn n\u00f3 tr\u1edf th\u00e0nh c\u00f4ng c\u1ee5 kh\u00f4ng th\u1ec3 thi\u1ebfu trong b\u1ea5t k\u1ef3 \u0111\u1ed9i DevOps n\u00e0o nghi\u00eam t\u00fac v\u1ec1 vi\u1ec7c hi\u1ec3u v\u00e0 ki\u1ec3m so\u00e1t h\u1ec7 th\u1ed1ng c\u1ee7a m\u00ecnh.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trong th\u1ebf gi\u1edbi DevOps ng\u00e0y c\u00e0ng ph\u1ee9c t\u1ea1p, vi\u1ec7c gi\u00e1m s\u00e1t h\u1ec7 th\u1ed1ng kh\u00f4ng c\u00f2n l\u00e0 t\u00f9y ch\u1ecdn m\u00e0 \u0111\u00e3 tr\u1edf th\u00e0nh y\u00eau c\u1ea7u b\u1eaft bu\u1ed9c. C\u00e1c \u0111\u1ed9i k\u1ef9 thu\u1eadt c\u1ea7n bi\u1ebft ch\u00ednh x\u00e1c \u0111i\u1ec1u g\u00ec \u0111ang x\u1ea3y ra b\u00ean trong h\u1ec7 th\u1ed1ng c\u1ee7a m\u00ecnh theo th\u1eddi gian th\u1ef1c &#8211; t\u1eeb t\u1ea3i CPU, l\u01b0\u1ee3ng request,<\/p>\n","protected":false},"author":1,"featured_media":4529,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[84],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/posts\/4523"}],"collection":[{"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/comments?post=4523"}],"version-history":[{"count":2,"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/posts\/4523\/revisions"}],"predecessor-version":[{"id":4531,"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/posts\/4523\/revisions\/4531"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/media\/4529"}],"wp:attachment":[{"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/media?parent=4523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/categories?post=4523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/technest.com.vn\/vi\/wp-json\/wp\/v2\/tags?post=4523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}