<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nitaoktaviani on Medium]]></title>
        <description><![CDATA[Stories by Nitaoktaviani on Medium]]></description>
        <link>https://medium.com/@nitaoktaviani2005?source=rss-c9a1232d0faf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PzFLDoIRCFLiXAXKKGWNiA.jpeg</url>
            <title>Stories by Nitaoktaviani on Medium</title>
            <link>https://medium.com/@nitaoktaviani2005?source=rss-c9a1232d0faf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 22:06:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nitaoktaviani2005/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Migrasi Kubernetes dari AWS EKS ke Azure AKS Menggunakan Velero]]></title>
            <link>https://medium.com/@nitaoktaviani2005/migrasi-kubernetes-dari-aws-eks-ke-azure-aks-menggunakan-velero-c8573e03dc83?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8573e03dc83</guid>
            <category><![CDATA[migrasi]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 08:40:00 GMT</pubDate>
            <atom:updated>2026-09-21T08:40:00.261Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Praktik migrasi workload Kubernetes lintas cloud menggunakan Velero, Amazon S3, dan Azure Managed Disk.</em></p><p>Migrasi aplikasi dari satu cloud provider ke cloud provider lain bukan hanya tentang menjalankan kembali aplikasi di cluster baru.</p><p>Ketika aplikasi berjalan di Kubernetes, ada beberapa hal yang perlu diperhatikan, seperti resource Kubernetes, persistent storage, data aplikasi, networking, serta perbedaan infrastruktur antara masing-masing cloud provider.</p><p>Pada lab ini, saya mencoba melakukan migrasi workload Kubernetes dari <strong>Amazon EKS di AWS ke Azure AKS</strong> menggunakan <strong>Velero</strong>.</p><p>Saya menguji dua skenario:</p><ul><li><strong>Stateless workload </strong>aplikasi tanpa persistent storage.</li><li><strong>Stateful workload</strong> aplikasi yang menggunakan PersistentVolume dan memiliki data yang harus dipertahankan.</li></ul><p>Untuk workload stateful, saya menggunakan <strong>File System Backup dengan Kopia</strong> untuk memindahkan data di dalam volume. Hasil migrasi kemudian divalidasi menggunakan <strong>SHA256 checksum</strong> untuk memastikan data pada sumber dan tujuan benar-benar sama.</p><h3>Kenapa Melakukan Migrasi dari EKS ke AKS?</h3><p>Ada berbagai alasan mengapa sebuah organisasi perlu memindahkan workload dari satu cloud provider ke cloud provider lainnya.</p><p>Contohnya:</p><ul><li>Migrasi workload ke cloud provider lain.</li><li>Mengurangi ketergantungan terhadap satu cloud provider.</li><li>Memindahkan workload ke environment Azure yang sudah tersedia.</li><li>Melakukan pengujian <strong>disaster recovery</strong>.</li><li>Menguji kemampuan portability sebuah workload Kubernetes.</li><li>Melakukan migrasi infrastructure secara bertahap.</li></ul><p>Namun, migrasi Kubernetes antar cloud memiliki tantangan tersendiri. Walaupun Kubernetes menggunakan standar yang sama, <strong>infrastruktur di belakang Kubernetes bisa berbeda</strong>. Pada AWS EKS, sebuah PersistentVolume dapat menggunakan:</p><pre>AWS EBS</pre><p>Sedangkan pada Azure AKS, storage yang digunakan dapat berupa:</p><pre>Azure Managed Disk</pre><p>Jadi, ketika kita melakukan migrasi workload stateful, kita tidak hanya perlu memindahkan resource Kubernetes, tetapi juga harus memastikan <strong>data di dalam volume ikut berpindah</strong>.</p><h3>Kenapa Menggunakan Velero?</h3><p>Untuk melakukan proses backup dan restore, saya menggunakan <strong>Velero</strong>. Velero merupakan tool open source yang dapat digunakan untuk melakukan:</p><ul><li>Backup resource Kubernetes.</li><li>Restore resource Kubernetes.</li><li>Backup persistent data.</li><li>Restore persistent data.</li><li>Migrasi workload Kubernetes.</li></ul><p>Dalam lab ini, Velero digunakan sebagai jembatan antara cluster AWS dan Azure. Alurnya:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0vtN0LrHseJ7zAzm9ffoxQ.png" /></figure><p>Jadi, EKS dan AKS tidak perlu melakukan copy workload secara langsung. EKS bertindak sebagai cluster sumber yang membuat backup, sedangkan AKS membaca backup tersebut dan melakukan restore.</p><h3>Persiapan</h3><p>Sebelum melakukan migrasi, ada beberapa komponen yang perlu disiapkan:</p><ul><li>AWS EKS</li><li>Azure AKS</li><li>Amazon S3</li><li>AWS IAM</li><li>Velero CLI</li></ul><h4>Membuat IAM User untuk Velero</h4><p>Velero membutuhkan permission untuk membaca dan menulis backup ke S3. Buat IAM User:</p><pre>aws iam create-user \<br>  --user-name velero-eks-aks-nita</pre><p>Command ini digunakan untuk:</p><p>Membuat IAM User yang nantinya digunakan oleh Velero untuk mengakses S3.</p><p>Kemudian buat policy:</p><pre>cat &gt; /tmp/velero-s3-policy.json &lt;&lt;&#39;EOF&#39;<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:ListBucket&quot;,<br>        &quot;s3:GetBucketLocation&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::poc-migrasi-eks-aks&quot;<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:GetObject&quot;,<br>        &quot;s3:PutObject&quot;,<br>        &quot;s3:DeleteObject&quot;,<br>        &quot;s3:AbortMultipartUpload&quot;,<br>        &quot;s3:ListMultipartUploadParts&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::poc-migrasi-eks-aks/*&quot;<br>    }<br>  ]<br>}<br>EOF</pre><p>Policy tersebut memberikan permission kepada Velero untuk mengakses bucket dan object di dalam S3.</p><p>Attach policy ke IAM User:</p><pre>aws iam put-user-policy \<br>  --user-name velero-eks-aks-nita \<br>  --policy-name velero-s3-access \<br>  --policy-document file:///tmp/velero-s3-policy.json</pre><p>Kemudian buat access key:</p><pre>aws iam create-access-key \<br>  --user-name velero-eks-aks-nita</pre><h4>Install Velero CLI</h4><p>Tentukan versi Velero:</p><pre>VELERO_VERSION=&quot;1.18.0&quot;<br>VELERO_ARCH=&quot;amd64&quot;</pre><p>Download Velero:</p><pre>curl -fL \<br>  &quot;https://github.com/vmware-tanzu/velero/releases/download/v${VELERO_VERSION}/velero-v${VELERO_VERSION}-linux-${VELERO_ARCH}.tar.gz&quot; \<br>  -o &quot;$HOME/velero.tar.gz&quot;</pre><p>Extract:</p><pre>tar -xzf &quot;$HOME/velero.tar.gz&quot; -C &quot;$HOME&quot;</pre><p>Buat directory untuk binary:</p><pre>mkdir -p &quot;$HOME/.local/bin&quot;</pre><p>Install Velero:</p><pre>install -m 0755 \<br>  &quot;$HOME/velero-v${VELERO_VERSION}-linux-${VELERO_ARCH}/velero&quot; \<br>  &quot;$HOME/.local/bin/velero&quot;</pre><p>Tambahkan ke PATH:</p><pre>export PATH=&quot;$HOME/.local/bin:$PATH&quot;</pre><p>Kemudian cek:</p><pre>velero version --client-only</pre><p><strong>Tujuannya:</strong> memastikan Velero CLI sudah berhasil di-install.</p><h4>Install Velero di EKS</h4><p>EKS akan menjadi <strong>cluster sumber</strong>.</p><p>Install Velero:</p><pre>velero --kubecontext eks-singapore-136 install \<br>  --namespace velero \<br>  --image velero/velero:v1.18.0 \<br>  --provider aws \<br>  --plugins velero/velero-plugin-for-aws:v1.14.0 \<br>  --bucket poc-migrasi-eks-aks \<br>  --backup-location-config region=ap-southeast-1 \<br>  --secret-file &quot;$HOME/credentials-velero&quot; \<br>  --use-volume-snapshots=false \<br>  --wait</pre><p>Beberapa parameter penting:</p><pre>--provider aws</pre><p>Menggunakan AWS sebagai provider.</p><pre>--bucket poc-migrasi-eks-aks</pre><p>Menentukan S3 bucket yang digunakan untuk menyimpan backup.</p><pre>--secret-file</pre><p>Menentukan file credential yang digunakan untuk mengakses AWS.</p><pre>--use-volume-snapshots=false</pre><p>Menonaktifkan volume snapshot karena target migrasi berada di cloud provider yang berbeda.</p><h4>Install Velero di AKS</h4><p>Pertama, ambil credential AKS:</p><pre>az aks get-credentials \<br>  --resource-group rg-lcep-dev \<br>  --name lcep-lab \<br>  --overwrite-existing</pre><p>Kemudian install Velero:</p><pre>velero --kubecontext lcep-lab install \<br>  --namespace velero \<br>  --image velero/velero:v1.18.0 \<br>  --provider aws \<br>  --plugins velero/velero-plugin-for-aws:v1.14.0 \<br>  --bucket poc-migrasi-eks-aks \<br>  --backup-location-config region=ap-southeast-1 \<br>  --secret-file &quot;$HOME/credentials-velero&quot; \<br>  --use-volume-snapshots=false \<br>  --wait</pre><p>Karena AKS hanya digunakan sebagai tujuan restore, BackupStorageLocation dibuat menjadi <strong>ReadOnly</strong>:</p><pre>kubectl --context lcep-lab \<br>  -n velero patch backupstoragelocation default \<br>  --type merge \<br>  -p &#39;{&quot;spec&quot;:{&quot;accessMode&quot;:&quot;ReadOnly&quot;}}&#39;</pre><h3>Migrasi Stateless</h3><p>Sekarang kita mulai dengan workload yang sederhana. Aplikasi yang digunakan adalah:</p><pre>nginx-demo</pre><p>Aplikasi ini memiliki:</p><pre>Deployment<br>   │<br>   ├── Pod<br>   └── Pod<br>       <br>Service</pre><p>Tidak ada PersistentVolume. Karena tidak ada data persistent, kita hanya perlu melakukan backup dan restore resource Kubernetes.</p><h4><strong>A. Deploy Aplikasi</strong></h4><p>Deploy aplikasi ke EKS:</p><pre>kubectl --context eks-singapore-136 \<br>  apply -f nginx-demo.yaml</pre><p>Cek Pod dan Service:</p><pre>kubectl --context eks-singapore-136 \<br>  get pods,svc -l app=nginx-demo</pre><p><strong>Tujuan:</strong> memastikan aplikasi berjalan dengan normal sebelum backup.</p><p><em>Note: ini hanya contoh deployment nya saja.</em></p><h4>B. Buat Backup</h4><p>Buat backup menggunakan Velero:</p><pre>velero --kubecontext eks-singapore-136 \<br>  backup create nginx-demo-backup \<br>  --include-namespaces default \<br>  --snapshot-volumes=false \<br>  --wait</pre><p>Backup akan diberi nama:</p><pre>nginx-demo-backup</pre><p><strong>Tujuan:</strong> menyimpan resource Kubernetes aplikasi ke backup storage.</p><h4>C. Cek Backup</h4><p>Cek detail backup:</p><pre>velero --kubecontext eks-singapore-136 \<br>  backup describe nginx-demo-backup \<br>  --details</pre><p>Kemudian cek dari AKS:</p><pre>velero --kubecontext lcep-lab \<br>  backup get</pre><p>Kalau backup sudah terlihat dari AKS, berarti AKS berhasil membaca backup yang dibuat oleh EKS melalui S3.</p><h4>D. Restore ke AKS</h4><p>Sekarang lakukan restore:</p><pre>velero --kubecontext lcep-lab \<br>  restore create nginx-demo-restore \<br>  --from-backup nginx-demo-backup \<br>  --wait</pre><p>Kemudian cek resource:</p><pre>kubectl --context lcep-lab \<br>  get deployment,pods,svc \<br>  -l app=nginx-demo</pre><p>Aplikasi sekarang sudah berhasil dibuat kembali di AKS.</p><p>Untuk stateless workload, prosesnya cukup sederhana:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AgPnqlE-6lct1sj7d6TYyA.png" /></figure><h3>Migrasi Stateful</h3><p>Selanjutnya kita masuk ke skenario yang lebih kompleks. Pada workload stateful, aplikasi memiliki data persistent.</p><p>Arsitekturnya:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jY4x0HPTStqk7WDTmMbMg.png" /></figure><p>Ketika workload dipindahkan ke AKS, storagenya berubah:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7sQGRDN4c28In9ZcyXDRCQ.png" /></figure><h4>Menyiapkan EBS CSI Driver</h4><p>Pertama, EKS perlu memiliki AWS EBS CSI Driver. Associate OIDC provider:</p><pre>eksctl utils associate-iam-oidc-provider \<br>  --cluster eks-singapore-136 \<br>  --region ap-southeast-1 \<br>  --approve</pre><p>Kemudian buat IAM service account:</p><pre>eksctl create iamserviceaccount \<br>  --cluster eks-singapore-136 \<br>  --region ap-southeast-1 \<br>  --namespace kube-system \<br>  --name ebs-csi-controller-sa \<br>  --role-name EKS-eks-singapore-136-EBS-CSI-Role \<br>  --attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \<br>  --role-only \<br>  --approve</pre><p>Buat EBS CSI add on:</p><pre>aws eks create-addon \<br>  --cluster-name eks-singapore-136 \<br>  --region ap-southeast-1 \<br>  --addon-name aws-ebs-csi-driver \<br>  --service-account-role-arn &quot;$EBS_CSI_ROLE_ARN&quot;</pre><h4>Membuat StorageClass</h4><p>Buat StorageClass untuk EBS:</p><pre>kubectl --context eks-singapore-136 apply -f - &lt;&lt;&#39;EOF&#39;<br>apiVersion: storage.k8s.io/v1<br>kind: StorageClass<br>metadata:<br>  name: gp3-migration<br>provisioner: ebs.csi.aws.com<br>parameters:<br>  type: gp3<br>  csi.storage.k8s.io/fstype: ext4<br>reclaimPolicy: Delete<br>allowVolumeExpansion: true<br>volumeBindingMode: WaitForFirstConsumer<br>EOF</pre><p>StorageClass ini menggunakan:</p><pre>AWS EBS gp3</pre><h4>Mengaktifkan File System Backup</h4><p>Untuk memindahkan data di dalam volume, Velero dijalankan dengan Node Agent dan File System Backup:</p><pre>velero --kubecontext eks-singapore-136 install \<br>  --namespace velero \<br>  --image velero/velero:v1.18.0 \<br>  --provider aws \<br>  --plugins velero/velero-plugin-for-aws:v1.14.0 \<br>  --bucket poc-migrasi-eks-aks \<br>  --backup-location-config region=ap-southeast-1 \<br>  --secret-file &quot;$HOME/credentials-velero&quot; \<br>  --use-volume-snapshots=false \<br>  --use-node-agent \<br>  --default-volumes-to-fs-backup \<br>  --wait</pre><p>Dua parameter yang penting:</p><pre>--use-node-agent<br>--default-volumes-to-fs-backup</pre><p>Digunakan untuk melakukan backup data volume pada level filesystem.</p><h4>Menyiapkan Password Kopia</h4><p>File System Backup menggunakan repository Kopia. Password repository harus <strong>sama persis di EKS dan AKS</strong>.</p><pre>read -r -s -p &quot;Password repository: &quot; \<br>  VELERO_REPO_PASSWORD<br>echo</pre><p>Simpan password:</p><pre>printf &#39;%s&#39; &quot;$VELERO_REPO_PASSWORD&quot; \<br>  &gt; &quot;$HOME/velero-repo-password&quot;</pre><p>Buat Secret:</p><pre>kubectl --context eks-singapore-136 \<br>  -n velero \<br>  create secret generic velero-repo-credentials \<br>  --from-file=repository-password=&quot;$HOME/velero-repo-password&quot; \<br>  --dry-run=client -o yaml \<br>  | kubectl --context eks-singapore-136 apply -f -</pre><p>Secret yang sama perlu dibuat di AKS menggunakan password yang sama.</p><h4>Mapping StorageClass</h4><p>Ini merupakan salah satu bagian penting dalam migrasi antar cloud.</p><p>Di EKS:</p><pre>gp3-migration</pre><p>Di AKS:</p><pre>managed-csi</pre><p>Maka kita perlu memberi tahu Velero bahwa:</p><pre>gp3-migration → managed-csi</pre><p>Buat ConfigMap:</p><pre>kubectl --context lcep-lab apply -f - &lt;&lt;&#39;EOF&#39;<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: change-storage-class-config<br>  namespace: velero<br>  labels:<br>    velero.io/plugin-config: &quot;&quot;<br>    velero.io/change-storage-class: RestoreItemAction<br>data:<br>  gp3-migration: managed-csi<br>EOF</pre><p>Dengan mapping ini, ketika PVC dari EKS direstore ke AKS, StorageClass-nya akan diarahkan ke managed-csi</p><h4>Deploy Aplikasi Stateful</h4><p>Sekarang deploy aplikasi yang memiliki PVC.</p><p>Strukturnya:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_QXkV0l-qUWDvOJKaKMgvA.png" /></figure><p>PVC menggunakan:</p><pre>StorageClass: gp3-migration<br>Storage: 1Gi</pre><p>Volume kemudian di mount ke:</p><pre>/usr/share/nginx/html</pre><h4>Membuat Data Uji</h4><p>Untuk memastikan data benar-benar ikut berpindah, saya membuat file HTML di dalam PVC:</p><pre>kubectl --context eks-singapore-136 \<br>  -n migration-stateful-demo \<br>  exec -i deployment/web-stateful \<br>  -- sh -c &#39;cat &gt; /usr/share/nginx/html/index.html&#39; &lt;&lt;&#39;EOF&#39;<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Data dari PVC EKS&lt;/h1&gt;<br>&lt;p&gt;Kode: STATEFUL-TEST-001&lt;/p&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>EOF</pre><p>Sekarang kita memiliki data yang bisa dibandingkan sebelum dan sesudah migrasi.</p><h4>Cek Data Sebelum Migrasi</h4><p>Hitung checksum file:</p><pre>kubectl --context eks-singapore-136 \<br>  -n migration-stateful-demo \<br>  exec deployment/web-stateful \<br>  -- sha256sum /usr/share/nginx/html/index.html</pre><p>Checksum ini menjadi <strong>baseline dari data sumber</strong>.</p><h4>Backup Workload Stateful</h4><p>Buat backup:</p><pre>velero --kubecontext eks-singapore-136 \<br>  backup create web-stateful-backup \<br>  --include-namespaces migration-stateful-demo \<br>  --snapshot-volumes=false \<br>  --default-volumes-to-fs-backup=true \<br>  --wait</pre><p>Cek PodVolumeBackup:</p><pre>kubectl --context eks-singapore-136 \<br>  -n velero \<br>  get podvolumebackups \<br>  -l velero.io/backup-name=web-stateful-backup \<br>  -o wide</pre><p>Command tersebut digunakan untuk memastikan data volume sudah ikut diproses oleh Velero.</p><h4>Restore ke AKS</h4><p>Sekarang restore:</p><pre>velero --kubecontext lcep-lab \<br>  restore create web-stateful-restore \<br>  --from-backup web-stateful-backup \<br>  --wait</pre><p>Cek Pod dan PVC:</p><pre>kubectl --context lcep-lab \<br>  -n migration-stateful-demo \<br>  get pods,pvc</pre><p>PVC yang sebelumnya menggunakan:</p><pre>gp3-migration</pre><p>akan menggunakan:</p><pre>managed-csi</pre><p>di AKS.</p><p>Dengan demikian, data dari AWS EBS dipulihkan ke storage Azure Managed Disk.</p><h4>Validasi Data</h4><p>Sekarang kita cek apakah data yang dipindahkan benar-benar sama.</p><p>Hitung checksum di AKS:</p><pre>kubectl --context lcep-lab \<br>  -n migration-stateful-demo \<br>  exec deployment/web-stateful \<br>  -- sha256sum /usr/share/nginx/html/index.html</pre><p>Hasil dari lab:</p><pre>Sumber (EKS):<br>a8dcf4dd20d326e73754d5527091880cff194fb8a126ed8b4196d13f191b23d0<br><br>Tujuan (AKS):<br>a8dcf4dd20d326e73754d5527091880cff194fb8a126ed8b4196d13f191b23d0</pre><p>Hasilnya <strong>sama persis</strong>.</p><p>Artinya, file yang berada di volume EKS berhasil dipulihkan ke AKS dengan isi yang identik.</p><h3>Hasil Akhir</h3><p>Secara keseluruhan, proses migrasinya adalah:</p><h4>Stateless</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SeTTVkVq0bRTfV6ysVuIeQ.png" /></figure><h4>Stateful</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xhV_3nHReB5G1DWuqWA_oQ.png" /></figure><p>Pada workload stateful, migrasi tidak hanya berhasil pada level Kubernetes resource, tetapi juga berhasil memindahkan data persistent. Validasi SHA256 menunjukkan checksum sumber dan tujuan identik.</p><h3>Kesimpulan</h3><p>Dari percobaan ini, saya mendapatkan gambaran bahwa migrasi Kubernetes antar-cloud membutuhkan lebih dari sekadar memindahkan manifest YAML.</p><p>Untuk <strong>stateless workload</strong>, prosesnya relatif sederhana karena tidak ada persistent data yang harus dipindahkan.</p><p>Sedangkan untuk <strong>stateful workload</strong>, kita perlu memperhatikan:</p><ul><li>PersistentVolume</li><li>StorageClass</li><li>Storage backend</li><li>File System Backup</li><li>Repository Kopia</li><li>Mapping StorageClass antara cloud provider</li><li>Validasi data setelah restore</li></ul><p>Yang paling penting dari lab ini adalah <strong>validasi setelah migrasi</strong>. Pod yang berhasil Running belum tentu berarti data berhasil dipindahkan dengan benar. Karena itu, saya menggunakan SHA256 checksum untuk membandingkan data sumber dan tujuan.</p><p>Pada percobaan ini, checksum EKS dan AKS <strong>identik</strong>, sehingga data yang diuji berhasil dimigrasikan dengan isi yang sama.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8573e03dc83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Aplikasi Python dari GitHub Tanpa Build Docker Manual dengan AppLaunch]]></title>
            <link>https://medium.com/@nitaoktaviani2005/deploy-aplikasi-python-dari-github-tanpa-build-docker-manual-dengan-applaunch-716a332f95a8?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/716a332f95a8</guid>
            <category><![CDATA[app-launch]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 15:28:44 GMT</pubDate>
            <atom:updated>2026-09-11T15:28:44.411Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dy-Za1Zxt62R9aZ8ozkwRw.png" /></figure><p>Kalau biasanya kita melakukan deployment aplikasi menggunakan Docker, ada beberapa proses yang perlu dilakukan mulai dari <strong>build image, push image ke container registry, menjalankan container, sampai mengatur deployment dan scaling</strong>.</p><p>Nah, <strong>AppLaunch</strong> hadir sebagai platform yang menyederhanakan proses tersebut. Secara sederhana, AppLaunch adalah <strong>container application platform</strong> yang memungkinkan kita menjalankan dan melakukan deployment aplikasi berbasis container tanpa harus mengelola seluruh infrastructure secara manual.</p><p>Kita bisa melakukan deployment dari <strong>Docker image maupun repository GitHub</strong>, kemudian AppLaunch menangani proses build, deployment, container registry, resource allocation, hingga fitur seperti autoscaling, monitoring, versioning, dan custom domain.</p><p>Jadi kalau biasanya workflow deployment saya cukup panjang, dengan AppLaunch prosesnya bisa dibuat jauh lebih sederhana.</p><h4>Project yang Saya Gunakan</h4><p>Untuk mencoba AppLaunch, saya menggunakan sebuah <strong>Python Login App</strong> yang saya simpan di GitHub. Aplikasi ini membutuhkan <strong>PostgreSQL</strong> sebagai database dan berjalan pada port 5000.</p><p>Untuk databasenya, saya menggunakan template PostgreSQL yang sudah tersedia di AppLaunch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xDWl-on__N1Y7HE4DT1ipg.png" /></figure><p>Dari template tersebut, PostgreSQL dapat langsung di deploy dengan konfigurasi resource, credential, dan connection string yang sudah disediakan.</p><h4>Deploy Langsung dari GitHub</h4><p>Hal yang pertama saya coba adalah fitur <strong>Deploy from GitHub</strong>. Saya cukup menghubungkan repository GitHub yang berisi aplikasi Python saya. <strong>Repository tersebut harus memiliki </strong><strong>Dockerfile di root karena AppLaunch menggunakan Dockerfile tersebut sebagai dasar untuk melakukan build image.</strong></p><p>Setelah repository terhubung, saya tinggal menentukan nama service, container port, dan resource yang dibutuhkan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ziXm6sOLMzptGhy9r5gTDw.png" /></figure><p>Biasanya setelah memiliki source code dan Dockerfile, saya masih perlu melakukan docker build, tagging image, kemudian docker push ke registry.</p><p>Dengan AppLaunch, proses tersebut tidak perlu dilakukan secara manual. AppLaunch akan menjalankan proses <strong>Docker build berdasarkan Dockerfile</strong>, kemudian secara otomatis melakukan push image ke <strong>private registry</strong> AppLaunch dan melanjutkan proses deployment. Jadi, <strong>Dockerfile tetap kita siapkan, tetapi proses build, push ke registry, dan deploymentnya ditangani oleh AppLaunch.</strong></p><h4>Automatic Build &amp; Private Container Registry</h4><p>Setelah deployment dijalankan, AppLaunch melakukan proses cloning repository, build aplikasi, kemudian push image ke registry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9UQmrQHlNpex4XOcpR_B4w.png" /></figure><p>Image hasil build tersebut kemudian tersimpan di <strong>private container registry</strong> yang disediakan oleh AppLaunch.</p><p>Menurut saya, ini cukup menarik karena kita tidak hanya menghindari proses build dan push image secara manual, tetapi juga sudah mendapatkan container registry yang terintegrasi dengan platform.</p><h4>Deployment &amp; Custom Domain</h4><p>Setelah proses build selesai, aplikasi Python saya berhasil berjalan sebagai service di AppLaunch. AppLaunch juga memberikan <strong>HTTPS endpoint secara otomatis</strong>, sehingga aplikasi dapat langsung diakses melalui browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TwXDfK0PIzfe8mMjEyAYSw.png" /></figure><p>Selain menggunakan URL bawaan AppLaunch, kita juga dapat menggunakan <strong>custom domain</strong> untuk mengakses aplikasi dengan domain milik sendiri.</p><h4>Autoscaling</h4><p>AppLaunch juga menyediakan fitur <strong>Autoscaling</strong>. Kita dapat menentukan minimum dan maksimum replica.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JBej_qVyRHFYePqsKTNggg.png" /></figure><p>Konsepnya cukup familiar jika sebelumnya pernah menggunakan Kubernetes HPA, yaitu menambah jumlah instance ketika penggunaan resource meningkat.</p><h4>Versioning &amp; Deployment</h4><p>Setiap deployment juga memiliki version sehingga perubahan deployment dapat dilacak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKIpRdyukvb-XmUVQXWfTA.png" /></figure><p>Hal ini menurut saya cukup membantu ketika melakukan update aplikasi karena versi sebelumnya masih dapat dilacak dan proses recovery menjadi lebih terstruktur.</p><h3>Kesimpulan</h3><p>Setelah mencoba AppLaunch, hal yang paling saya rasakan adalah <strong>simplicity</strong>.</p><p>Sebelumnya, saya terbiasa melakukan proses deployment secara bertahap, mulai dari melakukan build Docker image, memberikan tag pada image, melakukan push ke container registry, hingga akhirnya melakukan deployment aplikasi. Dengan AppLaunch, workflow tersebut bisa dibuat jauh lebih sederhana. Saya cukup menyiapkan repository GitHub beserta Dockerfile, menghubungkannya ke AppLaunch, melakukan beberapa konfigurasi, dan proses build hingga deployment dapat ditangani oleh platform.</p><p>Ditambah dengan fitur seperti <strong>automatic Docker build, private container registry, environment variables/secrets, autoscaling, logs, metrics, versioning, HTTPS, dan custom domain</strong>, AppLaunch menurut saya cukup menarik untuk membantu menyederhanakan deployment aplikasi berbasis container.</p><p>Personally, <strong>I’m quite happy to see a technology that can simplify some of the work I usually do as a DevOps engineer.</strong> Kita tetap bisa menggunakan konsep Docker dan container, tetapi tidak harus selalu mengurus setiap prosesnya secara manual.</p><p>Dan tentunya, yang saya coba di artikel ini baru sebagian kecil dari fitur yang tersedia. <strong>Masih banyak fitur AppLaunch yang ingin saya eksplor lebih lanjut</strong> dan saya penasaran bagaimana platform ini bisa digunakan untuk workflow deployment yang lebih kompleks.</p><p>Kalau teman-teman penasaran dan ingin mencoba juga, bisa langsung mengunjungi:</p><p><a href="https://console.applaunch.cloud/">AppLaunch</a></p><p>Untuk melihat fitur dan cara penggunaannya lebih lengkap:</p><p><a href="https://applaunch.cloud/docs/quick-start">Quick start</a></p><p><strong><em>Less infrastructure work, more focus on the application.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=716a332f95a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Don’t Use Kiro to Write My Code. I Use It as My DevOps Partner]]></title>
            <link>https://medium.com/@nitaoktaviani2005/i-dont-use-kiro-to-write-my-code-i-use-it-as-my-devops-partner-83af2054318a?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/83af2054318a</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kiro]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Sun, 26 Jul 2026 16:10:07 GMT</pubDate>
            <atom:updated>2026-07-26T16:10:07.626Z</atom:updated>
            <content:encoded><![CDATA[<p><em>AI doesn’t replace my thinking. It helps me become a better engineer.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJEcSdjq5coqwJgl1WlPyw.png" /></figure><p>When people talk about AI for software development, the first thing that usually comes to mind is code generation. AI can write functions, generate Dockerfiles, create Kubernetes manifests, or even scaffold an entire project in seconds. Those capabilities are impressive, but after using <strong>Kiro</strong>, I realized that generating code isn’t where I get the most value.</p><p>As a <strong>DevOps Engineer</strong>, writing code is only a small part of my daily work. A much larger portion of my time is spent reviewing infrastructure, validating deployments, troubleshooting issues, improving reliability, and making sure everything is safe before it reaches production. Those tasks require analysis and decision-making more than code generation.</p><p>That’s why I started using Kiro differently.</p><p>Instead of asking it to create another YAML file or Terraform module, I use Kiro as if I were discussing a project with another engineer. I ask it to review my work, challenge my assumptions, and help me identify things that I might have overlooked.</p><h4>Using Kiro as a Production Reviewer</h4><p>Recently, I was working on one of my DevOps portfolio projects that includes several common technologies such as <strong>Docker, Kubernetes, Helm, Terraform, GitHub Actions,</strong> and <strong>Ansible</strong>. Normally, reviewing every configuration manually takes time, especially when trying to ensure that everything follows production best practices.</p><p>So instead of checking each file one by one, I asked Kiro to review the entire repository from a production perspective.</p><p>Rather than explaining what each file does, Kiro analyzed the repository like a <strong>Staff Platform Engineer</strong>. It looked for security risks, reliability issues, observability gaps, scalability concerns, and operational improvements. It also categorized every finding by severity <strong>Critical, High, Medium,</strong> and <strong>Low </strong>before generating a complete production readiness report.</p><p>The prompt I used was surprisingly simple:</p><pre>Review this repository as a Staff Platform Engineer responsible for approving production deployments.<br><br>Analyze the repository for production readiness.<br><br>Evaluate:<br>- Dockerfiles<br>- Kubernetes manifests<br>- Helm Charts<br>- Terraform<br>- GitHub Actions<br>- Ansible<br>- Security<br>- Reliability<br>- Observability<br>- Scalability<br>- Cost Optimization<br><br>Categorize findings into Critical, High, Medium, and Low severity. Explain why each issue matters, its production impact, and recommend the best solution. Finally, generate a production-readiness-report.md.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KY0CFeqhZPqbEqBVOzk8kw.png" /></figure><p>I’ve also uploaded the complete report generated by Kiro if you’d like to explore the results in more detail.</p><p><strong>Full Production Readiness Report:</strong> <a href="https://drive.google.com/file/d/1FaNt1Pr-kYLrr6rGIqjsKEJ__heRXbv0/view?usp=sharing"><em>https://drive.google.com/file/d/1FaNt1Pr-kYLrr6rGIqjsKEJ__heRXbv0/view?usp=sharing</em></a></p><h4>More Than Just an AI Assistant</h4><p>What impressed me wasn’t just the report itself it was the conversation that followed.</p><p>Once Kiro highlighted potential issues, I could continue asking questions like:</p><ul><li><em>Why is this considered a High severity issue?</em></li><li><em>Would this configuration become a problem under heavy traffic?</em></li><li><em>Is there a better Kubernetes practice for this scenario?</em></li><li><em>If this were your production environment, what would you fix first?</em></li></ul><p>The interaction felt much closer to discussing a design review with a teammate than simply using an AI chatbot. Kiro didn’t make the decisions for me, but it helped me validate my thinking and encouraged me to consider perspectives I might have missed.</p><h4>AI as an Engineering Partner</h4><p>I believe this is where AI creates the most value for DevOps Engineers.</p><p>Infrastructure changes, production deployments, and operational decisions still require human judgment. AI shouldn’t replace that responsibility. Instead, it should help engineers make more informed decisions by acting as a second pair of eyes.</p><p>For me, Kiro isn’t just a tool that writes code.</p><p>It’s an engineering partner that reviews my work before it reaches production.</p><h4>Final Thoughts</h4><p>Many people evaluate AI by asking, <em>“How much code can it generate?”</em></p><p>After using Kiro, I started asking a different question:</p><blockquote><strong><em>“How many production issues can it help me prevent?”</em></strong></blockquote><p>That small shift completely changed how I use AI in my daily workflow.</p><p>I don’t use Kiro to think <strong>instead</strong> of me.</p><p>I use Kiro to <strong>think with me</strong>.</p><p>And for a DevOps Engineer, that’s far more valuable than generating another YAML file.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83af2054318a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building AI Powered Incident Summaries with AWS Bedrock and Grafana Alerting]]></title>
            <link>https://medium.com/@nitaoktaviani2005/building-ai-powered-incident-summaries-with-aws-bedrock-and-grafana-alerting-4a70f49f4f68?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a70f49f4f68</guid>
            <category><![CDATA[amazon-bedrock]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 15:38:50 GMT</pubDate>
            <atom:updated>2026-07-21T15:38:50.005Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve ever used observability platforms like <strong>Datadog</strong>, <strong>New Relic</strong>, or <strong>PagerDuty</strong>, you’re probably familiar with their <strong>AI generated incident summary</strong> feature an automatic report that explains what happened during an incident, how long it lasted, what was impacted, and what actions to take next.</p><p>This feature is incredibly useful because:</p><ul><li>The on call team gets immediate context without investigating from scratch</li><li>No need to jump between multiple dashboards to understand what triggered an alert</li><li>Incident documentation is automatically available without any manual effort</li></ul><p>The problem? <strong>Grafana doesn’t have this feature natively</strong>. Grafana does have an LLM plugin, but there’s no built-in capability to automatically generate and deliver incident summaries via email like Datadog or New Relic do.</p><p>So I thought: <em>“Why not build it myself?”</em></p><p>By leveraging <strong>AWS Bedrock</strong> (Amazon Nova Lite) as the LLM provider and <strong>Grafana Alerting Webhook</strong> as the trigger, I built a system that automatically generates an <strong>AI Incident Summary</strong> every time an alert is resolved and delivers it straight to my inbox.</p><h3>Architecture &amp; Topology</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*RCElMHedb9ZwOayzslZpGw.png" /></figure><p>Here’s how the entire flow works:</p><ol><li><strong>Grafana Alerting detects an anomaly</strong>. Pre-configured alert rules monitor metrics such as CPU usage &gt; 85%, Memory &gt; 85%, Disk &gt; 85%, and service error rates. When a threshold is exceeded for a specified duration, the alert fires.</li></ol><p>2. <strong>Notification Policy routes the alert to two contact points</strong>. This is the key to the architecture. With the continue: true configuration, a single alert is sent to two destinations simultaneously: the Email Contact Point and the Webhook Contact Point.</p><p>3. Two parallel paths.</p><ul><li><strong>Left path (Email Contact Point)</strong>: Grafana immediately sends a [FIRING] or [RESOLVED] email via its built-in SMTP. This is the fast notification with zero delay.</li><li><strong>Right path (Webhook Contact Point)</strong>: Grafana sends an HTTP POST request to the Bedrock Proxy on port 4000.</li></ul><p>4. <strong>Bedrock Proxy receives the webhook</strong>. The proxy checks the alert status. If <strong>firing</strong>, it simply acknowledges the request because the firing email is already handled by Grafana’s email contact point. If <strong>resolved</strong>, the proxy begins processing to generate the AI summary.</p><p>5. <strong>AWS Bedrock generates the incident summary</strong>. The proxy sends a carefully crafted prompt to Amazon Nova Lite via the Converse API. The prompt includes full context: alert name, severity, description, start time, end time, and environment details. The LLM produces a structured incident summary in HTML format.</p><p>6. <strong>Send the AI Incident Summary via SMTP</strong>. The generated AI summary is sent to the inbox as a third email: [AI Incident Summary]. This email contains a complete analysis covering what happened, duration, impact, resolution, and recommendations.</p><h3>Why AI Summary Only on Resolved?</h3><p>This design is intentional. When an alert is firing, what you need is a notification <strong>as fast as possible</strong> not an AI summary that takes a few seconds to process. The AI summary only becomes relevant after the incident is over, because that’s when we have complete data: when it started, when it ended, and how long it lasted.</p><p>As a result, for every incident you receive <strong>3 emails</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*ZXcWHBGVnVQv7CqeUah5Ow.png" /></figure><h3>Full Source Code</h3><p><strong>app.py</strong> Bedrock Proxy Service</p><pre>import os<br>import json<br>import smtplib<br>import logging<br>import threading<br>from datetime import datetime, timezone, timedelta<br>from email.mime.text import MIMEText<br>from email.mime.multipart import MIMEMultipart<br>from flask import Flask, request, jsonify<br>import boto3<br><br>app = Flask(__name__)<br>logging.basicConfig(level=logging.INFO)<br>logger = logging.getLogger(__name__)<br><br># AWS Bedrock config<br>AWS_REGION = os.environ.get(&quot;AWS_REGION&quot;, &quot;us-east-1&quot;)<br>MODEL_ID = os.environ.get(&quot;MODEL_ID&quot;, &quot;amazon.nova-lite-v1:0&quot;)<br><br># SMTP config<br>SMTP_HOST = os.environ.get(&quot;SMTP_HOST&quot;, &quot;smtp.gmail.com&quot;)<br>SMTP_PORT = int(os.environ.get(&quot;SMTP_PORT&quot;, &quot;587&quot;))<br>SMTP_USER = os.environ.get(&quot;SMTP_USER&quot;, &quot;&quot;)<br>SMTP_PASSWORD = os.environ.get(&quot;SMTP_PASSWORD&quot;, &quot;&quot;)<br>ALERT_EMAIL_TO = os.environ.get(&quot;ALERT_EMAIL_TO&quot;, &quot;&quot;)<br><br># Bedrock client<br>bedrock = boto3.client(&quot;bedrock-runtime&quot;, region_name=AWS_REGION)<br><br><br>def call_bedrock(prompt):<br>    &quot;&quot;&quot;Call AWS Bedrock with Converse API.&quot;&quot;&quot;<br>    response = bedrock.converse(<br>        modelId=MODEL_ID,<br>        messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: [{&quot;text&quot;: prompt}]}],<br>        inferenceConfig={&quot;maxTokens&quot;: 1024, &quot;temperature&quot;: 0.3},<br>    )<br>    return response[&quot;output&quot;][&quot;message&quot;][&quot;content&quot;][0][&quot;text&quot;]<br><br><br>def send_email(subject, body_html):<br>    &quot;&quot;&quot;Send email via SMTP.&quot;&quot;&quot;<br>    msg = MIMEMultipart(&quot;alternative&quot;)<br>    msg[&quot;Subject&quot;] = subject<br>    msg[&quot;From&quot;] = SMTP_USER<br>    msg[&quot;To&quot;] = ALERT_EMAIL_TO<br>    msg.attach(MIMEText(body_html, &quot;html&quot;))<br><br>    with smtplib.SMTP(SMTP_HOST, SMTP_PORT) as server:<br>        server.starttls()<br>        server.login(SMTP_USER, SMTP_PASSWORD)<br>        server.sendmail(SMTP_USER, ALERT_EMAIL_TO, msg.as_string())<br>    logger.info(f&quot;Email sent to {ALERT_EMAIL_TO}&quot;)<br><br><br>@app.route(&quot;/health&quot;, methods=[&quot;GET&quot;])<br>def health():<br>    return jsonify({&quot;status&quot;: &quot;healthy&quot;, &quot;model&quot;: MODEL_ID})<br><br><br>@app.route(&quot;/v1/chat/completions&quot;, methods=[&quot;POST&quot;])<br>def chat_completions():<br>    &quot;&quot;&quot;OpenAI-compatible chat completions endpoint.&quot;&quot;&quot;<br>    data = request.get_json()<br>    messages = data.get(&quot;messages&quot;, [])<br><br>    prompt = &quot;&quot;<br>    for msg in messages:<br>        if msg.get(&quot;role&quot;) == &quot;user&quot;:<br>            prompt = msg.get(&quot;content&quot;, &quot;&quot;)<br><br>    if not prompt:<br>        return jsonify({&quot;error&quot;: &quot;No user message found&quot;}), 400<br><br>    try:<br>        result = call_bedrock(prompt)<br>        return jsonify({<br>            &quot;id&quot;: &quot;chatcmpl-bedrock&quot;,<br>            &quot;object&quot;: &quot;chat.completion&quot;,<br>            &quot;choices&quot;: [{<br>                &quot;index&quot;: 0,<br>                &quot;message&quot;: {&quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: result},<br>                &quot;finish_reason&quot;: &quot;stop&quot;,<br>            }],<br>            &quot;model&quot;: MODEL_ID,<br>        })<br>    except Exception as e:<br>        logger.error(f&quot;Bedrock error: {e}&quot;)<br>        return jsonify({&quot;error&quot;: str(e)}), 500<br><br><br>@app.route(&quot;/v1/models&quot;, methods=[&quot;GET&quot;])<br>def list_models():<br>    &quot;&quot;&quot;OpenAI-compatible models listing.&quot;&quot;&quot;<br>    return jsonify({<br>        &quot;data&quot;: [<br>            {&quot;id&quot;: MODEL_ID, &quot;object&quot;: &quot;model&quot;, &quot;owned_by&quot;: &quot;aws-bedrock&quot;},<br>            {&quot;id&quot;: &quot;gpt-3.5-turbo&quot;, &quot;object&quot;: &quot;model&quot;, &quot;owned_by&quot;: &quot;aws-bedrock&quot;},<br>            {&quot;id&quot;: &quot;gpt-4&quot;, &quot;object&quot;: &quot;model&quot;, &quot;owned_by&quot;: &quot;aws-bedrock&quot;},<br>        ]<br>    })<br><br><br>@app.route(&quot;/webhook/alert&quot;, methods=[&quot;POST&quot;])<br>def webhook_alert():<br>    &quot;&quot;&quot;Receive Grafana alert webhook, process only resolved alerts.&quot;&quot;&quot;<br>    data = request.get_json()<br>    logger.info(f&quot;Received alert webhook: {json.dumps(data, indent=2)[:500]}&quot;)<br><br>    title = data.get(&quot;title&quot;, &quot;Grafana Alert&quot;)<br>    status = data.get(&quot;status&quot;, &quot;unknown&quot;)<br>    alerts = data.get(&quot;alerts&quot;, [])<br><br>    alert_details = []<br>    for alert in alerts:<br>        labels = alert.get(&quot;labels&quot;, {})<br>        annotations = alert.get(&quot;annotations&quot;, {})<br>        alert_details.append(<br>            f&quot;- Alert: {labels.get(&#39;alertname&#39;, &#39;N/A&#39;)}\n&quot;<br>            f&quot;  Severity: {labels.get(&#39;severity&#39;, &#39;N/A&#39;)}\n&quot;<br>            f&quot;  Summary: {annotations.get(&#39;summary&#39;, &#39;N/A&#39;)}\n&quot;<br>            f&quot;  Description: {annotations.get(&#39;description&#39;, &#39;N/A&#39;)}\n&quot;<br>            f&quot;  Status: {alert.get(&#39;status&#39;, &#39;N/A&#39;)}&quot;<br>        )<br><br>    alert_text = &quot;\n&quot;.join(alert_details) if alert_details else &quot;No alert details&quot;<br><br>    if status == &quot;resolved&quot;:<br>        thread = threading.Thread(<br>            target=_send_ai_incident_summary,<br>            args=[title, alert_text, alerts],<br>            daemon=True,<br>        )<br>        thread.start()<br>        return jsonify({&quot;status&quot;: &quot;ok&quot;, &quot;message&quot;: &quot;AI incident summary generating...&quot;})<br>    else:<br>        logger.info(f&quot;Alert firing for &#39;{title}&#39; — email handled by Grafana&quot;)<br>        return jsonify({&quot;status&quot;: &quot;ok&quot;, &quot;message&quot;: &quot;Firing alert acknowledged&quot;})<br><br><br>def _format_to_wib(iso_str):<br>    &quot;&quot;&quot;Convert ISO timestamp to WIB (UTC+7) readable format.&quot;&quot;&quot;<br>    try:<br>        dt = datetime.fromisoformat(iso_str.replace(&quot;Z&quot;, &quot;+00:00&quot;))<br>        wib = dt.astimezone(timezone(timedelta(hours=7)))<br>        return wib.strftime(&quot;%d %B %Y %H:%M WIB&quot;)<br>    except Exception:<br>        return iso_str<br><br><br>def _send_ai_incident_summary(title, alert_text, alerts):<br>    &quot;&quot;&quot;Generate AI Incident Summary after alert resolved.&quot;&quot;&quot;<br>    durations = []<br>    for alert in alerts:<br>        starts_at = alert.get(&quot;startsAt&quot;, &quot;&quot;)<br>        ends_at = alert.get(&quot;endsAt&quot;, &quot;&quot;)<br>        if starts_at and ends_at:<br>            durations.append(<br>                f&quot;  Start: {_format_to_wib(starts_at)}, End: {_format_to_wib(ends_at)}&quot;<br>            )<br><br>    duration_text = &quot;\n&quot;.join(durations) if durations else &quot;Duration unknown&quot;<br><br>    prompt = f&quot;&quot;&quot;You are an SRE assistant. An alert has fired and is now resolved.<br>Write a brief Incident Summary (NOT a full post-mortem).<br><br>Include:<br>1. **What happened** - One paragraph summary of the incident<br>2. **Duration** - How long the incident lasted<br>3. **Impact** - What was affected<br>4. **Resolution** - What likely resolved it<br>5. **Recommendation** - One or two key actions to prevent recurrence<br><br>Alert Information:<br>- Title: {title}<br>- Status: RESOLVED<br>- Duration:<br>{duration_text}<br>- Details:<br>{alert_text}<br><br>Environment: Docker Swarm on Azure VM (Grafana LGTM stack)<br>Services: ecommerce app (api-gateway, product, order, user, payment services)<br><br>Keep it concise and actionable. Format as HTML suitable for email.&quot;&quot;&quot;<br><br>    try:<br>        ai_summary = call_bedrock(prompt)<br>        logger.info(&quot;AI Incident Summary generated successfully&quot;)<br><br>        email_subject = f&quot;[AI Incident Summary] {title}&quot;<br>        email_body = f&quot;&quot;&quot;<br>        &lt;html&gt;<br>        &lt;body style=&quot;font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto;&quot;&gt;<br>            &lt;h2 style=&quot;color: #2c3e50;&quot;&gt;AI Incident Summary&lt;/h2&gt;<br>            &lt;p&gt;&lt;strong&gt;Alert:&lt;/strong&gt; {title}&lt;/p&gt;<br>            &lt;p&gt;&lt;strong&gt;Status:&lt;/strong&gt; RESOLVED&lt;/p&gt;<br>            &lt;p&gt;&lt;strong&gt;Generated at:&lt;/strong&gt; {datetime.now().strftime(&#39;%Y-%m-%d %H:%M:%S UTC+7&#39;)}&lt;/p&gt;<br>            &lt;hr&gt;<br>            &lt;div&gt;{ai_summary}&lt;/div&gt;<br>            &lt;hr&gt;<br>            &lt;p style=&quot;color: #666; font-size: 12px;&quot;&gt;<br>                Generated by AWS Bedrock ({MODEL_ID}) | Grafana LGTM Stack&lt;br&gt;<br>                This summary was generated automatically after alert resolution.<br>            &lt;/p&gt;<br>        &lt;/body&gt;<br>        &lt;/html&gt;<br>        &quot;&quot;&quot;<br>        send_email(email_subject, email_body)<br>        logger.info(&quot;AI Incident Summary email sent&quot;)<br>    except Exception as e:<br>        logger.error(f&quot;AI Incident Summary error: {e}&quot;)<br><br><br>if __name__ == &quot;__main__&quot;:<br>    app.run(host=&quot;0.0.0.0&quot;, port=4000)</pre><p><strong>requirements.txt</strong></p><pre>flask==3.1.0<br>boto3==1.35.0<br>gunicorn==23.0.0</pre><p><strong>Dockerfile</strong></p><pre>FROM python:3.11-slim<br><br>WORKDIR /app<br><br>COPY requirements.txt .<br>RUN pip install --no-cache-dir -r requirements.txt<br><br>COPY app.py .<br><br>EXPOSE 4000<br><br>CMD [&quot;gunicorn&quot;, &quot;--bind&quot;, &quot;0.0.0.0:4000&quot;, &quot;--workers&quot;, &quot;2&quot;, &quot;--timeout&quot;, &quot;120&quot;, &quot;app:app&quot;]</pre><h3>Grafana Configuration</h3><p><strong>Contact Points</strong></p><p>Two contact points are needed: one for standard email notifications, and one as a webhook to the Bedrock Proxy.</p><pre>apiVersion: 1<br>contactPoints:<br>  - orgId: 1<br>    name: email-notifications<br>    receivers:<br>      - uid: email-notif-1<br>        type: email<br>        settings:<br>          addresses: your-email@gmail.com<br>          singleEmail: true<br><br>  - orgId: 1<br>    name: ai-incident-summary<br>    receivers:<br>      - uid: ai-webhook-1<br>        type: webhook<br>        settings:<br>          url: http://bedrock-proxy:4000/webhook/alert<br>          httpMethod: POST</pre><p><strong>Notification Policies</strong></p><p>The most important part is continue: true on the ai-incident-summary route. Without this, alerts would only be sent to the webhook and would not be forwarded to the email contact point.</p><pre>apiVersion: 1<br>policies:<br>  - orgId: 1<br>    receiver: email-notifications<br>    group_by:<br>      - grafana_folder<br>      - alertname<br>    group_wait: 10s<br>    group_interval: 10s<br>    repeat_interval: 5m<br>    routes:<br>      - receiver: ai-incident-summary<br>        continue: true<br>      - receiver: email-notifications</pre><h3>How to Run</h3><pre># Build the Docker image<br>docker build -t bedrock-proxy ./bedrock-proxy<br><br># Run the container<br>docker run -d \<br>  --name bedrock-proxy \<br>  -p 4000:4000 \<br>  -e AWS_REGION=us-east-1 \<br>  -e MODEL_ID=amazon.nova-lite-v1:0 \<br>  -e AWS_ACCESS_KEY_ID=your-access-key \<br>  -e AWS_SECRET_ACCESS_KEY=your-secret-key \<br>  -e SMTP_HOST=smtp.gmail.com \<br>  -e SMTP_PORT=587 \<br>  -e SMTP_USER=your-email@gmail.com \<br>  -e SMTP_PASSWORD=your-app-password \<br>  -e ALERT_EMAIL_TO=your-email@gmail.com \<br>  bedrock-proxy<br><br># Test the health check<br>curl http://localhost:4000/health</pre><p>Note: For Gmail, use an App Password (not your regular password). Create one at<em> </em><a href="https://myaccount.google.com/apppasswords"><em>https://myaccount.google.com/apppasswords</em></a></p><h3>Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*W0EcVNwh_SL-nSqJm7OGAA.png" /></figure><p>With this setup, I was able to get an <strong>AI Incident Summary</strong> feature similar to what Datadog and other premium observability platforms offer but running on <strong>open-source Grafana</strong> at a fraction of the cost. Amazon Nova Lite on AWS Bedrock is extremely cost-effective for summarization tasks like this.</p><p>Every time an incident resolves, I immediately receive an email with an actionable summary no manual effort required.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a70f49f4f68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Save 99% on AWS EC2: Schedule Your Instance to Run Only 30 Minutes a Day]]></title>
            <link>https://medium.com/@nitaoktaviani2005/save-99-on-aws-ec2-schedule-your-instance-to-run-only-30-minutes-a-day-6ac168f6b22e?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac168f6b22e</guid>
            <category><![CDATA[eventbridge]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 15:55:44 GMT</pubDate>
            <atom:updated>2026-07-16T15:55:44.119Z</atom:updated>
            <content:encoded><![CDATA[<p>Use AWS Lambda and EventBridge to automatically start and stop EC2 instances on a precise schedule no always-on server required.</p><h4>The Problem</h4><p>I built a Telegram bot that automates my daily attendance check-in at work. The bot runs on an EC2 instance, and its job is simple:</p><ul><li>At 08:00, it sends me a reminder to clock in. I reply with a confirmation and an MFA code, and the bot logs into the attendance system on my behalf.</li><li>At 17:00, it does the same thing for clocking out.</li></ul><p>Each interaction takes about 2–3 minutes. That means my EC2 instance only needs to be alive for roughly <strong>15 minutes in the morning and 15 minutes in the evening </strong>a total of 30 minutes per day.</p><p>Yet if I leave the instance running 24/7, I am paying for 1,440 minutes of uptime every single day, of which 1,410 minutes are completely wasted.</p><h4>The Solution</h4><p>The idea is straightforward. Use AWS Lambda (triggered by EventBridge on a cron schedule) to start and stop the EC2 instance at exact times:</p><ul><li><strong>07:55 </strong>Lambda starts the EC2 instance (gives it 5 minutes to boot and let Docker containers come up).</li><li><strong>08:15 </strong>Lambda stops the EC2 instance (morning check-in is done).</li><li><strong>16:55 </strong>Lambda starts the EC2 instance again.</li><li><strong>17:15 </strong>Lambda stops the EC2 instance (evening check-out is done).</li></ul><p>The instance is alive for two short windows on weekdays. Everything else is off. Weekends are completely off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rd0oul7SRSszA3affCQfpw.png" /></figure><h4>Cost Comparison</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*MTuZYso8cpJitY2mQBZJpg.png" /></figure><p>The Lambda invocations and EventBridge rules are covered by the AWS free tier. The scheduling infrastructure itself costs nothing.</p><h3>Step 1 Write the Lambda Function</h3><p>A single Python function handles both starting and stopping. The behavior is determined by an environment variable called ACTION.</p><pre>import os<br>import boto3<br>import logging<br><br>log = logging.getLogger()<br>log.setLevel(logging.INFO)<br><br>ec2         = boto3.client(&quot;ec2&quot;, region_name=os.environ.get(&quot;AWS_REGION&quot;, &quot;ap-southeast-1&quot;))<br>INSTANCE_ID = os.environ[&quot;INSTANCE_ID&quot;]<br>ACTION      = os.environ[&quot;ACTION&quot;]<br><br><br>def lambda_handler(event, context):<br>    log.info(f&quot;Action: {ACTION} | Instance: {INSTANCE_ID}&quot;)<br><br>    if ACTION == &quot;start&quot;:<br>        ec2.start_instances(InstanceIds=[INSTANCE_ID])<br>        return {&quot;status&quot;: &quot;starting&quot;, &quot;instance&quot;: INSTANCE_ID}<br><br>    elif ACTION == &quot;stop&quot;:<br>        ec2.stop_instances(InstanceIds=[INSTANCE_ID])<br>        return {&quot;status&quot;: &quot;stopping&quot;, &quot;instance&quot;: INSTANCE_ID}<br><br>    else:<br>        raise ValueError(f&quot;Invalid ACTION: {ACTION}&quot;)</pre><p>One codebase, deployed multiple times with different environment variables. Simple and maintainable.</p><h3>Step 2 Create an IAM Role</h3><p>The Lambda function needs permission to control EC2 instances. Create a role with the following policy:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;ec2:StartInstances&quot;,<br>                &quot;ec2:StopInstances&quot;,<br>                &quot;ec2:DescribeInstances&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;logs:CreateLogGroup&quot;,<br>                &quot;logs:CreateLogStream&quot;,<br>                &quot;logs:PutLogEvents&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:logs:*:*:*&quot;<br>        }<br>    ]<br>}</pre><p>Steps:</p><ol><li>Go to IAM, then Roles, then Create Role.</li><li>Select AWS Service and choose Lambda as the use case.</li><li>Attach the custom policy above.</li><li>Name the role lambda-ec2-scheduler.</li></ol><p><em>For production use, restrict the Resource field to your specific instance ARN instead of using a wildcard.</em></p><h3>Step 3 Deploy the Lambda Functions</h3><p>For this use case, you need four Lambda deployments:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*eHunS0t_ruCzv6ftSLLxcQ.png" /></figure><p>For each function:</p><ol><li>Go to Lambda and create a new function with Python 3.12 runtime.</li><li>Assign the lambda-ec2-scheduler role.</li><li>Paste the code from Step 1.</li><li>Set the environment variables INSTANCE_ID and ACTION.</li><li>Set the timeout to 10 seconds.</li></ol><h3>Step 4 Create EventBridge Schedules</h3><p>Each Lambda function gets its own cron trigger. All cron expressions in EventBridge use UTC. Adjust based on your timezone.</p><p>In my case, the local timezone is UTC+7 (Asia/Jakarta). Here is the mapping:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*fWpVNEdc2QMe56zBHFR2ww.png" /></figure><p>To create each rule:</p><ol><li>Go to EventBridge, then Rules, then Create Rule.</li><li>Choose Schedule as the rule type.</li><li>Enter the cron expression.</li><li>Set the target to the corresponding Lambda function.</li></ol><p><em>Double check your timezone offset before deploying. A one hour mistake means your instance might not be ready when your application needs it.</em></p><h3>Step 5 Ensure Your Application Auto-Starts on Boot</h3><p>When EC2 starts, your application must come up automatically without manual intervention. If you are using Docker Compose, set the restart policy:</p><pre>services:<br>  my-app:<br>    build: .<br>    restart: unless-stopped</pre><p>Also make sure the Docker daemon is enabled on boot:</p><pre>sudo systemctl enable docker</pre><p>With this configuration, every time the instance boots, Docker starts, and your containers come up with it.</p><h3>Step 6 Test Manually</h3><p>Before relying on the schedule, verify everything end to end:</p><ol><li>Open one of the stop Lambda functions in the AWS console.</li><li>Click Test with an empty event ({}).</li><li>Confirm the EC2 instance begins stopping in the EC2 console.</li><li>Invoke the start function and confirm the instance boots.</li><li>SSH into the instance after boot and verify your application is running and responsive.</li></ol><p>This setup takes five minutes and costs nothing beyond the EC2 hours you actually consume. For workloads that only need to run during specific short windows like a bot that clocks in at 8:00 and clocks out at 17:00 this approach can reduce your bill by over 98%.</p><p>Key points:</p><ul><li>A single Python function handles both start and stop via an environment variable.</li><li>EventBridge cron triggers invoke Lambda at precise times.</li><li>Docker with a restart policy ensures your application recovers automatically on boot.</li><li>Lambda and EventBridge cost nothing under the free tier.</li><li>The entire scheduling layer is serverless and requires no maintenance.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac168f6b22e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding MTTD, MTTR, and MTBF A Practical Guide for DevOps Engineers]]></title>
            <link>https://medium.com/@nitaoktaviani2005/understanding-mttd-mttr-and-mtbf-a-practical-guide-for-devops-engineers-4ec17fce0001?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ec17fce0001</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Sat, 04 Apr 2026 14:54:38 GMT</pubDate>
            <atom:updated>2026-04-04T14:54:38.669Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oh38bqcxR1WZZI5WHagzww.png" /></figure><p>I am a DevOps engineer who is currently exploring the world of Site Reliability Engineering (SRE). Recently, I started learning more about SRE and its core principles. At first, many of the terms felt unfamiliar and a bit intimidating. However, as I went deeper, I realized something interesting. Many of these concepts have actually been part of my daily work as a DevOps engineer.</p><p>I just did not know that they had specific names in SRE. One of the concepts that caught my attention is MTTD, MTTR, and MTBF. At first, they sounded complex and highly theoretical. But in reality, they are simple and very practical. They describe things that we already do, such as detecting issues, fixing them, and preventing them from happening again. That is when I had a realization. <em>“Oh… this is what I’ve been doing all along.” </em>In this article, I want to share a simple and practical understanding of MTTD, MTTR, and MTBF, especially in the context of AWS and DevOps.</p><h3>What are MTTD, MTTR, and MTBF?</h3><p><strong>MTTD</strong> stands for <strong>Mean Time To Detect</strong>. It refers to how long it takes to detect a failure after it occurs. <strong>MTTR</strong> stands for <strong>Mean Time To Repair or Recover</strong>. It measures how long it takes to recover the system after a failure has been detected. <strong>MTBF</strong> stands for <strong>Mean Time Between Failures</strong>. It represents the average time between one failure and the next.</p><p>To make these concepts easier to understand, let’s use a simple analogy. Imagine your system is like a human body. MTTD is how quickly you realize that you are sick. MTTR is how quickly you recover after getting treatment. MTBF is how often you get sick over a period of time.</p><p>In the context of SRE, these three metrics are very important. They help measure how reliable and resilient a system is. MTTD focuses on how fast we can detect problems. MTTR focuses on how fast we can recover from those problems. MTBF focuses on how frequently those problems occur.</p><p>Together, they form a complete picture of system reliability. A good system should detect issues quickly, recover fast, and experience failures less often. This is why these metrics are widely used in Site Reliability Engineering practices.</p><h3>How to Calculate MTTD, MTTR, and MTBF (with Availability)</h3><p>Before diving deeper into calculations, we need to understand one important concept availability. Availability measures how often a system is up and running.</p><h4>Availability Formula</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*1fL-Cb71aqKcEpsrSPc1Ww.png" /></figure><p>Availability is calculated by comparing uptime and downtime. Uptime is the time when the system is working normally. Downtime is the time when the system is not available. To make it more practical, AWS relates availability with MTBF and MTTR.</p><h4>Relationship Between MTBF and MTTR</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*fD8QOCfSW7Qf29WUxkLlYA.png" /></figure><p>This formula shows that availability depends on how often failures happen and how fast we recover. If MTBF is high, it means failures are rare. If MTTR is low, it means recovery is fast.</p><h4>Understanding the Timeline (MTTD, MTTR, MTBF)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*0vwr_Qw34a8rh2EMSMxk8w.png" /></figure><p>Imagine a timeline of a system operation. First, a failure occurs. Then, there is a delay before we detect the issue. This delay is called MTTD. After detection, we start fixing the problem. The total time from failure until recovery is called MTTR. Once the system is back to normal, it runs until the next failure occurs. This duration is called MTBF.</p><p>From the diagram, we can clearly see how these metrics are connected. MTTD is a part of MTTR. MTTR includes detection and repair time. MTBF represents the stable period between failures.</p><p>A smaller MTTD means faster detection. A smaller MTTR means faster recovery. A larger MTBF means failures happen less frequently.</p><h3>Implementation in AWS (Tools &amp; Services)</h3><p>After understanding the concepts of MTTD, MTTR, and MTBF, the next step is to see how these are implemented in AWS. AWS provides a wide range of services that help improve system reliability. Each metric can be supported by different tools depending on its purpose.</p><h4>MTTD (Detection)</h4><p>To reduce MTTD, we need strong monitoring and observability. <strong>Amazon CloudWatch</strong> allows us to collect metrics and create alarms based on system conditions. These alarms can notify us immediately when something goes wrong. <strong>CloudWatch Synthetics</strong> helps simulate user behavior to detect issues before users notice them. <strong>AWS X-Ray</strong> provides distributed tracing to identify latency issues and errors across services. Health checks from <strong>Elastic Load Balancer </strong>and <strong>Route 53</strong> can automatically detect unhealthy resources.</p><h4>MTTR (Recovery)</h4><p>To reduce MTTR, automation and fast recovery mechanisms are essential. Auto Scaling can automatically replace unhealthy instances to maintain system availability. Load Balancers can route traffic away from failed instances to healthy ones. <strong>AWS Lambda</strong> can be used to automate recovery actions, such as restarting services or triggering workflows. <strong>AWS Systems Manager</strong> provides runbooks that help standardize and automate operational tasks.</p><h4>MTBF (Reliability)</h4><p>To increase MTBF, we need to design systems that are resilient and fault-tolerant. Using <strong>Multi-AZ</strong> and <strong>Multi-Region</strong> architectures helps ensure high availability even during failures. <strong>AWS Fault Injection Simulator</strong> can be used to test how the system behaves under failure conditions. <strong>Amazon CodeGuru</strong> helps identify potential issues in code before they cause failures. <strong>CI/CD pipelines</strong> and automation reduce human error and ensure consistent deployments.</p><p>In AWS, these tools work together to improve overall system reliability. Monitoring helps detect issues quickly. Automation helps recover from failures faster. Resilient architecture helps reduce the frequency of failures.</p><p>In reality, no system is perfect, and failures will always happen. The goal is not to eliminate failures, but to detect and recover as quickly as possible. MTTD, MTTR, and MTBF help us understand how fast we detect, recover, and how often failures occur. Looking back, I realized that many of these practices are already part of my daily DevOps work. I just did not realize they had formal names in SRE. If you are in DevOps, you are probably already doing SRE without realizing it. Now is a good time to explore it more deeply.</p><p><em>Reference:</em></p><ul><li><a href="https://docs.aws.amazon.com/whitepapers/latest/availability-and-beyond-improving-resilience/understanding-availability.html">Understanding availability</a></li><li><a href="https://www.logicmonitor.com/blog/whats-the-difference-between-mttr-mttd-mttf-and-mtbf">What&#39;s the difference between MTTR, MTBF, MTTD, and MTTF</a></li><li><a href="https://www.ibm.com/id-id/think/topics/mttr-vs-mtbf">MTTR vs MTBF: Apa bedanya? | IBM</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ec17fce0001" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From DevOps to SRE: Learning Incident and Postmortem from a Simple Simulation]]></title>
            <link>https://medium.com/@nitaoktaviani2005/from-devops-to-sre-learning-incident-and-postmortem-from-a-simple-simulation-cda6b2e4d207?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/cda6b2e4d207</guid>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[postmortem]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Sat, 28 Mar 2026 09:57:58 GMT</pubDate>
            <atom:updated>2026-03-28T09:57:58.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gcdKrkcjEpCPXYlMUQoHPw.png" /></figure><p>As a DevOps engineer, I am familiar with deployment, automation, and infrastructure. However, recently I have become interested in learning more about SRE (Site Reliability Engineering), especially how systems handle incidents and maintain reliability.</p><p>This curiosity led me to explore a simple question what actually happens when a system starts to fail?</p><p><strong>What is a Postmortem?</strong></p><p>A postmortem is a document created after an incident to analyze what happened, why it happened, and how to prevent it from happening again.</p><p>It is one of the core practices in SRE, used to turn failures into learning opportunities.</p><p><strong>Where Does Postmortem Come From?</strong></p><p>The concept of postmortem became widely known through large-scale engineering teams, especially those working on distributed systems.</p><p>It was popularized in SRE practices, where systems are complex and failures are inevitable. Instead of avoiding failure completely, teams focus on learning from it.</p><p><strong>Why Do We Use Postmortem?</strong></p><p>In real systems, incidents will always happen. No system is perfect.</p><p>Postmortem helps teams understand incidents in a structured way, ensuring that the same problem does not happen repeatedly.</p><p><strong>What Are the Benefits of Postmortem?</strong></p><p>Postmortems provide several important benefits:</p><ul><li>They help identify the root cause of a problem</li><li>They improve system reliability over time</li><li>They encourage a culture of learning instead of blaming</li><li>They provide documentation for future incidents</li></ul><h4>Demo Overview</h4><p>To better understand this concept, I created a simple API simulation.</p><p>The goal of this demo is to intentionally create a performance issue and observe how the system behaves under problematic conditions.</p><p><strong>What I Did in the Demo</strong></p><p>I implemented three endpoints:</p><ul><li>/ normal response</li><li>/fast fast response</li><li>/slow intentionally slow response</li></ul><p>The /slow endpoint performs a heavy synchronous operation to simulate a real-world performance issue.</p><p><strong>What I Wanted to Observe</strong></p><p>By triggering the /slow endpoint multiple times, I wanted to observe how the system behaves under load and whether other endpoints are affected.</p><p>This helps simulate how a real incident might impact a system.</p><p><strong>Monitoring Evidence</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBVBiyF5w6KfM-tIDaZzAg.png" /></figure><p>From the monitoring metrics, a spike in HTTP 5xx errors was observed during the incident.</p><p>Although the spike was not continuous, it indicates that the system experienced instability when the /slow endpoint was triggered.</p><p>This suggests that even temporary blocking operations can impact system reliability.</p><h4>Writing the Postmortem</h4><p>Now that we understand how the incident happened, the next step is to document it properly.</p><p>In this case, I created a simple postmortem based on the simulation results, including the summary, impact, root cause, and action items.</p><p>If you are interested in seeing a real example, I have documented the full postmortem from this simulation.</p><p>You can access it through the following link:</p><p><a href="https://drive.google.com/file/d/10SenyYaSk6TSTpe-qUIThDIx71BUbDqU/view?usp=sharing">https://drive.google.com/file/d/10SenyYaSk6TSTpe-qUIThDIx71BUbDqU/view?usp=sharing</a></p><p>Understanding how systems fail is just as important as knowing how to build them.</p><p>Through this simple simulation, I learned that reliability is not only about infrastructure, but also about how we design and write our code. Even a small blocking process can have a significant impact on the entire system.</p><p>This experience also introduced me to the importance of postmortems in building a culture of continuous improvement.</p><p>Postmortems are not about assigning blame, but about learning and improving system reliability.</p><p><em>Referensi:</em></p><ul><li><a href="https://sre.google/workbook/postmortem-culture/">Google SRE - Postmortem Practices for Incident Management</a></li><li><a href="https://sre.google/sre-book/example-postmortem/">Example Postmortem</a></li><li><a href="https://rootly.com/incident-postmortems">What Is an Incident Postmortem? Definition and Key Benefits</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cda6b2e4d207" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Membangun Centralized Logging Kubernetes dengan Grafana Loki, Alloy, dan Grafana di AKS]]></title>
            <link>https://medium.com/@nitaoktaviani2005/membangun-centralized-logging-kubernetes-dengan-grafana-loki-alloy-dan-grafana-di-aks-1fdf66451097?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fdf66451097</guid>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Thu, 08 Jan 2026 07:56:28 GMT</pubDate>
            <atom:updated>2026-01-08T07:56:28.289Z</atom:updated>
            <content:encoded><![CDATA[<p>Dalam lingkungan <strong>Kubernetes</strong>, aplikasi berjalan secara terdistribusi di banyak <strong>pod</strong> dan <strong>node</strong>. Setiap komponen menghasilkan log-nya masing-masing, yang sering kali tersebar dan tidak terpusat. Kondisi ini membuat proses <strong>troubleshooting</strong>, <strong>monitoring error</strong>, dan <strong>root cause analysis</strong> menjadi lebih sulit, terutama ketika terjadi masalah pada sistem produksi.</p><p>Tanpa mekanisme <strong>centralized logging</strong>, engineer harus mengakses log dari masing-masing pod secara manual. Proses ini tidak hanya memakan waktu, tetapi juga menyulitkan dalam mengidentifikasi pola error, lonjakan log, atau anomali yang terjadi di seluruh cluster. Seiring bertambahnya jumlah layanan dan kompleksitas sistem, pendekatan ini menjadi tidak efisien dan berisiko terhadap stabilitas operasional.</p><p>Untuk mengatasi permasalahan tersebut, pada implementasi ini dibangun solusi <strong>centralized logging</strong> menggunakan <strong>Grafana Loki Stack</strong> di atas <strong>Azure Kubernetes Service (AKS)</strong>. Solusi ini memungkinkan seluruh log aplikasi dan sistem Kubernetes dikumpulkan secara terpusat, disimpan dengan efisien, serta divisualisasikan dalam satu antarmuka yang mudah dianalisis.</p><p>Dengan pendekatan ini, tim operasional dapat:</p><ul><li>Mengakses log dari seluruh pod dan namespace dalam satu dashboard.</li><li>Melakukan pencarian dan analisis log secara real-time.</li><li>Mendeteksi lonjakan error dan pola masalah lebih cepat.</li><li>Mempercepat proses investigasi insiden tanpa perlu mengakses node secara langsung.</li></ul><p>Implementasi ini menjadi fondasi awal untuk membangun observability yang lebih baik di lingkungan Kubernetes, serta dapat dikembangkan lebih lanjut dengan fitur alerting, monitoring, dan tracing di masa depan.</p><h3>Referensi dan Penyesuaian Konfigurasi</h3><p>Pada implementasi centralized logging ini, konfigurasi tidak dibuat sepenuhnya dari nol. Sebagai acuan awal, saya mempelajari <strong>dokumentasi resmi Grafana Loki dan Grafana Alloy</strong> untuk memahami konsep, arsitektur, serta best practice yang direkomendasikan oleh vendor.</p><p>Selain dokumentasi resmi, saya juga menggunakan referensi konfigurasi dari repository GitHub <strong>devopshobbies</strong> yang menyediakan contoh implementasi Grafana Loki Stack di Kubernetes. Repository tersebut memberikan gambaran praktis mengenai struktur konfigurasi, deployment menggunakan Helm, serta integrasi antar komponen observability.</p><p>Namun demikian, konfigurasi pada implementasi ini <strong>tidak digunakan secara langsung (copy paste)</strong>. Beberapa penyesuaian dilakukan agar solusi yang dibangun lebih sesuai dengan kebutuhan dan kondisi lingkungan <strong>Azure Kubernetes Service (AKS)</strong> serta tujuan penggunaan internal. Penyesuaian tersebut meliputi:</p><ul><li><strong>Mode deployment Grafana Loki</strong><br>Menggunakan <em>scalable mode</em> untuk memisahkan komponen <em>read</em>, <em>write</em>, dan <em>backend</em>, sehingga arsitektur lebih siap untuk dikembangkan dan diskalakan di kemudian hari.</li><li><strong>Backend storage untuk Loki</strong><br>Object storage dikonfigurasikan menggunakan <strong>MinIO</strong> yang bersifat S3-compatible, sehingga lebih fleksibel dan mudah dikontrol pada lingkungan Kubernetes.</li><li><strong>Log collector menggunakan Grafana Alloy</strong><br>Alih-alih menggunakan Grafana Agent bawaan dari Helm chart Loki, saya memilih <strong>Grafana Alloy</strong> sebagai log collector karena lebih modular, modern, dan direkomendasikan sebagai agent generasi terbaru.</li><li><strong>Akses Grafana melalui LoadBalancer</strong><br>Grafana dikonfigurasikan agar dapat diakses dari luar cluster melalui Service LoadBalancer, sehingga memudahkan proses visualisasi dan analisis log.</li></ul><p>Dengan mengombinasikan <strong>dokumentasi resmi</strong> dan <strong>referensi komunitas</strong>, serta melakukan penyesuaian sesuai kebutuhan, implementasi ini diharapkan tidak hanya berfungsi secara teknis, tetapi juga mengikuti praktik yang baik dan mudah dipelihara dalam jangka panjang.</p><h3>Arsitektur Solusi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*bNebT2NQ3kevuSz47WX1sg.png" /></figure><p>Arsitektur solusi pada implementasi ini menggunakan <strong>Grafana Loki Scalable Architecture</strong> yang dirancang untuk memisahkan jalur <strong>penulisan log (write path)</strong> dan <strong>pembacaan log (read path)</strong>. Pemisahan ini bertujuan untuk meningkatkan performa, skalabilitas, serta kemudahan pengelolaan sistem log pada lingkungan Kubernetes.</p><p>Secara garis besar, alur sistem terbagi menjadi tiga bagian utama:</p><ol><li><strong>Log ingestion (Write Path)</strong></li><li><strong>Log query (Read Path)</strong></li><li><strong>Object storage sebagai backend penyimpanan</strong></li></ol><p>Diagram arsitektur di atas menggambarkan bagaimana data log mengalir dari Kubernetes hingga dapat divisualisasikan di Grafana.</p><h4>Log Collection menggunakan Grafana Alloy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*OU4ZyZ4siugdmwvVyYTVqA.png" /></figure><p>Pada sisi paling awal, <strong>Grafana Alloy</strong> berjalan sebagai <strong>DaemonSet</strong> di setiap node Kubernetes. Alloy bertugas untuk:</p><ul><li>Melakukan discovery pod Kubernetes.</li><li>Mengambil log dari file sistem /var/log/pods.</li><li>Menambahkan label seperti namespace, pod, dan container.</li><li>Mengirimkan log ke Grafana Loki melalui endpoint HTTP.</li></ul><p>Dengan pendekatan ini, setiap node akan secara otomatis mengirimkan log dari seluruh pod yang berjalan di node tersebut tanpa perlu konfigurasi manual per aplikasi.</p><h4>Write Path (Alur Penulisan Log)</h4><p>Alur penulisan log dimulai ketika Alloy mengirimkan log ke Loki.</p><p><strong>Distributor</strong></p><ul><li>Menerima log dari Alloy.</li><li>Melakukan validasi dan load balancing.</li><li>Mendistribusikan log ke beberapa instance Ingester.</li></ul><p><strong>Ingester</strong></p><ul><li>Menerima log dari Distributor.</li><li>Menyimpan log sementara di memori.</li><li>Mengelompokkan log menjadi <em>chunks.</em></li><li>Menulis data log (chunks) dan index ke object storage.</li></ul><p><strong>Object Storage (MinIO)</strong></p><ul><li>Menyimpan data log secara persisten.</li><li>Terdiri dari: Chunks (isi log), Index (metadata log).</li><li>Menggunakan MinIO yang bersifat <strong>S3 compatible.</strong></li></ul><p>Dengan menggunakan object storage, Loki dapat menyimpan log dalam jumlah besar dengan biaya lebih efisien dibandingkan penyimpanan berbasis disk lokal.</p><h4>Read Path (Alur Pembacaan Log)</h4><p>Ketika pengguna melakukan query melalui Grafana, alur pembacaan log akan berjalan sebagai berikut:</p><p><strong>Query Frontend</strong></p><ul><li>Menerima query LogQL dari Grafana.</li><li>Melakukan optimasi dan pembagian query.</li><li>Meneruskan query ke Querier.</li></ul><p><strong>Querier</strong></p><ul><li>Mengambil index dan chunks dari object storage.</li><li>Menggabungkan dan memproses data log.</li><li>Mengembalikan hasil query ke Query Frontend.</li></ul><p><strong>Caching Layer (Opsional)</strong></p><ul><li>Digunakan untuk menyimpan hasil query dan index.</li><li>Membantu meningkatkan performa query berulang.</li></ul><p>Hasil akhir kemudian ditampilkan di Grafana dalam bentuk tabel log atau visualisasi grafik.</p><h4>Komponen Pendukung</h4><p>Beberapa komponen tambahan juga berperan dalam arsitektur ini, antara lain:</p><ul><li><strong>Compactor</strong><br>Bertugas melakukan optimasi data log, seperti penggabungan chunk dan penerapan retention policy.</li><li><strong>Ruler</strong><br>Digunakan untuk rule evaluation dan alerting berbasis log (jika diaktifkan).</li></ul><p>Komponen-komponen ini memastikan data log tetap terkelola dengan baik dan tidak terus bertambah tanpa kontrol.</p><h4>Ringkasan Alur Sistem</h4><p>Secara ringkas, alur arsitektur dapat disimpulkan sebagai berikut:</p><ol><li>Pod Kubernetes menghasilkan log.</li><li>Grafana Alloy mengumpulkan dan mengirim log ke Loki.</li><li>Loki menyimpan log ke object storage melalui write path.</li><li>Grafana melakukan query melalui read path.</li><li>Log divisualisasikan dalam dashboard Grafana.</li></ol><p>Arsitektur ini dirancang agar <strong>scalable</strong>, <strong>fault-tolerant</strong>, dan <strong>mudah dikembangkan</strong> untuk kebutuhan observability di masa depan.</p><h3>Komponen yang Digunakan</h3><p>Implementasi centralized logging ini dibangun menggunakan beberapa komponen utama yang saling terintegrasi untuk mengumpulkan, menyimpan, dan memvisualisasikan log dari lingkungan Kubernetes. Berikut adalah komponen-komponen yang digunakan beserta perannya masing-masing.</p><h4>Azure Kubernetes Service (AKS)</h4><p><strong>Azure Kubernetes Service (AKS)</strong> digunakan sebagai platform utama untuk menjalankan seluruh workload. AKS berperan sebagai:</p><ul><li>Orkestrator container untuk aplikasi dan sistem observability.</li><li>Lingkungan terpusat untuk menjalankan Loki, Grafana, Alloy, dan MinIO.</li><li>Platform yang mendukung scaling dan manajemen resource secara terpusat.</li></ul><p>Penggunaan AKS memudahkan pengelolaan cluster Kubernetes tanpa harus mengelola control plane secara manual.</p><h4>Grafana Loki</h4><p><strong>Grafana Loki</strong> digunakan sebagai sistem log aggregation. Loki dirancang khusus untuk log dengan pendekatan <em>label-based indexing</em>, sehingga lebih efisien dibandingkan sistem log tradisional.</p><p>Peran Grafana Loki dalam arsitektur ini:</p><ul><li>Menerima log dari Grafana Alloy.</li><li>Menyimpan log ke object storage.</li><li>Menyediakan query log menggunakan LogQL.</li><li>Mendukung arsitektur scalable (read, write, backend terpisah).</li></ul><p>Pada implementasi ini, Loki dijalankan menggunakan <strong>Helm Chart resmi Grafana</strong> dalam mode <strong>scalable</strong>.</p><h4>Grafana Alloy</h4><p><strong>Grafana Alloy</strong> digunakan sebagai <strong>log collector</strong> yang berjalan di setiap node Kubernetes dalam bentuk DaemonSet.</p><p>Fungsi utama Grafana Alloy:</p><ul><li>Melakukan discovery pod Kubernetes secara otomatis.</li><li>Mengambil log dari file sistem /var/log/pods.</li><li>Menambahkan label metadata seperti namespace, pod, dan container.</li><li>Meneruskan log ke Grafana Loki.</li></ul><p>Grafana Alloy dipilih karena merupakan agent generasi terbaru dari Grafana yang lebih modular dan fleksibel dibandingkan Grafana Agent versi lama.</p><h4>Grafana</h4><p><strong>Grafana</strong> digunakan sebagai platform visualisasi dan eksplorasi log.</p><p>Peran Grafana dalam sistem ini:</p><ul><li>Menyediakan UI untuk query log menggunakan LogQL.</li><li>Menampilkan log dalam bentuk tabel dan grafik.</li><li>Membuat dashboard untuk monitoring aktivitas aplikasi.</li><li>Mengintegrasikan Loki sebagai datasource log.</li></ul><p>Grafana di-deploy menggunakan Helm dan dikonfigurasi agar dapat diakses melalui <strong>Service LoadBalancer</strong>.</p><h4>MinIO (Object Storage)</h4><p><strong>MinIO</strong> digunakan sebagai backend object storage untuk Grafana Loki.</p><p>Fungsi MinIO:</p><ul><li>Menyimpan chunks dan index log</li><li>Bertindak sebagai S3 compatible storage</li><li>Mendukung retensi data log dan optimasi penyimpanan</li></ul><p>MinIO dijalankan di dalam AKS menggunakan Helm Chart resmi dengan persistent volume agar data log tetap tersimpan meskipun pod direstart.</p><h4>Helm</h4><p><strong>Helm</strong> digunakan sebagai package manager untuk Kubernetes.</p><p>Peran Helm dalam implementasi ini:</p><ul><li>Mempermudah proses deployment Loki, Grafana, Alloy, dan MinIO</li><li>Mengelola konfigurasi melalui file values.yaml.</li><li>Memungkinkan perubahan konfigurasi tanpa redeploy manual.</li></ul><p>Dengan Helm, proses instalasi menjadi lebih konsisten dan dapat direproduksi di environment lain.</p><h4>LogQL</h4><p><strong>LogQL</strong> merupakan bahasa query yang digunakan oleh Grafana Loki.</p><p>Kegunaan LogQL:</p><ul><li>Melakukan pencarian log berbasis label.</li><li>Melakukan filter log berdasarkan isi pesan.</li><li>Mengubah log menjadi metrik (log-based metrics).</li><li>Digunakan sebagai dasar pembuatan dashboard Grafana.</li></ul><h3>STEP 1 Menyiapkan Object Storage (MinIO)</h3><p>Grafana Loki membutuhkan <strong>object storage</strong> untuk menyimpan data log dalam bentuk <strong>chunks</strong> dan <strong>index</strong>. Pada implementasi ini, object storage tidak menggunakan layanan cloud managed (seperti Azure Blob Storage), melainkan menggunakan <strong>MinIO</strong> yang dijalankan langsung di dalam cluster Kubernetes.</p><p>Pendekatan ini dipilih karena:</p><ul><li>Lebih mudah dikontrol dan dikonfigurasi.</li><li>Bersifat <strong>S3 compatible</strong>, sehingga cocok dengan Grafana Loki.</li><li>Tidak bergantung langsung pada layanan cloud tertentu.</li><li>Cocok untuk lingkungan pengujian maupun internal.</li></ul><p><strong>Menambahkan Helm Repository MinIO</strong></p><p>Langkah pertama adalah menambahkan Helm repository resmi MinIO.</p><pre>helm repo add minio https://charts.min.io/<br>helm repo update</pre><p><strong>Membuat Namespace MinIO</strong></p><p>Agar resource MinIO terisolasi dengan baik, MinIO dijalankan pada namespace khusus.</p><pre>kubectl create namespace minio</pre><p><strong>Instalasi MinIO Menggunakan Helm</strong></p><p>MinIO di deploy menggunakan mode <strong>standalone</strong> dengan persistent volume agar data tetap tersimpan meskipun pod direstart.</p><pre>helm install minio minio/minio \<br>  -n minio \<br>  --set mode=standalone \<br>  --set replicas=1 \<br>  --set persistence.enabled=true \<br>  --set persistence.storageClass=managed-csi \<br>  --set persistence.size=10Gi \<br>  --set rootUser=&lt;MINIO_ACCESS_KEY&gt; \<br>  --set rootPassword=&lt;MINIO_SECRET_KEY&gt; \<br>  --set service.type=LoadBalancer</pre><p>Konfigurasi utama yang digunakan:</p><ul><li><strong>mode=standalone: </strong>satu instance MinIO.</li><li><strong>persistence.enabled=true: </strong>data disimpan di PVC.</li><li><strong>storageClass=managed-csi: </strong>storage default AKS.</li><li><strong>service.type=LoadBalancer: </strong>MinIO dapat diakses dari luar cluster.</li></ul><p><strong>Verifikasi Status MinIO</strong></p><p>Setelah instalasi selesai, pastikan pod MinIO berjalan dengan normal.</p><pre>kubectl get pods -n minio</pre><p>Output yang diharapkan:</p><pre>minio-xxxxxxxxxx   1/1   Running</pre><p>Cek juga service MinIO untuk memastikan external IP sudah tersedia.</p><pre>kubectl get svc -n minio</pre><p><strong>Membuat Bucket untuk Grafana Loki</strong></p><p>Grafana Loki membutuhkan beberapa bucket untuk menyimpan data log dan metadata. Bucket yang digunakan pada implementasi ini adalah:</p><ul><li>loki-chunks</li><li>loki-ruler</li><li>loki-admin</li></ul><p>Bucket dibuat menggunakan <strong>MinIO Client (mc)</strong> yang dijalankan di dalam cluster.</p><pre>kubectl run mc --rm -it \<br>  --image=minio/mc \<br>  -n minio -- \<br>  alias set local http://minio.minio.svc.cluster.local:9000 &lt;MINIO_ACCESS_KEY&gt; &lt;MINIO_SECRET_KEY&gt;</pre><p>Kemudian buat bucket:</p><pre>kubectl run mc --rm -it \<br>  --image=minio/mc \<br>  -n minio -- \<br>  mb local/loki-chunks<br><br>kubectl run mc --rm -it \<br>  --image=minio/mc \<br>  -n minio -- \<br>  mb local/loki-ruler<br><br>kubectl run mc --rm -it \<br>  --image=minio/mc \<br>  -n minio -- \<br>  mb local/loki-admin</pre><p><strong>Ringkasan Step 1</strong></p><p>Pada tahap ini, kita telah berhasil:</p><ul><li>Menjalankan MinIO di AKS.</li><li>Mengaktifkan persistent storage untuk MinIO.</li><li>Menyiapkan bucket yang dibutuhkan Grafana Loki.</li><li>Memastikan MinIO dapat diakses oleh workload di dalam cluster.</li></ul><p>Object storage ini akan digunakan pada step selanjutnya sebagai backend penyimpanan Grafana Loki.</p><h3>STEP 2 Deploy Grafana Loki (Scalable Mode)</h3><p>Setelah object storage (MinIO) siap digunakan, langkah berikutnya adalah melakukan deployment <strong>Grafana Loki</strong> sebagai sistem log aggregation. Pada implementasi ini, Grafana Loki dijalankan menggunakan <strong>Helm Chart resmi Grafana</strong> dengan <strong>mode scalable</strong>.</p><p>Mode scalable dipilih agar komponen Loki dapat dipisahkan berdasarkan fungsinya, sehingga arsitektur lebih terstruktur, mudah dikembangkan, dan siap untuk skala yang lebih besar di masa depan.</p><h4>Mode Scalable pada Grafana Loki</h4><p>Grafana Loki scalable mode memisahkan beberapa komponen utama, antara lain:</p><ul><li><strong>Read: </strong>menangani query log</li><li><strong>Write: </strong>menerima dan menulis log</li><li><strong>Backend: </strong>mengelola storage, index, dan lifecycle data</li><li><strong>Gateway: </strong>single entry point untuk read &amp; write</li><li><strong>Compactor: </strong>mengelola retention dan optimasi data</li></ul><p>Pendekatan ini berbeda dengan <em>single binary mode</em> yang seluruh fungsinya berjalan dalam satu pod.</p><h4>Konfigurasi Loki (values.yaml)</h4><p>Berikut adalah konfigurasi values.yaml yang digunakan untuk deployment Grafana Loki pada implementasi ini, beserta penjelasan masing-masing bagian.</p><pre>test:<br>  enabled: false<br><br>monitoring:<br>  selfMonitoring:<br>    enabled: false<br>    grafanaAgent:<br>      installOperator: false<br><br>read:<br>  replicas: 1<br><br>write:<br>  replicas: 1<br><br>backend:<br>  replicas: 1<br>  persistence:<br>    enabled: false<br>  extraVolumes:<br>    - name: retention<br>      emptyDir: {}<br>  extraVolumeMounts:<br>    - name: retention<br>      mountPath: /data<br><br>loki:<br>  auth_enabled: false<br><br>  commonConfig:<br>    replication_factor: 1<br><br>  limits_config:<br>    retention_period: 25h<br>    max_query_lookback: 25h<br><br>  compactor:<br>    working_directory: /data/retention<br>    retention_enabled: true<br>    delete_request_store: s3<br><br>  schemaConfig:<br>    configs:<br>      - from: 2024-04-01<br>        store: tsdb<br>        object_store: s3<br>        schema: v13<br>        index:<br>          prefix: index_<br>          period: 24h<br>        chunks:<br>          period: 24h<br><br>  storage:<br>    type: s3<br>    bucketNames:<br>      chunks: loki-chunks<br>      ruler: loki-ruler<br>      admin: loki-admin<br>    s3:<br>      endpoint: http://minio.minio.svc.cluster.local:9000<br>      accessKeyId: minioadmin<br>      secretAccessKey: minioadmin<br>      s3ForcePathStyle: true<br>      insecure: true</pre><p><strong>Test Configuration</strong></p><pre>test:<br>  enabled: false</pre><p>Penjelasan:</p><ul><li>Menonaktifkan deployment resource testing bawaan Helm chart.</li><li>Digunakan untuk environment non-testing.</li><li>Mengurangi resource yang tidak dibutuhkan.</li></ul><p><strong>Monitoring &amp; Self-Monitoring</strong></p><pre>monitoring:<br>  selfMonitoring:<br>    enabled: false<br>    grafanaAgent:<br>      installOperator: false</pre><p>Penjelasan:</p><ul><li>selfMonitoring.enable: false = Loki <strong>tidak mengirim metric internal ke sistem monitoring.</strong></li><li>installOperator: false =<strong> Helm chart Loki tidak menginstall Grafana Agent bawaan.</strong></li></ul><p>Alasan:</p><ul><li>Log collector <strong>dikontrol sendiri menggunakan Grafana Alloy.</strong></li><li>Menghindari duplikasi agent dan konflik konfigurasi.</li></ul><p><strong>Read &amp; Write Component</strong></p><pre>read:<br>  replicas: 1<br><br>write:<br>  replicas: 1</pre><p>Penjelasan:</p><ul><li>read menangani query log dari Grafana.</li><li>write menerima log dari Alloy.</li><li>Replica diset 1 karena implementasi ini masih tahap awal / internal.</li></ul><p><em>Jumlah replica dapat ditingkatkan di production environment untuk high availability.</em></p><p><strong>Backend Component</strong></p><pre>backend:<br>  replicas: 1<br>  persistence:<br>    enabled: false<br>  extraVolumes:<br>    - name: retention<br>      emptyDir: {}<br>  extraVolumeMounts:<br>    - name: retention<br>      mountPath: /data</pre><p>Penjelasan:</p><ul><li>Backend bertanggung jawab terhadap: index, metadata dan compactor</li><li>persistence.enabled: false = Backend tidak menyimpan data di PVC lokal.</li><li>Data log sepenuhnya disimpan di <strong>object storage (MinIO).</strong></li></ul><p>Extra Volume:</p><ul><li>emptyDir digunakan untuk: direktori kerja compactor dan penyimpanan sementara (ephemeral).</li></ul><p><strong>Authentication Configuration</strong></p><pre>loki:<br>  auth_enabled: false</pre><p>Penjelasan:</p><ul><li>Authentication Loki dinonaktifkan</li><li>Cocok untuk: internal cluster dan akses trusted (Grafana &amp; Alloy di cluster yang sama)</li></ul><p><em>Untuk multi-tenant atau public access, auth sebaiknya diaktifkan.</em></p><p><strong>Replication Configuration</strong></p><pre>commonConfig:<br>  replication_factor: 1</pre><p>Penjelasan:</p><ul><li>Menentukan jumlah replika data log</li><li>1 berarti: tidak ada replikasi data dan cocok untuk environment non-critical.</li></ul><p><em>Pada production environment, nilai ini sebaiknya ≥=3.</em></p><p><strong>Retention &amp; Query Limits</strong></p><pre>limits_config:<br>  retention_period: 25h<br>  max_query_lookback: 25h</pre><p>Penjelasan:</p><ul><li>retention_period = log disimpan selama 25 jam.</li><li>max_query_lookback = membatasi query agar tidak melebihi periode retensi.</li></ul><p>Manfaat:</p><ul><li>Mengontrol biaya storage.</li><li>Mencegah query berat terhadap data lama.</li></ul><p><strong>Compactor Configuration</strong></p><pre>compactor:<br>  working_directory: /data/retention<br>  retention_enabled: true<br>  delete_request_store: s3</pre><p>Penjelasan:</p><ul><li>Compactor bertugas: menghapus data log lama dan mengoptimalkan chunk dan index.</li><li>delete_request_store: s3 = metadata delete disimpan di object storage.</li></ul><p><strong>Schema Configuration</strong></p><pre>schemaConfig:<br>  configs:<br>    - from: 2026-08-01<br>      store: tsdb<br>      object_store: s3<br>      schema: v13<br>      index:<br>        prefix: index_<br>        period: 24h<br>      chunks:<br>        period: 24h</pre><p>Penjelasan:</p><ul><li>Menggunakan <strong>TSDB schema (v13)</strong> schema terbaru Loki.</li><li>Index dan chunk diputar setiap 24 jam.</li><li>Object store diarahkan ke backend S3 compatible.</li></ul><p><strong>Storage Configuration (MinIO)</strong></p><pre>storage:<br>  type: s3<br>  bucketNames:<br>    chunks: loki-chunks<br>    ruler: loki-ruler<br>    admin: loki-admin<br>  s3:<br>    endpoint: http://minio.minio.svc.cluster.local:9000<br>    accessKeyId: &lt;MINIO_ACCESS_KEY&gt;<br>    secretAccessKey: &lt;MINIO_SECRET_KEY&gt;<br>    s3ForcePathStyle: true<br>    insecure: true</pre><p>Penjelasan:</p><ul><li>Loki menggunakan backend <strong>S3 compatible.</strong></li><li>Endpoint diarahkan ke MinIO internal Kubernetes.</li><li>s3ForcePathStyle: true = wajib untuk MinIO.</li><li>insecure: true = menggunakan HTTP (internal cluster).</li></ul><p><em>Credential MinIO tidak ditampilkan secara eksplisit pada dokumentasi publik.</em></p><h4><strong>Instalasi Grafana Loki Menggunakan Helm</strong></h4><p>Setelah konfigurasi siap, Grafana Loki di-deploy menggunakan perintah berikut:</p><pre>helm install loki grafana/loki \<br>  -n loki \<br>  --create-namespace \<br>  -f loki-scalable-values.yml</pre><h4><strong>Verifikasi Deployment Loki</strong></h4><pre>kubectl get pods -n loki</pre><p>Deployment dianggap berhasil jika seluruh pod Loki berada dalam status running.</p><h4>Ringkasan Step 2</h4><p>Pada tahap ini, kita telah berhasil:</p><ul><li>Menjalankan Grafana Loki dalam scalable mode.</li><li>Mengonfigurasi backend storage menggunakan MinIO.</li><li>Mengaktifkan retention policy.</li><li>Menyiapkan sistem log yang siap menerima data dari log collector.</li></ul><p>Grafana Loki kini siap menerima log dari Grafana Alloy pada tahap selanjutnya.</p><h3>STEP 3 Configure Log Collection (Grafana Alloy)</h3><p>Setelah Grafana Loki berhasil dijalankan dan backend storage siap, langkah berikutnya adalah <strong>mengumpulkan log dari Kubernetes dan mengirimkannya ke Loki</strong>. Untuk kebutuhan ini, digunakan <strong>Grafana Alloy</strong> sebagai log collector.</p><p>Grafana Alloy dijalankan sebagai <strong>DaemonSet</strong>, sehingga setiap node Kubernetes memiliki satu instance Alloy yang bertugas membaca log dari pod yang berjalan di node tersebut.</p><h4>Peran Grafana Alloy dalam Arsitektur</h4><p>Grafana Alloy berfungsi sebagai:</p><ul><li>Melakukan <strong>discovery pod Kubernetes.</strong></li><li>Membaca file log container dari /var/log/pods.</li><li>Menambahkan metadata (label) seperti: namespace, pod, container.</li><li>Melakukan parsing log (opsional).</li><li>Mengirim log ke Grafana Loki melalui HTTP API.</li></ul><p>Dengan pendekatan ini, <strong>tidak diperlukan konfigurasi manual per aplikasi</strong>. Semua pod yang berjalan di cluster otomatis dapat dikumpulkan log nya.</p><h4>Menjalankan Grafana Alloy sebagai DaemonSet</h4><p>Agar Grafana Alloy dapat membaca log seluruh pod di setiap node, Alloy dijalankan dalam mode <strong>DaemonSet</strong>.</p><p>Konfigurasi ini memastikan:</p><ul><li>Satu pod Alloy berjalan di setiap node.</li><li>Alloy memiliki akses langsung ke file log container pada node tersebut.</li></ul><h4>Membuat Namespace Alloy</h4><p>Grafana Alloy dijalankan pada namespace terpisah agar lebih terisolasi dan mudah dikelola.</p><pre>kubectl create namespace alloy-logs</pre><h4>Konfigurasi Deployment Alloy (alloy-logs-values.yml)</h4><p>Berikut adalah konfigurasi Helm values untuk menjalankan Grafana Alloy sebagai log collector:</p><pre>alloy:<br>  configMap:<br>    create: false<br>    name: alloy-config<br>    key: config.alloy<br>  clustering:<br>    enabled: false<br>  mounts:<br>    varlog: true<br><br>controller:<br>  type: &#39;daemonset&#39;</pre><p><strong>Penjelasan Setiap Bagian Konfigurasi</strong></p><p><strong>controller.type: daemonset</strong></p><pre>controller:<br>  type: &#39;daemonset&#39;</pre><p>Pengaturan ini menentukan <strong>cara Grafana Alloy dijalankan di Kubernetes</strong>.</p><ul><li>daemonset berarti: s<strong>atu pod Alloy akan berjalan di setiap node Kubernetes </strong>dan alloy dapat mengakses log container yang berada langsung di node tersebut.</li></ul><p>Kenapa DaemonSet penting?</p><p>Log Kubernetes disimpan di filesystem <strong>node</strong>, tepatnya di:</p><pre>/var/log/pods/</pre><p>Agar Alloy bisa membaca log tersebut:</p><ul><li>Alloy <strong>harus berjalan di node yang sama.</strong></li><li>Tidak cukup hanya satu pod Alloy (Deployment).</li></ul><p>Karena itu, <strong>DaemonSet adalah pilihan yang benar dan wajib</strong> untuk log collection berbasis file.</p><p><strong>alloy.mounts.varlog: true</strong></p><pre>alloy:<br>  mounts:<br>    varlog: true</pre><p>Konfigurasi ini:</p><ul><li>Mem-mount direktori /var/log dari <strong>node host.</strong></li><li>Ke dalam container Grafana Alloy.</li></ul><p>Sehingga di dalam container Alloy:</p><pre>/var/log/pods/</pre><p>berisi log semua container Kubernetes di node tersebut.</p><p>Tanpa konfigurasi ini:</p><ul><li>Alloy <strong>tidak bisa membaca log pod.</strong></li><li>Log collection <strong>tidak akan bekerja.</strong></li></ul><p><strong>alloy.configMap</strong></p><pre>alloy:<br>  configMap:<br>    create: false<br>    name: alloy-config<br>    key: config.alloy</pre><p>Bagian ini mengatur <strong>sumber konfigurasi pipeline Grafana Alloy</strong>.</p><p><strong>create: false</strong></p><ul><li>Helm <strong>tidak membuat ConfigMap otomatis.</strong></li><li>ConfigMap dikelola secara manual / terpisah.</li></ul><p>Tujuannya:</p><ul><li>Konfigurasi lebih <strong>modular.</strong></li><li>Mudah diubah tanpa reinstall chart.</li><li>Lebih rapi untuk production.</li></ul><p><strong>name: alloy-config</strong></p><p>Nama ConfigMap Kubernetes yang berisi konfigurasi Alloy.</p><p>ConfigMap ini berisi:</p><ul><li>Discovery pod Kubernetes.</li><li>Relabeling &amp; enrichment label.</li><li>Parsing log.</li><li>Endpoint Loki tujuan.</li></ul><p><strong>key: config.alloy</strong></p><p>Key di dalam ConfigMap yang digunakan sebagai:</p><ul><li><strong>file konfigurasi utama Grafana Alloy</strong></li></ul><p>Contoh struktur ConfigMap:</p><pre>data:<br>  config.alloy: |<br>    discovery.kubernetes &quot;pods&quot; { ... }</pre><p><strong>alloy.clustering.enabled: false</strong></p><pre>alloy:<br>  clustering:<br>    enabled: false</pre><p>Clustering <strong>dinonaktifkan</strong> karena:</p><ul><li>Alloy hanya berperan sebagai <strong>log shipper.</strong></li><li>Tidak menyimpan state.</li><li>Tidak membutuhkan koordinasi antar pod.</li></ul><p>Clustering biasanya hanya diperlukan untuk:</p><ul><li>Stateful agent.</li><li>Advanced HA use case.</li></ul><h4>Penjelasan Konfigurasi Grafana Alloy (alloy-logs-configMap.yml)</h4><p>ConfigMap ini berisi <strong>pipeline Grafana Alloy</strong> yang menentukan bagaimana log Kubernetes:</p><ol><li>Ditemukan (discovery).</li><li>Diberi label (relabel).</li><li>Dibaca dari filesystem.</li><li>Diproses (parsing &amp; enrichment).</li><li>Dikirim ke Grafana Loki.</li></ol><p>Pipeline ini memastikan log dari pod Kubernetes dapat dikonsumsi dan dianalisis menggunakan <strong>LogQL</strong> di Grafana.</p><pre>apiVersion: v1<br>data:<br>  config.alloy: |<br>     discovery.kubernetes &quot;pods&quot; {<br>       role = &quot;pod&quot;<br>     }<br><br>     discovery.relabel &quot;pod_logs&quot; {<br>       targets = discovery.kubernetes.pods.targets<br>       rule {<br>         source_labels = [&quot;__meta_kubernetes_namespace&quot;]<br>         target_label  = &quot;namespace&quot;<br>       }<br>       rule {<br>         source_labels = [&quot;__meta_kubernetes_pod_name&quot;]<br>         target_label  = &quot;pod&quot;<br>       }<br>       rule {<br>         source_labels = [&quot;__meta_kubernetes_pod_container_name&quot;]<br>         target_label  = &quot;container&quot;<br>       }<br>       rule {<br>         source_labels = [&quot;__meta_kubernetes_namespace&quot;, &quot;__meta_kubernetes_pod_name&quot;]<br>         separator     = &quot;/&quot;<br>         target_label  = &quot;job&quot;<br>       }<br>       rule {<br>         source_labels = [&quot;__meta_kubernetes_pod_uid&quot;, &quot;__meta_kubernetes_pod_container_name&quot;]<br>         separator     = &quot;/&quot;<br>         action        = &quot;replace&quot;<br>         replacement   = &quot;/var/log/pods/*$1/*.log&quot;<br>         target_label  = &quot;__path__&quot;<br>       }<br>       rule {<br>         action = &quot;replace&quot;<br>         source_labels = [&quot;__meta_kubernetes_pod_container_id&quot;]<br>         regex = &quot;^(\\w+):\\/\\/.+$&quot;<br>         replacement = &quot;$1&quot;<br>         target_label = &quot;tmp_container_runtime&quot;<br>       }<br>     }<br><br>     local.file_match &quot;pod_logs&quot; {<br>       path_targets = discovery.relabel.pod_logs.output<br>     }<br><br>     loki.source.file &quot;pod_logs&quot; {<br>       targets    = local.file_match.pod_logs.targets<br>       forward_to = [loki.process.pod_logs.receiver]<br>     }<br><br>     loki.process &quot;pod_logs&quot; {<br>       stage.match {<br>         selector = &quot;{namespace=~\&quot;(ngin|ngim)x\&quot;}&quot;<br>         stage.regex {<br>           expression = &quot;(?P&lt;method&gt;GET|PUT|DELETE|POST)&quot;<br>         }<br>         stage.regex {<br>           expression = &quot;(?P&lt;status_code_with_http_version&gt;HTTP.{6}\\d{3})&quot;<br>         }<br>         stage.regex {<br>           expression = &quot;(?P&lt;status_code&gt;\\d{3})&quot;<br>           source = &quot;status_code_with_http_version&quot;<br>         }<br>         stage.labels {<br>           values = {<br>             method = &quot;&quot;,<br>             status_code = &quot;&quot;,<br>           }<br>         }<br>       }<br>       stage.match {<br>         selector = &quot;{tmp_container_runtime=\&quot;containerd\&quot;}&quot;<br>         stage.cri {}<br>         stage.labels {<br>           values = {<br>             flags   = &quot;&quot;,<br>             stream  = &quot;&quot;,<br>           }<br>         }<br>       }<br>       stage.match {<br>         selector = &quot;{tmp_container_runtime=\&quot;docker\&quot;}&quot;<br>         stage.docker {}<br>         stage.labels {<br>           values = {<br>             stream  = &quot;&quot;,<br>           }<br>         }<br>       }<br>       stage.label_drop {<br>         values = [&quot;tmp_container_runtime&quot;]<br>       }<br><br>       forward_to = [loki.write.loki.receiver]<br>     }<br><br>     loki.write &quot;loki&quot; {<br>       endpoint {<br>         url = &quot;http://loki-gateway.loki.svc.cluster.local/loki/api/v1/push&quot;<br>       }<br>     }<br>kind: ConfigMap<br>metadata:<br>  name: alloy-config<br>  namespace: alloy-logs</pre><p><strong>Kubernetes Pod Discovery</strong></p><pre>discovery.kubernetes &quot;pods&quot; {<br>  role = &quot;pod&quot;<br>}</pre><p>Fungsi:</p><ul><li>Alloy melakukan <strong>discovery seluruh pod Kubernetes.</strong></li><li>Metadata Kubernetes otomatis tersedia, seperti: namespace, pod name, container name, pod UID, container runtime</li></ul><p><em>Tanpa tahap ini, Alloy </em><strong><em>tidak tahu pod mana saja yang ada di cluster</em></strong><em>.</em></p><p><strong>Relabeling &amp; Metadata Enrichment</strong></p><pre>discovery.relabel &quot;pod_logs&quot; {<br>  targets = discovery.kubernetes.pods.targets</pre><p>Bagian ini adalah <strong>jantung konfigurasi</strong> karena:</p><ul><li>Mengubah metadata Kubernetes menjadi <strong>label Loki.</strong></li><li>Menentukan <strong>file log mana yang harus dibaca.</strong></li></ul><p><strong>Menambahkan Label Namespace</strong></p><pre>rule {<br>  source_labels = [&quot;__meta_kubernetes_namespace&quot;]<br>  target_label  = &quot;namespace&quot;<br>}</pre><p>Setiap log akan memiliki label:</p><pre>namespace=&quot;&lt;nama-namespace&gt;&quot;</pre><p>Ini penting untuk filtering LogQL, misalnya:</p><pre>{namespace=&quot;default&quot;}</pre><p><strong>Menambahkan Label Pod</strong></p><pre>rule {<br>  source_labels = [&quot;__meta_kubernetes_pod_name&quot;]<br>  target_label  = &quot;pod&quot;<br>}</pre><p>Memudahkan tracing log ke pod tertentu.</p><p><strong>Menambahkan Label Container</strong></p><pre>rule {<br>  source_labels = [&quot;__meta_kubernetes_pod_container_name&quot;]<br>  target_label  = &quot;container&quot;<br>}</pre><p>Berguna saat satu pod memiliki <strong>lebih dari satu container</strong>.</p><p><strong>Membuat Label job</strong></p><pre>rule {<br>  source_labels = [&quot;__meta_kubernetes_namespace&quot;, &quot;__meta_kubernetes_pod_name&quot;]<br>  separator     = &quot;/&quot;<br>  target_label  = &quot;job&quot;<br>}</pre><p>Menghasilkan label:</p><pre>job=&quot;namespace/pod-name&quot;</pre><p>Label ini sering dipakai sebagai <strong>entry point query LogQL</strong>.</p><p><strong>Menentukan Path File Log</strong></p><pre>rule {<br>  source_labels = [&quot;__meta_kubernetes_pod_uid&quot;, &quot;__meta_kubernetes_pod_container_name&quot;]<br>  separator     = &quot;/&quot;<br>  replacement   = &quot;/var/log/pods/*$1/*.log&quot;<br>  target_label  = &quot;__path__&quot;<br>}</pre><p>Fungsi:</p><ul><li>Menentukan <strong>lokasi file log container di node.</strong></li><li>Format ini sesuai standar Kubernetes.</li></ul><p>Contoh path:</p><pre>/var/log/pods/&lt;pod-uid&gt;/&lt;container-name&gt;/*.log</pre><p>Tanpa __path__, Alloy <strong>tidak bisa membaca log sama sekali</strong>.</p><p><strong>Deteksi Container Runtime</strong></p><pre>rule {<br>  source_labels = [&quot;__meta_kubernetes_pod_container_id&quot;]<br>  regex = &quot;^(\\w+):\\/\\/.+$&quot;<br>  replacement = &quot;$1&quot;<br>  target_label = &quot;tmp_container_runtime&quot;<br>}</pre><p>Mendeteksi apakah container menggunakan:</p><ul><li>containerd</li><li>docker</li></ul><p>Label ini bersifat <strong>sementara</strong> dan hanya dipakai untuk parsing.</p><p><strong>File Matching</strong></p><pre>local.file_match &quot;pod_logs&quot; {<br>  path_targets = discovery.relabel.pod_logs.output<br>}</pre><p>Fungsi:</p><ul><li>Mencocokkan file log berdasarkan path hasil relabeling.</li><li>Menyiapkan daftar file yang akan dibaca Alloy.</li></ul><p><strong>Membaca Log File</strong></p><pre>loki.source.file &quot;pod_logs&quot; {<br>  targets    = local.file_match.pod_logs.targets<br>  forward_to = [loki.process.pod_logs.receiver]<br>}</pre><p>Alloy mulai:</p><ul><li>Membaca isi file log.</li><li>Mengirim log ke tahap processing.</li></ul><p><strong>Log Processing Pipeline</strong></p><pre>loki.process &quot;pod_logs&quot; {</pre><p>Tahap ini digunakan untuk:</p><ul><li>Parsing log.</li><li>Enrichment label.</li><li>Normalisasi format log.</li></ul><p><strong>Parsing Log Nginx (Contoh)</strong></p><pre>stage.match {<br>  selector = &quot;{namespace=~\&quot;(ngin|ngim)x\&quot;}&quot;</pre><p>Pipeline ini hanya aktif untuk namespace yang mengandung nginx.</p><p><strong>Ekstraksi HTTP Method</strong></p><pre>stage.regex {<br>  expression = &quot;(?P&lt;method&gt;GET|PUT|DELETE|POST)&quot;<br>}</pre><p>Menghasilkan label:</p><pre>method=&quot;GET&quot;</pre><p><strong>Ekstraksi HTTP Status Code</strong></p><pre>stage.regex {<br>  expression = &quot;(?P&lt;status_code&gt;\\d{3})&quot;<br>}</pre><p>Memungkinkan analisis error seperti:</p><pre>{status_code=&quot;500&quot;}</pre><p><strong>Parsing Berdasarkan Container Runtime</strong></p><p>Containerd</p><pre>stage.match {<br>  selector = &quot;{tmp_container_runtime=\&quot;containerd\&quot;}&quot;<br>  stage.cri {}<br>}</pre><p>Docker</p><pre>stage.match {<br>  selector = &quot;{tmp_container_runtime=\&quot;docker\&quot;}&quot;<br>  stage.docker {}<br>}</pre><p>Menyesuaikan parsing dengan format log masing-masing runtime.</p><p><strong>Membersihkan Label Sementara</strong></p><pre>stage.label_drop {<br>  values = [&quot;tmp_container_runtime&quot;]<br>}</pre><p>Menghindari label internal muncul di Grafana.</p><p><strong>Mengirim Log ke Grafana Loki</strong></p><pre>loki.write &quot;loki&quot; {<br>  endpoint {<br>    url = &quot;http://loki-gateway.loki.svc.cluster.local/loki/api/v1/push&quot;<br>  }<br>}</pre><p>Fungsi</p><ul><li>Mengirim log ke <strong>Loki Gateway.</strong></li><li>Gateway meneruskan log ke: distributor, ingester, dan object storage.</li></ul><p>Metadata ConfigMap</p><pre>metadata:<br>  name: alloy-config<br>  namespace: alloy-logs</pre><p>ConfigMap ini:</p><ul><li>Dipakai langsung oleh Helm Chart Grafana Alloy.</li><li>Di-mount sebagai konfigurasi runtime Alloy.</li></ul><h4>Menerapkan Konfigurasi Grafana Alloy</h4><p>Setelah seluruh konfigurasi Grafana Alloy selesai ditulis, langkah selanjutnya adalah <strong>menerapkan konfigurasi tersebut ke cluster Kubernetes</strong>.</p><p>Pada tahap ini:</p><ul><li>alloy-logs-configMap.yaml berisi <strong>pipeline log.</strong></li><li>alloy-logs-values.yaml berisi <strong>cara Alloy dijalankan</strong></li></ul><p>Kedua file ini <strong>baru akan aktif setelah Grafana Alloy dijalankan melalui Helm</strong>.</p><p><strong>Menerapkan ConfigMap Grafana Alloy</strong></p><p>ConfigMap yang berisi pipeline Grafana Alloy diterapkan terlebih dahulu:</p><pre>kubectl apply -f grafana-alloy-resources/alloy-logs-configMap.yml</pre><p>Langkah ini menyimpan konfigurasi pipeline Alloy di cluster Kubernetes dan akan digunakan oleh pod Alloy saat dijalankan.</p><p><strong>Menjalankan Grafana Alloy Menggunakan Helm</strong></p><p>Grafana Alloy kemudian dijalankan menggunakan Helm dengan konfigurasi yang telah dibuat sebelumnya.</p><pre>helm install alloy grafana/alloy \<br>  -n alloy-logs \<br>  -f loki-scenario/alloy-logs-values.yml</pre><p>Perintah ini akan:</p><ul><li>Menjalankan Alloy sebagai DaemonSet.</li><li>Mengaitkan Alloy dengan ConfigMap alloy-config.</li><li>Mengaktifkan log collection di setiap node Kubernetes.</li></ul><p><strong>Verifikasi Deployment Grafana Alloy</strong></p><p>Pastikan seluruh pod Grafana Alloy berjalan dengan normal:</p><pre>kubectl get pods -n alloy-logs</pre><p>Jumlah pod Alloy seharusnya sama dengan jumlah node Kubernetes.</p><h4>Ringkasan step 3</h4><p>Pada tahap ini, Grafana Alloy berperan sebagai <strong>log collector terdistribusi</strong> yang berjalan di setiap node Kubernetes dan bertugas mengirimkan log aplikasi ke Grafana Loki.</p><p>Alur lengkap prosesnya adalah sebagai berikut:</p><p><strong>Grafana Alloy dijalankan sebagai DaemonSet</strong><br>Alloy berjalan di setiap node Kubernetes sehingga memiliki akses langsung ke log container yang tersimpan di node.</p><p><strong>Alloy melakukan discovery pod Kubernetes</strong><br>Alloy secara otomatis menemukan seluruh pod yang berjalan di cluster tanpa perlu konfigurasi manual per aplikasi.</p><p><strong>Metadata pod dikonversi menjadi label Loki</strong><br>Informasi seperti:</p><ul><li>namespace</li><li>nama pod</li><li>nama container</li></ul><p>diubah menjadi label Loki untuk memudahkan filtering dan query log.</p><p><strong>File log container ditemukan di node</strong><br>Alloy mengakses file log container dari direktori:</p><pre>/var/log/pods/</pre><p><strong>Log dibaca dan diparse</strong><br>Alloy membaca log berdasarkan container runtime (containerd / docker) dan melakukan parsing agar format log konsisten.</p><p><strong>Log diperkaya (enrichment)</strong><br>Label tambahan ditambahkan ke log stream sehingga log memiliki konteks yang jelas saat dianalisis di Grafana.</p><p><strong>Log dikirim ke Grafana Loki</strong><br>Log yang telah diproses dikirim ke Grafana Loki melalui endpoint HTTP API(/loki/api/v1/push).</p><h3>STEP 4 Visualisasi Log Menggunakan Grafana &amp; LogQL</h3><p>Setelah log berhasil dikumpulkan oleh Grafana Alloy dan disimpan di Grafana Loki, langkah berikutnya adalah <strong>melakukan visualisasi dan eksplorasi log menggunakan Grafana</strong>.</p><p>Pada tahap ini, Grafana berperan sebagai <strong>antarmuka utama</strong> untuk:</p><ul><li>Melihat log secara real-time.</li><li>Melakukan pencarian dan filtering log.</li><li>Menganalisis pola log menggunakan LogQL.</li><li>Membuat dashboard monitoring berbasis log.</li></ul><p>Grafana dijalankan menggunakan Helm Chart resmi Grafana. Agar Grafana dapat langsung digunakan tanpa konfigurasi manual melalui UI, datasource Loki didefinisikan secara otomatis melalui file values.</p><h4>Menambahkan Loki sebagai Datasource Grafana</h4><p>Integrasi Grafana dengan Loki dilakukan menggunakan <strong>provisioning datasource</strong>, sehingga Loki otomatis tersedia saat Grafana pertama kali dijalankan.</p><p><strong>Konfigurasi Datasource Loki (loki-datasource-values.yaml)</strong></p><pre>datasources:<br>  datasources.yaml:<br>    apiVersion: 1<br>    datasources:<br>      - name: loki<br>        type: loki<br>        url: http://loki-gateway.loki<br>        access: proxy<br>        editable: true<br>        isDefault: true<br><br>service:<br>  type: LoadBalancer<br>  port: 80<br>  targetPort: 3000</pre><p><strong>Penjelasan Konfigurasi:</strong></p><p><strong>name: loki</strong><br>Nama datasource yang akan muncul di Grafana</p><p><strong>type: loki</strong><br>Menentukan jenis datasource sebagai Grafana Loki</p><p><strong>url: </strong><a href="http://loki-gateway.loki/"><strong>http://loki-gateway.loki</strong></a><br>Endpoint Loki Gateway di dalam cluster Kubernetes</p><p><strong>access: proxy</strong><br>Grafana bertindak sebagai proxy saat mengakses Loki</p><p><strong>isDefault: true</strong><br>Loki dijadikan datasource default untuk query log</p><p>Dengan konfigurasi ini, Grafana tidak memerlukan setup datasource manual melalui UI.</p><p><strong>Mengakses Grafana Menggunakan Service LoadBalancer</strong></p><p>Agar Grafana dapat diakses langsung dari luar cluster tanpa menggunakan port forward, Service Grafana dikonfigurasikan menggunakan <strong>LoadBalancer</strong>.</p><p>Konfigurasi Service Grafana</p><pre>service:<br>  type: LoadBalancer<br>  port: 80<br>  targetPort: 3000</pre><p>Penjelasan:</p><p><strong>type: LoadBalancer</strong></p><p>Kubernetes akan membuat public IP melalui cloud provider.</p><p><strong>port: 80</strong></p><p>Grafana dapat diakses melalui port HTTP standar.</p><p><strong>targetPort: 3000</strong></p><p>Port internal Grafana.</p><p>Dengan konfigurasi ini, Grafana dapat diakses langsung melalui browser menggunakan external IP yang diberikan oleh cloud provider.</p><h4><strong>Deploy Grafana Menggunakan Helm</strong></h4><p>Grafana di deploy dengan perintah berikut:</p><pre>helm install grafana grafana/grafana \<br>  -n grafana \<br>  --create-namespace \<br>  -f loki-scenario/loki-datasource-values.yml</pre><p>Setelah deployment selesai, pastikan pod Grafana berjalan dengan normal:</p><pre>kubectl get pods -n grafana</pre><h4>Mengakses Grafana UI</h4><p>Setelah deployment selesai, ambil external IP Grafana dengan perintah:</p><pre>kubectl get svc -n grafana</pre><p>Contoh output:</p><pre>grafana   LoadBalancer   10.0.0.5   20.xxx.xxx.xxx   80:xxxxx/TCP</pre><p>Grafana dapat diakses melalui browser pada alamat:</p><pre>http://&lt;EXTERNAL-IP&gt;</pre><h4>Eksplorasi Log Menggunakan LogQL</h4><p>Log dapat dieksplorasi melalui menu <strong>Explore</strong> di Grafana menggunakan LogQL.</p><p><strong>Contoh Query LogQL</strong></p><p>Menampilkan semua log:</p><pre>{namespace=~&quot;.+&quot;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tiD2JsGCWwZbcGngcgDXEQ.png" /></figure><p>Filter log berdasarkan namespace:</p><pre>{namespace=&quot;default&quot;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3BCPFH0EEw-wdSeKpYNEbg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*id7_p2GJPXthbYcQxuot5g.png" /></figure><p>Mencari log yang mengandung error:</p><pre>{namespace=&quot;default&quot;} |= &quot;error&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OVBNU_8l_zr-sEtrTFfFbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kc9T8d9HKybf9XtO5lpOgA.png" /></figure><h4>Visualisasi Log dan Dashboard</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDdsNTgAOPLB0n8lJksWhQ.png" /></figure><p>Query LogQL dapat disimpan ke dalam <strong>Grafana Dashboard</strong> dan divisualisasikan dalam bentuk:</p><ul><li>Table</li><li>Time series</li><li>Stat panel</li></ul><p>Dengan dashboard ini, log tidak hanya menjadi data mentah, tetapi juga alat monitoring dan troubleshooting aplikasi.</p><p><strong>Panel 1 Total Log per Menit</strong></p><p>Tujuan:</p><p>Melihat <strong>traffic log secara umum</strong> (apakah aplikasi aktif / spike).</p><p>Query LogQL</p><pre>count_over_time({namespace=~&quot;.+&quot;}[1m])</pre><p>Visualization</p><ul><li><strong>Time series</strong></li></ul><p>Artinya:</p><p><em>Berapa baris log yang masuk setiap 1 menit.</em></p><p><strong>Panel 2 Error Log per Menit</strong></p><p>Tujuan:</p><p>Monitoring <strong>error rate</strong> dari aplikasi.</p><p>Query LogQL</p><pre>count_over_time({namespace=~&quot;.+&quot;} |~ &quot;(?i)error|exception|failed&quot; [1m])</pre><p>Visualization</p><ul><li><strong>Time series</strong></li></ul><p><strong>Panel 3 Log Terbaru (Live Log View)</strong></p><p>Tujuan:</p><p>Melihat <strong>log mentah secara real-time</strong>.</p><p>Query LogQL</p><pre>{namespace=~&quot;.+&quot;}</pre><p>Visualization</p><ul><li><strong>Logs</strong></li></ul><p><strong>Panel 4 Top Pod dengan Log Terbanyak</strong></p><p>Tujuan:</p><p>Mengetahui <strong>pod mana yang paling “berisik”</strong>.</p><p>Query LogQL</p><pre>sum(count_over_time({namespace=~&quot;.+&quot;}[5m])) by (pod)</pre><p>Visualization</p><ul><li><strong>Bar chart</strong></li></ul><h4>Ringkasan Step 4</h4><p>Pada tahap ini, Grafana digunakan sebagai antarmuka visualisasi untuk log yang telah dikumpulkan oleh Grafana Alloy dan disimpan di Grafana Loki.</p><p>Melalui integrasi Loki sebagai datasource, Grafana memungkinkan eksplorasi log secara real-time menggunakan LogQL. Log dapat difilter berdasarkan namespace, pod, atau konten tertentu seperti error, serta diubah menjadi metrik sederhana untuk kebutuhan monitoring.</p><p>Dashboard Grafana dibuat untuk menampilkan:</p><ul><li>Total log per menit.</li><li>Error log per menit.</li><li>Distribusi log berdasarkan pod.</li><li>Tampilan log terbaru secara real-time.</li></ul><p>Dengan pendekatan ini, log tidak hanya berfungsi sebagai data mentah, tetapi juga menjadi alat observability yang dapat digunakan untuk monitoring dan troubleshooting aplikasi di Kubernetes.</p><p>Dengan mengombinasikan Grafana Loki, Grafana Alloy, dan Grafana, sistem centralized logging berhasil dibangun secara terdistribusi dan scalable di Kubernetes. Implementasi ini memberikan visibilitas penuh terhadap log aplikasi, mempermudah proses troubleshooting, serta menjadi fondasi awal untuk observability stack yang lebih matang di lingkungan cloud-native.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fdf66451097" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-on Observability: Membangun Logging Terdistribusi dengan Grafana Loki & Alloy]]></title>
            <link>https://medium.com/@nitaoktaviani2005/hands-on-observability-membangun-logging-terdistribusi-dengan-grafana-loki-alloy-adfc2365e1cd?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/adfc2365e1cd</guid>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 03:16:39 GMT</pubDate>
            <atom:updated>2026-01-06T03:16:39.499Z</atom:updated>
            <content:encoded><![CDATA[<p>Observability adalah salah satu fondasi penting dalam sistem modern, terutama pada arsitektur berbasis container dan microservices. Salah satu tantangan terbesar yang sering muncul adalah mengumpulkan, menyimpan dan menganalisis log dari banyak service secara efisien.</p><p>Dalam artikel ini, saya akan membagikan hasil eksplorasi dan pembelajaran saya saat melakukan hands-on lab Grafana Loki, mulai dari setup, arsitektur, hingga memahami bagaimana log dari Docker container bisa berubah menjadi query LogQL di Grafana.</p><p><em>Catatan: eksperimen ini menggunakan </em><strong><em>demo resmi dari dokumentasi Grafana Loki</em></strong><em>, dengan penjelasan tambahan berdasarkan pemahaman pribadi.</em></p><h4>Sekilas Tentang LGTM Stack</h4><p>LGTM Stack adalah singkatan dari:</p><ul><li>Loki: backend log aggregation.</li><li>Grafana: visualisasi.</li><li>Tempo: distributed tracing.</li><li>Mimir: metrics backend.</li></ul><p>Pada bab ini, fokus utama ada di logging, sehingga komponen yang digunakan adalah:</p><ul><li>Grafana Loki (penyimpanan log)</li><li>Grafana Alloy (log collector/agent)</li><li>Grafana (query &amp; visualisasi)</li></ul><h4>Arsitektur Singkat</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*z8GvT6pOD0Zt9zHNAxLjdA.png" /></figure><p>Gambar di atas menunjukkan <strong>alur end-to-end log</strong> mulai dari sumber aplikasi hingga proses analisis di Grafana. Secara umum, arsitektur Loki Stack dapat dibagi menjadi <strong>tiga lapisan utama:</strong> <strong>Log Sources → Loki Backend → Visualization &amp; Analysis</strong>.</p><p><strong>Log Sources</strong></p><p>Pada sisi paling kiri, terdapat berbagai sumber log, antara lain:</p><ul><li>Docker container</li><li>Kubernetes</li><li>Cloud Services (AWS, GCP, Azure)</li><li>Kafka</li><li>Format log: Logfmt, JSON, Syslog, OTLP, dan lainnya</li></ul><p>Log dari berbagai environment ini tidak dikirim langsung ke Loki, melainkan dikumpulkan terlebih dahulu oleh Grafana Alloy.</p><p><strong>Grafana Alloy</strong> berperan sebagai <em>telemetry collector</em> yang:</p><ul><li>Membaca log (stdout/stderr, file log, dsb.)</li><li>Menambahkan metadata dan label.</li><li>Melakukan preprocessing.</li><li>Meneruskan log ke Loki.</li></ul><p><strong>Loki</strong></p><p>Bagian tengah pada diagram adalah core Loki, yang terdiri dari beberapa komponen internal:</p><ul><li>Compactor: menggabungkan dan merapikan chunk serta index untuk efisiensi storage.</li></ul><p><em>Chunk adalah potongan data log yang dikumpulkan dan disimpan Loki secara bertahap (per label dan waktu) sebelum akhirnya ditulis ke storage agar efisien dan cepat di query.</em></p><ul><li>Distributor: menerima log dari Alloy dan mendistribusikan ke ingester.</li><li>Query Frontend: mengoptimalkan query (sharding, caching, parallelism)</li></ul><p><em>Sharding: teknik membagi satu query log besar menjadi beberapa bagian kecil (shard) agar bisa diproses oleh banyak querier secara bersamaan sehingga query lebih cepat.</em></p><p><em>Caching: mekanisme menyimpan hasil query atau data yang sering diakses di cache agar permintaan yang sama tidak perlu dihitung ulang.</em></p><p><em>Parallelism: kemampuan menjalankan banyak proses query secara bersamaan (concurrent) untuk mempercepat eksekusi pencarian log.</em></p><ul><li>Ingester: menyimpan log sementara di memory dan menuliskannya ke storage sebagai chunks.</li><li>Querier: menjalankan query logQL terhadap data log.</li><li>Ruler: mengevaluasi rule untuk alerting berbasis log.</li></ul><p><strong>Grafana</strong></p><p>Bagian paling kanan adalah Grafana, yang digunakan untuk:</p><ul><li>Logs Drilldown: eksplorasi log secara visual berbasis service/container.</li><li>Explore: menjalankan query LogQL secara manual.</li><li>Dashboard: visualisasi metrik berbasis log.</li><li>Alerting: membuat alert dari hasil query log.</li></ul><p>Grafana tidak menyimpan log, melainkan hanya melakukan query ke Loki dan menampilkan hasilnya.</p><h4>Persyarat</h4><p>Sebelum memulai, pastikan sudah terinstall:</p><ul><li>Docker</li><li>Docker Compose</li></ul><p>Sebagai alternatif, Grafana juga menyediakan Loki Quickstart Sandbox, yaitu environment interaktif dengan semua dependency sudah siap pakai.</p><h4>Deploy Loki Stack Menggunakan Docker Compose</h4><p>Pada bagian ini, Loki Stack akan dijalankan secara lokal menggunakan Docker Compose. Setup ini mengikuti <strong>Loki Fundamentals — Getting Started</strong>, namun dengan tambahan penjelasan agar lebih mudah dipahami, terutama bagi yang baru mengenal Loki.</p><p>Stack ini terdiri dari tiga komponen utama: Grafana Alloy, Grafana Loki, dan Grafana.</p><p>Catatan:</p><p><em>Quickstart ini diasumsikan dijalankan di Linux atau macOS. Pengguna Windows tetap bisa mengikuti langkah yang sama menggunakan </em><strong><em>Windows Subsystem for Linux (WSL)</em></strong><em>.</em></p><p><strong>Menjalankan Loki Stack</strong></p><p>Clone repository Loki Fundamentals dan masuk ke direktori project:</p><pre>git clone https://github.com/grafana/loki-fundamentals.git -b getting-started<br>cd loki-fundamentals</pre><p>Jalankan seluruh service menggunakan Docker Compose:</p><pre>docker compose up -d</pre><p>Setelah container berjalan, akan ada tiga service utama yang aktif:</p><ul><li>Grafana</li><li>Loki</li><li>Alloy</li></ul><p><strong>Verifikasi Service</strong></p><p>Masing-masing service bida diverifikasi melalui browser:</p><ul><li><strong>Alloy UI</strong><br> <a href="http://localhost:12345/graph">http://localhost:12345/graph</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QO8sIOjuyK2iROlIaePu4Q.png" /></figure><ul><li><strong>Grafana</strong><br> <a href="http://localhost:3000/">http://localhost:3000</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m9sXWpV0l056PCi6oBwZdQ.png" /></figure><ul><li><strong>Loki Metrics</strong><br> <a href="http://localhost:3100/metrics">http://localhost:3100/metrics</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*odVsAX_wB9FN2byrMMvuXw.png" /></figure><p>Karena Grafana Alloy sudah dikonfigurasi untuk membaca log dari semua Docker container, Loki akan langsung menerima log sejak awal, bahkan tanpa aplikasi tambahan.</p><p><strong>Penjelasan Konfigurasi Loki Stack</strong></p><p>Agar lebih memahami apa yang sebenarnya terjadi, kita perlu melihat konfigurasi yang digunakan dalam setup ini.</p><p>Struktur file utama:</p><pre>loki-fundamentals/<br>├── config.alloy<br>├── docker-compose.yml<br>├── loki-config.yaml<br>├── greenhouse/<br>├── README.md<br>└── LICENSE</pre><p>Masing-masing file dan folder memiliki peran yang berbeda dalam membangun end-to-end logging pipeline menggunakan Loki Stack.</p><ol><li><strong>config.alloy</strong></li></ol><p>File config.alloy mendefinisikan alur kerja Grafana Alloy, mulai dari menemukan container Docker hingga mengirim lok ke Loki.</p><p>a. <strong>Discovery Container Docker</strong></p><pre>discovery.docker &quot;getting_started&quot; {<br>  host = &quot;unix:///var/run/docker.sock&quot;<br>  refresh_interval = &quot;5s&quot;<br>}</pre><p>Bagian ini bertugas:</p><ul><li>Terhubung ke Docker Engine melalui docker.sock.</li><li>Mendeteksi container yang sedang berjalan.</li><li>Mengambil metadata container (nama, ID, image, dll).</li><li>Melakukan refresh setiap 5 detik.</li></ul><p><em>/var/run/docker.sock</em> adalah socker Unix yang digunakan Docker untuk menyediakan API internal. Dengan mengakses socker ini, Alloy bisa membaca log container tanpa perlu konfigurasi tambahan di aplikasi.</p><p>b. <strong>Relabeling Metadata Docker</strong></p><pre>discovery.relabel &quot;getting_started&quot; {<br>  rule {<br>    source_labels = [&quot;__meta_docker_container_name&quot;]<br>    regex         = &quot;/(.*)&quot;<br>    target_label  = &quot;container&quot;<br>  }<br>}</pre><p>Metadata Docker bersifat internal dan tidak langsung digunakan oleh Loki. Tahap relabeling ini mengubah metadata tersebut menjadi label Loki yang bisa di query.</p><p>Hasilnya, setiap log akan memiliki label:</p><pre>container=&lt;nama_container&gt;</pre><p>Label inilah yang nantinya digunakan di LogQL, misalnya:</p><pre>{container=&quot;loki-fundamentals-loki-1&quot;}</pre><p>c. <strong>Mengambil Log dari Docker</strong></p><pre>loki.source.docker &quot;getting_started&quot; {<br>  host          = &quot;unix:///var/run/docker.sock&quot;<br>  targets       = discovery.docker.getting_started.targets<br>  relabel_rules = discovery.relabel.getting_started.rules<br>  forward_to    = [loki.process.getting_started.receiver]<br>}</pre><p>Di tahap ini:</p><ul><li>Alloy mulai men-tail (mengambil) log dari container.</li><li>Menggunakan target hasil discovery.</li><li>Menerapkan aturan relabel.</li><li>Meneruskan log ke tahap processing.</li></ul><p>d. <strong>Processing Log</strong></p><pre>loki.process &quot;getting_started&quot; {<br>  stage.static_labels {<br>    values = {<br>      env = &quot;production&quot;,<br>    }<br>  }<br>  forward_to = [loki.write.getting_started.receiver]<br>}</pre><p>Tahap processing digunakan untuk:</p><ul><li>Menambahkan label statis (env=production).</li><li>Mensimulasikan skenario environment production.</li><li>Menyiapkan log sebelum dikirim ke Loki.</li></ul><p>Label tambahan ini sangat berguna untuk filtering dan agregasi log.</p><p>e.<strong> Mengirim Log ke Loki</strong></p><pre>loki.write &quot;getting_started&quot; {<br>  endpoint {<br>    url = &quot;http://loki:3100/loki/api/v1/push&quot;<br>  }<br>}</pre><p>Log dikirim ke Loki melalui HTTP API <em>/loki/api/v1/push</em>. Hostname loki mengacu pada service name di Docker Compose, karena semua container berbeda dalam satu network yang sama.</p><p>f.<strong> Live Debugging</strong></p><pre>livedebugging {<br>  enabled = true<br>}</pre><p>Fitur ini memungkinkan:</p><ul><li>Melihat log secara realtime di Alloy UI.</li><li>Melihat hasil relabel dan processing secara langsung.</li></ul><p>2. <strong>loki-config.yaml</strong></p><p>File ini adalah konfigurasi utama Loki yang mengatur cara Loki menerima, menyimpan, dan melayani query log. Konfigurasi ini menggunakan mode monolithic, cocok untuk local lab dan learning.</p><p>a. <strong>Authentication</strong></p><pre>auth_enabled: false</pre><ul><li>Menonaktifkan autentikasi.</li><li>Semua request ke Loki boleh masuk tanpa token atau kredensial.</li><li>Umum digunakan untuk environment lokal/lab.</li></ul><p>b.<strong> Server Configuration</strong></p><pre>server:<br>  http_listen_port: 3100<br>  grpc_listen_port: 9096<br>  log_level: info<br>  grpc_server_max_concurrent_streams: 1000</pre><ul><li>3100: port utama loki untuk menerima log yang di push oleh agent (alloy/promtail).</li><li>9096: port internal gRPC antar komponen Loki.</li><li>log_level: logging level standar.</li><li>grpc_server_max_concurrent_streams: batas koneksi paralel gRPC.</li></ul><p>c.<strong> Common Configuration (Core Loki)</strong></p><pre>common:<br>  instance_addr: 127.0.0.1<br>  path_prefix: /tmp/loki</pre><ul><li>path_prefix: direktori dasar penyimpanan data Loki.</li><li>Digunakan untuk chunk, index, dan data internal lain.</li></ul><p>Storage:</p><pre>storage:<br>  filesystem:<br>    chunks_directory: /tmp/loki/chunks<br>    rules_directory: /tmp/loki/rules</pre><ul><li>Menggunakan filesystem lokal sebagai storage.</li><li>Cocok untuk lab (bukan prodcution).</li><li>Chunk log dan rules disimpan di disk lokal.</li></ul><p>Ring &amp; Replication</p><pre>replication_factor: 1<br>ring:<br>  kvstore:<br>    store: inmemory</pre><ul><li><strong>replication_factor: 1: t</strong>idak ada replikasi data.</li></ul><p><em>Artinya: setiap log hanya disimpan satu kali di satu instance Loki. Tidak ada salinan (backup) log di instance Loki lain. Lebih hemat resource (cocok untuk lab).</em></p><ul><li>Ring disimpan <strong>in-memory</strong>, artinya tidak persisten.</li></ul><p><em>Artinya: informasi “siapa menyimpan data apa” hanya ada di RAM. Saat Loki restart, ring hilang, loki menganggap dirinya mulai dari nol.</em></p><ul><li>Menandakan Loki berjalan <strong>single instance</strong>.</li></ul><p>d. <strong>Query Range &amp; Cache</strong></p><pre>query_range:<br>  results_cache:<br>    cache:<br>      embedded_cache:<br>        enabled: true<br>        max_size_mb: 100</pre><ul><li>Mengaktifkan cache hasil query.</li><li>Mempercepat query log yang sama.</li><li>Cache disimpan di memory Loki.</li></ul><p>e. <strong>Limits Configuration</strong></p><pre>limits_config:<br>  metric_aggregation_enabled: true<br>  allow_structured_metadata: true<br>  volume_enabled: true<br>  retention_period: 24h</pre><ul><li>Mengaktifkan fitur agregasi metric dari log.</li><li>Mengizinkan metadata terstruktur.</li><li>Log hanya disimpan <strong>24 jam</strong> (auto delete).</li></ul><p>f. <strong>Schema Configuration</strong></p><pre>schema_config:<br>  configs:<br>    - store: tsdb<br>      object_store: filesystem<br>      schema: v13</pre><ul><li>Menentukan <strong>format penyimpanan log &amp; index</strong>.</li><li>Menggunakan <strong>TSDB schema v13</strong> (modern &amp; efisien).</li><li>Index dibuat per <strong>24 jam</strong>.</li></ul><p>g. <strong>Pattern Ingester</strong></p><pre>pattern_ingester:<br>  enabled: true</pre><ul><li>Loki bisa mengenali <strong>pola log otomatis</strong>.</li><li>Digunakan untuk analisis log berbasis pattern.</li></ul><p>h. <strong>Ruler</strong></p><pre>ruler:<br>  enable_alertmanager_discovery: true<br>  enable_api: true</pre><ul><li>Mengaktifkan fitur <strong>alerting berbasis log</strong>.</li><li>Bisa terintegrasi dengan Alertmanager.</li></ul><p>i. <strong>Frontend</strong></p><pre>frontend:<br>  encoding: protobuf</pre><ul><li>Menggunakan <strong>protobuf</strong> untuk komunikasi query.</li><li>Lebih efisien dibanding JSON.</li></ul><p>j. <strong>Compactor</strong></p><pre>compactor:<br>  retention_enabled: true</pre><ul><li>Bertugas membersihkan data lama.</li><li>Menghapus log yang melewati <strong>retention period</strong> (24 jam).</li></ul><p>3. <strong>docker-compose.yml</strong></p><p>File docker-compose.yml ini digunakan untuk menjalankan <strong>Loki Stack secara lokal</strong> menggunakan Docker Compose. Stack ini terdiri dari tiga komponen utama, yaitu <strong>Grafana Alloy</strong>, <strong>Loki</strong>, dan <strong>Grafana</strong>, yang saling terhubung dalam satu jaringan Docker.</p><p>a.<strong> Service Alloy</strong></p><pre>alloy:<br>  image: grafana/alloy:v1.7.5</pre><p>Service Alloy berperan sebagai agent observability yang bertugas untuk:</p><ul><li>Menemukan container Docker.</li><li>Mengambil log dari container.</li><li>Meneruskan log ke Loki.</li></ul><p>Port yang dibuka:</p><pre>ports:<br>  - 12345:12345<br>  - 4317:4317<br>  - 4318:4318</pre><ul><li>12345: Alloy UI (untuk melihat pipeline dan live logs).</li><li>4317/4318: Endpoint OpenTelemetry (gRPC &amp; HTTP).</li></ul><p>Volume:</p><pre>volumes:<br>  - ./config.alloy:/etc/alloy/config.alloy<br>  - /var/run/docker.sock:/var/run/docker.sock</pre><ul><li>config.alloy: file konfigurasi Alloy yang digunakan saat runtime.</li><li>docker.sock: memberikan akses ke Docker API agar Alloy dapat mendeteksi container, membaca log container.</li></ul><p>Command:</p><pre>command: run --server.http.listen-addr=0.0.0.0:12345 \<br>--storage.path=/var/lib/alloy/data /etc/alloy/config.alloy</pre><p>Perintah ini menjalankan Alloy dengna:</p><ul><li>HTTP server aktif di port 12345.</li><li>Storage internal Alloy.</li><li>Menggunakan file konfigurasi config.alloy.</li></ul><p>Dependency &amp; Network:</p><pre>depends_on:<br>  - loki<br>networks:<br>  - loki</pre><ul><li>Alloy dijalankan setelah Loki siap.</li><li>Terhubung ke network loki.</li></ul><p>b. <strong>Service Loki</strong></p><pre>loki:<br>  image: grafana/loki:3.4.2</pre><p>Service Loki berfungsi sebagai log database yang menyimpan dan mengelola log.</p><p>Port:</p><pre>ports:<br>  - &quot;3100:3100&quot;</pre><p>Port utama Loki untuk:</p><ul><li>Menerima log (Ingest).</li><li>Metrics endpoint.</li><li>Query log.</li></ul><p>Volume &amp; Comamnd:</p><pre>volumes:<br>  - ./loki-config.yaml:/etc/loki/local-config.yaml<br>command: -config.file=/etc/loki/local-config.yaml</pre><ul><li>Menggunakan konfigurasi Loku kustom dari file loki-config.yaml</li><li>Menjalankan Loki dalam mode monolith (semua komponen Loki dalam satu binary)</li></ul><p>Network:</p><pre>networks:<br>  - loki</pre><p>c.<strong> Service Grafana</strong></p><pre>grafana:<br>  image: grafana/grafana:11.6.0</pre><p>Grafana digunakan sebagai dashboard dan query interface untuk log yang disimpan di Loki.</p><p>Environment Variable:</p><pre>environment:<br>  - GF_FEATURE_TOGGLES_ENABLE=grafanaManagedRecordingRules<br>  - GF_AUTH_ANONYMOUS_ENABLED=true<br>  - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin<br>  - GF_AUTH_BASIC_ENABLED=false</pre><p>Penjelasan singkat:</p><ul><li>GF_FEATURE_TOGGLES_ENABLE=grafanaManagedRecordingRules</li></ul><p>Mengaktifkan fitur tambahan Grafana untuk pengelolaan recording rules. Disiapkan untuk kebutuhan observability lanjutan.</p><ul><li>GF_AUTH_ANONYMOUS_ENABLED=true</li></ul><p>Mengizinkan akses Grafana tanpa login (tanpa username dan password).</p><ul><li>GF_AUTH_ANONYMOUS_ORG_ROLE=Admin</li></ul><p>User anonim diberi hak Admin, sehingga bisa mengatur datasource dan dashboard.</p><ul><li>GF_AUTH_BASIC_ENABLED=false</li></ul><p>Menonaktifkan login basic auth agar hanya menggunakan mode anonim.</p><p>Port:</p><pre>ports:<br>  - 3000:3000</pre><p>Grafana UI dapat diakses melalui:</p><pre>http://localhost:3000</pre><p>EntryPoint (Auto Provisioning Datasource):</p><p>Bagian ini secara otomatis:</p><ul><li>Membuat datasource Loki.</li><li>Menghubungkan Grafana Loki tanpa konfigurasi manual</li></ul><pre>url: &#39;http://loki:3100&#39;</pre><p>Grafana mengakses Loki melalui Docker network, bukan localhost.</p><p>d. <strong>Docker Network</strong></p><pre>networks:<br>  loki:</pre><p>Network khusus agar:</p><ul><li>Alloy</li><li>Loki</li><li>Grafana</li></ul><p>dapat saling berkomunikasi menggunakan nama service (loki, grafana, alloy).</p><h4>Deploy Sample Application (Carnivorous Greenhouse)</h4><p>Pada tahap sebelumnya, Loki baru mengumpulkan log dari komponen stack itu sendiri (Grafana, Loki, Alloy). Agar observability lebih realistis, digunakan <strong>sample microservices application</strong> bernama <strong>The Carnivorous Greenhouse</strong>.</p><p>Aplikasi ini mensimulasikan sistem greenhouse dan terdiri dari <strong>7 service terpisah</strong>, sehingga sangat cocok untuk melihat bagaimana Loki bekerja pada arsitektur microservices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*Plln4Xo-mj9T6h8OBL5Eow.png" /></figure><p><strong>Komponen Aplikasi</strong></p><p>Aplikasi Carnivorous Greenhouse terdiri dari:</p><ul><li><strong>User Service</strong><br> Mengelola user dan autentikasi (sign up &amp; login).</li><li><strong>Plant Service</strong><br> Mengelola pembuatan plant dan notifikasi ke service lain.</li><li><strong>Simulation Service</strong><br> Menghasilkan data sensor untuk setiap plant.</li><li><strong>WebSocket Service</strong><br> Menangani koneksi realtime antar komponen.</li><li><strong>Bug Service</strong><br> Service khusus untuk mensimulasikan error secara acak (chaos testing).</li><li><strong>Main App</strong><br> Aplikasi utama yang menghubungkan seluruh service.</li><li><strong>Database (PostgreSQL)</strong><br> Menyimpan data user dan plant.</li></ul><p>Arsitektur ini mencerminkan kondisi nyata di production, di mana setiap service berjalan dalam container terpisah dan menghasilkan log masing-masing.</p><p><strong>Menjalankan Sample Application</strong></p><p>Dengan direktori loki-fundamentals sebagai working directory, aplikasi dijalankan menggunakan Docker Compose:</p><pre>docker compose -f greenhouse/docker-compose-micro.yml up -d --build</pre><p>Karena image aplikasi perlu di-build terlebih dahulu, proses ini membutuhkan beberapa menit.</p><p>Jika berhasil, Docker akan menampilkan container seperti:</p><ul><li>greenhouse-main_app-1</li><li>greenhouse-user_service-1</li><li>greenhouse-plant_service-1</li><li>greenhouse-simulation_service-1</li><li>greenhouse-websocket_service-1</li><li>greenhouse-bug_service-1</li><li>greenhouse-db-1</li></ul><p><strong>Verifikasi Aplikasi</strong></p><p>Akses aplikasi melalui browser:</p><pre>http://localhost:5005</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YIz9fR6Mh17m0MZy4Q585w.png" /></figure><p>Jika berhasil, akan muncul halaman login Carnivorous Greenhouse.</p><p>Untuk menghasilkan log, lakukan beberapa aksi berikut:</p><ul><li>Sign Up: membuat user baru</li><li>Login: masuk ke aplikasi</li><li>Add Plant: menambahkan beberapa plant</li></ul><p>Setiap aksi ini akan menghasilkan log dari berbagai service.</p><p><strong>Log Masuk ke Loki Secara Otomatis</strong></p><p>Tanpa konfigurasi tambahan, log dari seluruh container greenhouse <strong>langsung dikirim ke Loki</strong>, karena:</p><ul><li>Alloy menggunakan discovery.docker</li><li>Semua container Docker otomatis terdeteksi</li><li>Log ditail langsung dari Docker runtime</li></ul><p>Label container akan berisi nama container seperti:</p><pre>greenhouse-main_app-1<br>greenhouse-plant_service-1</pre><p><strong>Melihat Log di Grafana</strong></p><p>Logs Drilldown</p><p>Akses:</p><pre>http://localhost:3000/drilldown</pre><p>Di sini akan terlihat service-service greenhouse sebagai entitas terpisah, lengkap dengan log realtime nya.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-gAHyzIpVbQ4cV-IMlpGg.png" /></figure><p><strong>Query Log Menggunakan Grafana Explore</strong></p><p>Untuk analisis lebih lanjut, gunakan <strong>Grafana Explore</strong>:</p><ol><li>Buka <a href="http://localhost:3000/">http://localhost:3000</a></li></ol><p>2. Pilih menu <strong>Explore </strong>(atau search aja)<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fkRgUKikC7aPam45h340gQ.png" /></figure><p>3. Pilih data source <strong>Loki</strong></p><p>4. Gunakan <strong>Code mode</strong> untuk menulis LogQL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RyQ4vZHMgPSvrF2aJrJ9hw.png" /></figure><p><strong>Contoh Query Dasar</strong></p><p>Melihat semua log dari main app:</p><pre>{container=&quot;greenhouse-main_app-1&quot;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opYEc1TzXvNEQj6N3OdYUQ.png" /></figure><p>Mencari log yang mengandung request POST:</p><pre>{container=&quot;greenhouse-main_app-1&quot;} |= &quot;POST&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_IFUVRSdcXI9wYi1MBEbSQ.png" /></figure><p><strong>Parsing Log (Logfmt)</strong></p><p>Log aplikasi menggunakan format <strong>logfmt</strong>, misalnya:</p><pre>ts=2025-02-21 16:09:42,176 level=INFO line=97 msg=&quot;GET /static/style.css&quot;</pre><p>Untuk mengekstrak field seperti level dan line, gunakan parser:</p><pre>{container=&quot;greenhouse-main_app-1&quot;} | logfmt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T94s4M0WJ2w2rKjFrMOPBw.png" /></figure><p>Setelah diparse, atribut tersebut bisa difilter.</p><p><strong>Analisis Error Log</strong></p><p>Aktifkan <strong>Bug Service</strong> dengan menyalakan <em>Toggle Error Mode</em> di UI aplikasi. Service akan mulai menghasilkan error secara acak.</p><p>Contoh query error:</p><pre>{container=&quot;greenhouse-plant_service-1&quot;} | logfmt | level=&quot;ERROR&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2YtxxXOWtUHjnTjpET-rLw.png" /></figure><p>Filter error dari baris kode tertentu:</p><pre>{container=&quot;greenhouse-plant_service-1&quot;} | logfmt | level=&quot;ERROR&quot;, line=&quot;58&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUhjzGKa8-5UB-xF6MXmMQ.png" /></figure><p><strong>Metrics dari Log (LogQL Metrics)</strong></p><p>LogQL juga bisa menghasilkan <strong>metrics berbasis log</strong>.</p><p>Error rate per detik</p><pre>sum(rate({container=&quot;greenhouse-plant_service-1&quot;} | logfmt | level=&quot;ERROR&quot; [$__auto]))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tvcA9_MUPfihg63O_5QHYQ.png" /></figure><p>Top 10 service dengan error tertinggi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQbgqb6tx3yuPcniHBsAdw.png" /></figure><p>Throughput log per service (production)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WboePRVzf_SIgtaRwy8LRQ.png" /></figure><p>Label env=&quot;production&quot; berasal dari <strong>static label</strong> yang ditambahkan Alloy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adfc2365e1cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Membangun Monitoring Terdistribusi di AWS EC2 dengan Prometheus, Grafana, dan CI/CD GitHub Actions]]></title>
            <link>https://medium.com/@nitaoktaviani2005/membangun-monitoring-terdistribusi-di-aws-ec2-dengan-prometheus-grafana-dan-ci-cd-github-actions-28527103a0c7?source=rss-c9a1232d0faf------2</link>
            <guid isPermaLink="false">https://medium.com/p/28527103a0c7</guid>
            <category><![CDATA[cloud-devops]]></category>
            <category><![CDATA[logging-and-monitoring]]></category>
            <dc:creator><![CDATA[Nitaoktaviani]]></dc:creator>
            <pubDate>Sun, 28 Dec 2025 06:54:28 GMT</pubDate>
            <atom:updated>2025-12-28T06:54:28.820Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*enTJ4XwDIyZAiixsZJhZzA.png" /></figure><p>Sebelum masuk ke arsitektur monitoring, penting untuk memperkenalkan <strong>aplikasi web yang menjadi objek utama deployment dan observability</strong>.</p><p>Pada artikel ini, saya menggunakan sebuah <strong>web application sederhana</strong> yang dijalankan di <strong>Amazon EC2</strong> sebagai contoh workload nyata. Aplikasi inilah yang nantinya akan:</p><ul><li>dideploy otomatis menggunakan CI/CD</li><li>dimonitor menggunakan Prometheus &amp; Grafana</li><li>menjadi sumber alert ketika terjadi kegagalan</li></ul><p>Berikut adalah tampilan web yang akan dideploy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNd_f-7h6DPMULUH05BHTQ.png" /></figure><p>Dalam praktik DevOps dan production system, <strong>monitoring bukanlah fitur tambahan</strong>, melainkan kebutuhan utama. Tanpa monitoring, kita tidak tahu apakah aplikasi benar-benar berjalan normal, mengalami bottleneck, atau bahkan sudah down tanpa disadari.</p><p>Pada banyak project awal, monitoring sering ditempatkan <strong>dalam satu server yang sama dengan aplikasi</strong>. Pendekatan ini memang sederhana, tetapi memiliki risiko besar:</p><blockquote>ketika server aplikasi mati, <strong>monitoring ikut mati</strong>.</blockquote><p>Melalui artikel ini, saya ingin membagikan pengalaman membangun <strong>monitoring terdistribusi</strong> menggunakan <strong>Amazon EC2</strong>, dengan memisahkan:</p><ul><li><strong>VM aplikasi</strong></li><li><strong>VM monitoring</strong></li></ul><p>Pendekatan ini umum digunakan di lingkungan production untuk meningkatkan <strong>reliability, observability, dan security</strong>.</p><h4><strong>Gambaran Arsitektur</strong></h4><p>Arsitektur yang digunakan terdiri dari <strong>dua EC2 instance (VM)</strong> dalam satu VPC:</p><p><strong>VM 1 Web / Application Node</strong></p><p>Berfungsi sebagai node aplikasi dan exporter:</p><ul><li>Web application (dcc-web)</li><li><strong>Node Exporter</strong> → monitoring resource host</li><li><strong>cAdvisor</strong> → monitoring container</li></ul><p><strong>VM 2 Monitoring Node</strong></p><p>Berfungsi sebagai pusat observability:</p><ul><li><strong>Prometheus</strong> → metrics collector</li><li><strong>Grafana</strong> → visualization &amp; dashboard</li><li><strong>Alertmanager</strong> → alerting (Telegram)</li></ul><p>Pemisahan ini membuat sistem lebih tahan terhadap kegagalan pada node aplikasi.</p><h4>Alur Monitoring (End-to-End)</h4><p>Secara garis besar, alur monitoring berjalan seperti ini:</p><ol><li><strong>Node Exporter &amp; cAdvisor</strong> di VM1 mengekspose metrics</li><li><strong>Prometheus</strong> di VM2 melakukan <em>pull</em> metrics secara berkala</li><li><strong>Grafana</strong> membaca data dari Prometheus untuk visualisasi</li><li><strong>Alertmanager</strong> mengirim notifikasi ke Telegram jika kondisi tertentu terpenuhi</li></ol><p>Pendekatan <em>pull-based</em> dari Prometheus membuat sistem lebih aman dan terkontrol, karena:</p><ul><li>Tidak perlu membuka banyak akses dari VM aplikasi ke luar</li><li>Monitoring node yang menentukan apa saja yang dipantau</li></ul><h4><strong>Konsep Pemisahan Node (Why This Matters)</strong></h4><p>Pemisahan VM ini memberikan beberapa keuntungan penting:</p><ul><li><strong>Isolation</strong><br>Gangguan pada aplikasi tidak memengaruhi monitoring.</li><li><strong>Security</strong><br>Exporter (9100, 8080) hanya dibuka untuk IP VM monitoring, bukan publik.</li><li><strong>Scalability</strong><br>Mudah menambahkan node aplikasi baru tanpa mengubah stack monitoring.</li></ul><p>Pendekatan ini sering digunakan dalam sistem berskala kecil hingga menengah sebelum masuk ke Kubernetes atau managed observability service.</p><h3>Security Group &amp; Networking Strategy</h3><p>Dalam arsitektur terdistribusi, <strong>networking dan security group adalah fondasi utama</strong>. Monitoring yang baik tidak hanya soal metrics dan dashboard, tetapi juga soal <strong>siapa boleh mengakses apa</strong>.</p><p>Pada setup ini, saya menerapkan prinsip <strong>least privilege</strong>, yaitu:</p><blockquote>hanya membuka port yang benar-benar dibutuhkan, dan hanya ke pihak yang tepat.</blockquote><p><strong>Security Group — VM 1 (Web / Application Node)</strong></p><p>VM ini menjalankan:</p><ul><li>Web application</li><li>Node Exporter</li><li>cAdvisor</li></ul><p><strong>Inbound Rules yang Digunakan</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-rXmLUwz0oWb45gT_gEFAw.png" /></figure><ol><li><strong>Port 8080 &amp; 9100 tidak dibuka ke publik</strong></li></ol><p>2. Hanya <strong>VM Monitoring</strong> yang boleh mengakses exporter</p><p>Ini mencegah:</p><ul><li>metrics leak</li><li>reconnaissance attack</li><li>abuse endpoint exporter</li></ul><p>Pendekatan ini umum digunakan di production sebelum menggunakan service mesh atau private endpoint.</p><p><strong>Security Group VM 2 (Monitoring Node)</strong></p><p>VM ini bertugas sebagai <strong>central observability system</strong>.</p><p><strong>Inbound Rules yang Digunakan</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zl3WwTykP52z4tEbA6wRlw.png" /></figure><blockquote>Dalam production, port Prometheus &amp; Alertmanager sebaiknya dibatasi ke IP tertentu atau VPN. Pada tahap ini dibuka untuk kemudahan eksplorasi dan debugging.</blockquote><h4>Kenapa Menggunakan Elastic IP?</h4><p>Setiap EC2 instance diberikan <strong>Elastic IP</strong>, sehingga:</p><ul><li>IP <strong>tidak berubah</strong> saat instance restart</li><li>Prometheus <strong>tidak perlu update target</strong></li><li>Security Group rule tetap valid</li></ul><p>Ini sangat penting karena:</p><ul><li>Prometheus menggunakan <strong>static scrape target</strong></li><li>Alert &amp; dashboard bergantung pada kestabilan endpoint</li></ul><h3>Docker &amp; Docker Compose Setup (VM1 &amp; VM2)</h3><p>Untuk menjaga konsistensi environment dan mempermudah deployment, seluruh service pada kedua VM dijalankan menggunakan <strong>Docker</strong> dan <strong>Docker Compose</strong>.</p><p>Pendekatan ini memberikan beberapa keuntungan:</p><ul><li>Konfigurasi mudah dibaca &amp; versionable</li><li>Service dapat dijalankan ulang dengan cepat</li><li>Cocok untuk CI/CD dan monitoring berbasis container</li></ul><p><strong>VM 1 Web / Application Node</strong></p><p>VM ini menjalankan <strong>aplikasi web</strong> dan <strong>exporter monitoring</strong>.</p><p>Docker Compose VM Web</p><pre>version: &quot;3.8&quot;<br><br>services:<br>  dcc-web:<br>    image: haechanlovelove/dcc-web:v1<br>    container_name: dcc-web<br>    ports:<br>      - &quot;3000:3000&quot;<br>    restart: always<br><br>  cadvisor:<br>    image: gcr.io/cadvisor/cadvisor:v0.49.1<br>    container_name: cadvisor<br>    ports:<br>      - &quot;8080:8080&quot;<br>    volumes:<br>      - /:/rootfs:ro<br>      - /var/run:/var/run:rw<br>      - /sys:/sys:ro<br>      - /var/lib/docker/:/var/lib/docker:ro<br>    restart: always<br><br>  node-exporter:<br>    image: prom/node-exporter<br>    container_name: node-exporter<br>    ports:<br>      - &quot;9100:9100&quot;<br>    restart: always</pre><p><strong>Penjelasan Service di VM Web</strong></p><p>Dcc Web</p><ul><li>Aplikasi web utama</li><li>Diekspos melalui port <strong>3000</strong></li><li>Image dibuild dan dipush melalui <strong>GitHub Actions</strong></li></ul><p>Node Exporter</p><ul><li>Mengumpulkan metrics host (CPU, memory, disk, network)</li><li>Berjalan di port <strong>9100</strong></li><li>Digunakan Prometheus untuk monitoring level VM</li></ul><p>Cadvisor</p><ul><li>Mengumpulkan metrics container (CPU, memory, restart)</li><li>Membutuhkan akses ke Docker runtime dan filesystem</li><li>Berjalan di port <strong>8080</strong></li></ul><blockquote>Dengan setup ini, satu VM dapat memberikan metrics <strong>host-level</strong> dan <strong>container-level</strong> sekaligus.</blockquote><p><strong>VM 2 Monitoring Node</strong></p><p>VM ini bertugas sebagai <strong>central observability system</strong>.</p><p>Docker Compose VM Monitoring</p><pre>version: &quot;3.8&quot;<br><br>services:<br>  prometheus:<br>    image: prom/prometheus<br>    ports:<br>      - &quot;9090:9090&quot;<br>    volumes:<br>      - ./prometheus.yml:/etc/prometheus/prometheus.yml<br>      - ./alert.rules.yml:/prometheus/alert.rules.yml<br><br>  grafana:<br>    image: grafana/grafana<br>    ports:<br>      - &quot;3000:3000&quot;<br><br>  alertmanager:<br>    image: prom/alertmanager<br>    container_name: alertmanager<br>    volumes:<br>      - ./alertmanager.yml:/etc/alertmanager/alertmanager.yml<br>    ports:<br>      - &quot;9093:9093&quot;</pre><p><strong>Penjelasan Service di VM Monitoring</strong></p><p>Prometheus</p><ul><li>Melakukan <strong>pull metrics</strong> dari VM Web</li><li>Menyimpan time-series metrics</li><li>Mengevaluasi alert rules</li></ul><p>Grafana</p><ul><li>Mengambil data dari Prometheus</li><li>Menyediakan dashboard visual</li><li>Digunakan untuk observability harian</li></ul><p>Alertmanager</p><ul><li>Menerima alert dari Prometheus</li><li>Mengelola grouping &amp; routing alert</li><li>Mengirim notifikasi ke <strong>Telegram</strong></li></ul><h4>Image Management &amp; Versioning Strategy (Docker Hub)</h4><p>Selain menjalankan service menggunakan Docker Compose, saya juga menerapkan <strong>image versioning strategy</strong> pada aplikasi web yang disimpan di <strong>Docker Hub</strong>.</p><p><a href="https://hub.docker.com/r/haechanlovelove/dcc-web/tags">haechanlovelove/dcc-web - Docker Image</a></p><p>Alih-alih menggunakan tag latest, setiap perubahan aplikasi dibuild dan dipush dengan <strong>versi yang eksplisit</strong>, seperti:</p><pre>haechanlovelove/dcc-web:v1<br>haechanlovelove/dcc-web:v2<br>haechanlovelove/dcc-web:v3</pre><p>Pendekatan ini memberikan kontrol penuh terhadap proses deployment dan rollback.</p><p>Kenapa Tidak Menggunakan latest?</p><p>Meskipun latest terlihat praktis, dalam praktik production tag ini <strong>tidak direkomendasikan</strong>, karena:</p><ul><li>Sulit mengetahui versi aplikasi yang sedang berjalan</li><li>Berisiko menarik image yang tidak sesuai ekspektasi</li><li>Menyulitkan proses rollback ketika terjadi kegagalan</li></ul><p>Dengan versioning yang eksplisit, setiap deployment menjadi <strong>deterministik</strong> dan dapat dilacak.</p><h3>Prometheus Scrape Configuration</h3><p>Pada arsitektur ini, <strong>Prometheus</strong> bertindak sebagai pusat pengumpulan metrics. Prometheus menggunakan <strong>pull-based model</strong>, artinya server Prometheus secara aktif mengambil metrics dari target yang telah didefinisikan.</p><p>Pendekatan ini memberikan kontrol penuh terhadap:</p><ul><li>target yang dimonitor</li><li>interval pengambilan metrics</li><li>keamanan akses endpoint metrics</li></ul><h4>Pull Model pada Prometheus</h4><p>Berbeda dengan sistem monitoring berbasis <em>push</em>, Prometheus:</p><ul><li>tidak menerima data secara pasif</li><li>menentukan sendiri endpoint mana yang akan dipantau</li><li>menarik metrics secara berkala</li></ul><p>Dalam setup ini:</p><ul><li><strong>Node Exporter</strong> dan <strong>cAdvisor</strong> berjalan di VM Web</li><li><strong>Prometheus</strong> berada di VM Monitoring</li><li>Komunikasi hanya satu arah: <strong>Monitoring → Web</strong></li></ul><p>Konfigurasi prometheus.yml</p><p>Berikut adalah konfigurasi scrape yang digunakan:</p><pre>global:<br>  scrape_interval: 15s<br><br>rule_files:<br>  - &quot;/prometheus/alert.rules.yml&quot;<br><br>alerting:<br>  alertmanagers:<br>    - static_configs:<br>        - targets:<br>            - &quot;alertmanager:9093&quot;<br><br>scrape_configs:<br>  - job_name: &quot;app-node&quot;<br>    static_configs:<br>      - targets: [&quot;172.31.28.***:9100&quot;]<br><br>  - job_name: &quot;cadvisor&quot;<br>    static_configs:<br>      - targets: [&quot;172.31.28.***:8080&quot;]</pre><h4>Penjelasan Tiap Bagian Konfigurasi</h4><p><strong>scrape_interval</strong></p><pre>scrape_interval: 15s</pre><p>Prometheus akan mengambil metrics setiap <strong>15 detik</strong>. Interval ini cukup seimbang antara:</p><ul><li>real-time visibility</li><li>beban jaringan dan storage</li></ul><p><strong>Scrape Node Exporter</strong></p><pre>job_name: &quot;app-node&quot;<br>targets: [&quot;172.31.28.***:9100&quot;]</pre><p>Job ini digunakan untuk:</p><ul><li>memantau kondisi VM Web</li><li>CPU, memory, disk, network</li><li>availability node</li></ul><p>Metrics ini biasanya divisualisasikan menggunakan <strong>Node Exporter Full Dashboard</strong> di Grafana.</p><p><strong>Scrape cAdvisor</strong></p><pre>job_name: &quot;cadvisor&quot;<br>targets: [&quot;172.31.28.***:8080&quot;]</pre><p>Job ini digunakan untuk:</p><ul><li>memantau container aplikasi</li><li>CPU &amp; memory per container</li><li>restart dan lifecycle container</li></ul><p>Dengan cAdvisor, monitoring tidak hanya berhenti di level VM, tetapi sampai ke <strong>level container</strong>.</p><p><strong>Labeling &amp; Identifikasi Target</strong></p><p>Setiap target yang di-scrape akan otomatis memiliki label seperti:</p><ul><li>job</li><li>instance</li></ul><p>Contoh:</p><pre>job=&quot;cadvisor&quot;<br>instance=&quot;172.31.28.***:8080&quot;</pre><p>Label ini sangat penting karena:</p><ul><li>digunakan dalam query PromQL</li><li>menjadi dasar alerting</li><li>mempermudah filtering di Grafana</li></ul><h4>Hubungan dengan Security Group</h4><p>Scrape configuration ini hanya bisa berjalan karena:</p><ul><li>port <strong>9100 &amp; 8080</strong> di VM Web <strong>hanya dibuka untuk IP VM Monitoring</strong></li><li>tidak ada akses publik ke endpoint metrics</li></ul><p>Dengan demikian:</p><ul><li>metrics aman dari pihak luar</li><li>Prometheus tetap dapat mengakses exporter tanpa hambatan</li></ul><h3>Alert Rules &amp; Telegram Notification</h3><p>Monitoring tanpa alert ibarat dashboard tanpa alarm. Kita bisa melihat grafik, tetapi <strong>tidak tahu kapan harus bertindak</strong>. Pada tahap ini, <strong>Prometheus</strong> dan <strong>Alertmanager</strong> digunakan untuk mendeteksi kondisi tidak normal dan mengirimkan notifikasi ke <strong>Telegram</strong> secara real-time.</p><h4>Konsep Alerting yang Digunakan</h4><p>Dalam setup ini, alert dibagi menjadi dua level:</p><ol><li><strong>Target-level alert</strong><br> Mendeteksi jika exporter atau target monitoring tidak dapat dijangkau.</li><li><strong>Container-level alert</strong><br> Mendeteksi jika container aplikasi utama (dcc-web) berhenti berjalan.</li></ol><p>Pendekatan ini memastikan:</p><ul><li>kita tahu <strong>node-nya bermasalah</strong></li><li>kita tahu <strong>container spesifik yang down</strong></li></ul><p>Alert Rules (alert.rules.yml)</p><p>Berikut adalah konfigurasi alert yang digunakan:</p><pre>groups:<br>- name: vm1-container-alert<br>  rules:<br><br>  # Target DOWN (Node Exporter / cAdvisor)<br>  - alert: TargetDown<br>    expr: up == 0<br>    for: 1m<br>    labels:<br>      severity: critical<br>    annotations:<br>      summary: &quot;🚨 Target DOWN&quot;<br>      description: &quot;Target {{ $labels.job }} ({{ $labels.instance }}) MATI&quot;<br><br>  # dcc-web container DOWN<br>  - alert: DccWebDown<br>    expr: |<br>      time() - container_last_seen{name=&quot;dcc-web&quot;} &gt; 60<br>    for: 1m<br>    labels:<br>      severity: critical<br>    annotations:<br>      summary: &quot;🚨 dcc-web DOWN&quot;<br>      description: |<br>        Container: dcc-web<br>        VM: {{ $labels.instance }}</pre><h4>Penjelasan Alert Rules</h4><p><strong>TargetDown</strong></p><pre>expr: up == 0</pre><p>Alert ini aktif ketika:</p><ul><li>exporter tidak bisa di-scrape</li><li>node tidak reachable</li><li>service exporter mati</li></ul><p>Digunakan sebagai <strong>early warning</strong> bahwa ada masalah di level infrastruktur atau jaringan.</p><p><strong>DccWebDown</strong></p><pre>time() - container_last_seen{name=&quot;dcc-web&quot;} &gt; 60</pre><p>Alert ini aktif ketika:</p><ul><li>container dcc-web tidak terlihat lebih dari 60 detik</li><li>container crash atau berhenti</li></ul><p>Ini adalah alert <strong>application-critical</strong>, karena langsung berdampak ke user.</p><p><strong>Kenapa Menggunakan </strong><strong>for: 1m?</strong></p><pre>for: 1m</pre><p>Durasi ini digunakan untuk:</p><ul><li>menghindari false alert akibat restart singkat</li><li>memastikan masalah benar-benar terjadi</li><li>mengurangi alert noise</li></ul><p>Alert hanya akan dikirim jika kondisi error <strong>bertahan minimal 1 menit</strong>.</p><h4>Konfigurasi Alertmanager ke Telegram</h4><p>Alertmanager (alertmanager.yml)</p><pre>global:<br>  resolve_timeout: 5m<br><br>route:<br>  receiver: telegram-alert<br>  group_wait: 10s<br>  group_interval: 1m<br>  repeat_interval: 1h<br><br>receivers:<br>- name: telegram-alert<br>  telegram_configs:<br>  - bot_token: &quot;&lt;BOT_TOKEN&gt;&quot;<br>    chat_id: &lt;CHAT_ID&gt;<br>    parse_mode: HTML<br>    message: |<br>      🚨 &lt;b&gt;ALERT PROMETHEUS&lt;/b&gt;<br><br>      &lt;b&gt;Status:&lt;/b&gt; {{ .Status }}<br>      &lt;b&gt;Alert:&lt;/b&gt; {{ .CommonAnnotations.summary }}<br><br>      {{ range .Alerts }}<br>      🔹 &lt;b&gt;Job:&lt;/b&gt; {{ .Labels.job }}<br>      🔹 &lt;b&gt;Instance:&lt;/b&gt; {{ .Labels.instance }}<br>      🔹 &lt;b&gt;Info:&lt;/b&gt; {{ .Annotations.description }}<br>      {{ end }}</pre><h4>Simulasi Incident (Real Case)</h4><ol><li>Container dcc-web dimatikan:</li></ol><pre>docker stop dcc-web</pre><p>2. Prometheus mendeteksi:</p><ul><li>container_last_seen tidak update</li><li>alert DccWebDown aktif</li></ul><p>3. Telegram menerima notifikasi:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zoMwpprYeGhmPhF42NDcUw.jpeg" /></figure><p>Ini memastikan incident <strong>terdeteksi tanpa perlu membuka dashboard Grafana</strong>.</p><h3>Grafana Dashboard &amp; Visualization</h3><p>Setelah metrics berhasil dikumpulkan oleh <strong>Prometheus</strong>, langkah selanjutnya adalah <strong>memvisualisasikan data tersebut agar mudah dipahami</strong>.<br> Di sinilah peran <strong>Grafana</strong> menjadi sangat penting.</p><p>Grafana digunakan sebagai <strong>single pane of glass</strong> untuk:</p><ul><li>memantau kondisi VM</li><li>melihat performa container</li><li>melakukan troubleshooting cepat saat incident</li></ul><h4><strong>Menghubungkan Grafana dengan Prometheus</strong></h4><p>Langkah pertama adalah menambahkan Prometheus sebagai <strong>data source</strong> di Grafana.</p><p><strong>Konsepnya sederhana:</strong></p><ul><li>Grafana <strong>tidak menyimpan data</strong></li><li>Grafana hanya <strong>query ke Prometheus</strong></li><li>Semua metrics tetap berada di Prometheus</li></ul><p>Dengan setup ini, dashboard akan selalu menampilkan data <strong>real-time</strong> sesuai kondisi sistem.</p><h4>Dashboard Node Exporter (Host-Level Monitoring)</h4><p>Dashboard ini digunakan untuk memantau <strong>kondisi VM Web (Application Node)</strong> secara keseluruhan.</p><p>Metrics yang Dipantau</p><ul><li>CPU usage</li><li>Memory utilization</li><li>Disk usage</li><li>Network traffic</li><li>System load</li></ul><p>Dashboard Node Exporter sangat membantu untuk menjawab pertanyaan seperti:</p><ul><li>Apakah VM kehabisan memory?</li><li>Apakah CPU spike sebelum aplikasi down?</li><li>Apakah ada bottleneck di disk atau network?</li></ul><p>Biasanya dashboard ini di <em>import</em> dari Grafana community dan langsung dapat digunakan tanpa konfigurasi tambahan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s4qi-JmOlVczxyIQj-jmGQ.jpeg" /></figure><h4>Dashboard cAdvisor (Container-Level Monitoring)</h4><p>Berbeda dengan Node Exporter, <strong>cAdvisor</strong> memberikan visibility hingga ke <strong>level container</strong>.</p><p>Metrics yang Dipantau</p><ul><li>CPU usage per container</li><li>Memory usage per container</li><li>Container restart</li><li>Network I/O container</li></ul><p>Dengan dashboard cAdvisor, saya dapat:</p><ul><li>melihat container dcc-web secara spesifik</li><li>mengetahui apakah hanya satu container yang bermasalah</li><li>membedakan masalah aplikasi vs masalah VM</li></ul><p>Ini sangat penting dalam arsitektur berbasis container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xzXzsR9iAIYKG8lmOO9Pvw.png" /></figure><h4>Hubungan Grafana dengan Alerting</h4><p>Meskipun alert dikirim melalui <strong>Alertmanager ke Telegram</strong>, Grafana tetap berperan penting sebagai:</p><ul><li>alat verifikasi incident</li><li>media investigasi setelah alert diterima</li></ul><p>Alur nyatanya biasanya seperti ini:</p><ol><li>Alert masuk ke Telegram</li><li>Buka Grafana</li><li>Cek dashboard Node Exporter &amp; cAdvisor</li><li>Identifikasi penyebab masalah</li></ol><h3>CI/CD GitHub Actions Deployment</h3><p>Agar proses deployment tidak dilakukan secara manual, saya mengintegrasikan aplikasi web dengan <strong>GitHub Actions</strong>.<br> Setiap perubahan kode yang di-<em>push</em> ke branch main akan secara otomatis:</p><ol><li>dibuild menjadi Docker image</li><li>dipush ke <strong>Docker Hub</strong></li><li>dideploy ke <strong>Amazon EC2</strong> menggunakan Docker Compose</li></ol><p>Pendekatan ini membuat proses rilis aplikasi menjadi <strong>konsisten, repeatable, dan minim human error</strong>.</p><h4>Workflow GitHub Actions</h4><p>Berikut workflow CI/CD yang digunakan:</p><pre>name: Build &amp; Deploy Docker v1<br><br>on:<br>  push:<br>    branches:<br>      - main<br><br>jobs:<br>  build-and-deploy:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>    - name: Checkout code<br>      uses: actions/checkout@v4<br><br>    - name: Login to Docker Hub<br>      uses: docker/login-action@v3<br>      with:<br>        username: ${{ secrets.DOCKER_USERNAME }}<br>        password: ${{ secrets.DOCKER_PASSWORD }}<br><br>    - name: Build &amp; Push Docker Image<br>      uses: docker/build-push-action@v5<br>      with:<br>        context: .<br>        push: true<br>        tags: haechanlovelove/dcc-web:v1<br><br>    - name: Deploy to EC2 using Docker Compose<br>      uses: appleboy/ssh-action@v1.0.0<br>      with:<br>        host: ${{ secrets.EC2_HOST }}<br>        username: ${{ secrets.EC2_USER }}<br>        key: ${{ secrets.EC2_SSH_KEY }}<br>        script: |<br>          cd /home/ec2-user/todo-app<br><br>          docker-compose pull<br>          docker-compose down<br>          docker-compose up -d</pre><h4>Penjelasan Tahap CI/CD</h4><p>Build &amp; Push Image</p><ul><li>Aplikasi dibuild menjadi Docker image</li><li>Image dipush ke Docker Hub dengan tag versi tertentu</li><li>Image siap digunakan oleh Docker Compose di EC2</li></ul><p>Deploy via SSH ke EC2</p><ul><li>GitHub Actions melakukan SSH ke VM Web</li><li>Menjalankan docker-compose pull untuk menarik image terbaru</li><li>Menjalankan docker-compose up -d untuk update container</li></ul><p>Tidak ada docker run manual, sehingga deployment:</p><ul><li>lebih bersih</li><li>lebih konsisten</li><li>lebih mudah dikembangkan</li></ul><h4>Deployment Tanpa Mengganggu Monitoring</h4><p>arena monitoring (Prometheus, Grafana, Alertmanager) berjalan di <strong>VM terpisah</strong>, proses deployment aplikasi:</p><ul><li>tidak memengaruhi monitoring</li><li>tetap terpantau oleh cAdvisor &amp; Node Exporter</li><li>langsung memicu alert jika container gagal naik</li></ul><p>Ini memberikan <strong>feedback cepat</strong> setelah deployment.</p><h4>Security &amp; Secret Management</h4><p>Semua kredensial sensitif disimpan menggunakan <strong>GitHub Secrets</strong>, seperti:</p><ul><li>Docker Hub credentials</li><li>SSH key EC2</li><li>Host dan username EC2</li></ul><p>Tidak ada secret yang ditulis langsung di repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AIEynxpBOnFCVp2NR9CzoA.png" /></figure><h3>Lessons Learned &amp; Best Practices</h3><p>Dari implementasi monitoring dan deployment ini, ada beberapa pelajaran penting yang bisa diambil, terutama bagi engineer yang sedang membangun sistem di luar managed service.</p><h4>1. Pisahkan Monitoring dari Aplikasi</h4><p>Menjalankan monitoring pada VM terpisah membuat sistem:</p><ul><li>lebih <strong>reliable</strong></li><li>tetap terpantau saat aplikasi down</li><li>lebih mudah dikembangkan ke skala lebih besar</li></ul><p>Monitoring seharusnya <strong>tidak bergantung</strong> pada sistem yang dimonitor.</p><h4>2. Jangan Buka Exporter ke Publik</h4><p>Node Exporter dan cAdvisor <strong>bukan untuk konsumsi publik</strong>.</p><p>Best practice yang diterapkan:</p><ul><li>port exporter hanya dibuka ke IP monitoring node</li><li>tidak menggunakan 0.0.0.0/0</li></ul><p>Ini mengurangi risiko:</p><ul><li>data leakage</li><li>reconnaissance attack</li><li>abuse endpoint metrics</li></ul><h4>3. Gunakan Image Versioning, Bukan latest</h4><p>Menggunakan tag versi (v1, v2, dst.) memberikan:</p><ul><li>visibilitas versi yang sedang berjalan</li><li>proses rollback yang cepat</li><li>deployment yang lebih aman</li></ul><p>Strategi ini sangat membantu saat terjadi kegagalan setelah rilis.</p><h4>4. Monitoring Harus Aktif, Bukan Pasif</h4><p>Dashboard saja tidak cukup.</p><p>Dengan kombinasi:</p><ul><li>Prometheus</li><li>Alertmanager</li><li>Telegram notification</li></ul><p>Sistem dapat <strong>memberi tahu ketika terjadi masalah</strong>, bahkan sebelum pengguna melaporkan.</p><h4>5. CI/CD dan Monitoring Harus Terintegrasi</h4><p>Setiap deployment:</p><ul><li>langsung terpantau oleh cAdvisor</li><li>berpotensi memicu alert jika gagal</li><li>memberikan feedback cepat ke engineer</li></ul><p>Monitoring tanpa CI/CD, atau sebaliknya, akan terasa timpang.</p><h3>Penutup &amp; Future Improvements</h3><p>Melalui artikel ini, saya membangun sistem <strong>end-to-end</strong> yang mencakup:</p><ul><li>deployment aplikasi otomatis</li><li>monitoring host dan container</li><li>alert real-time ke Telegram</li><li>visualisasi metrics dengan Grafana</li></ul><p>Arsitektur ini cocok untuk:</p><ul><li>personal project</li><li>learning DevOps &amp; observability</li><li>small production workload</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28527103a0c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>