{
  "type": "aside",
  "draft": false,
  "title": "Adventures in Vibe Coding with Grafana and Claude",
  "slug": "vibe-coding-claude-grafana",
  "tags": [
    "grafana",
    "claude",
    "vibecoding",
    "llms",
    "ai"
  ],
  "time": "15:26:23-07:00",
  "attachments": [
    "attachments/2025-06-04-blog-lmorchard-graphs.png"
  ],
  "year": "2025",
  "month": "06",
  "day": "04",
  "isDir": false,
  "date": "2025-06-04T22:26:23.000Z",
  "postName": "2025-06-04",
  "html": "<p>Since re-launching my blog, I wanted to monitor traffic and logs more closely. Nothing groundbreaking, but it had been a while since I'd run Grafana, Prometheus, and Loki on my own hardware.</p>\n<p>Turns out there's <a href=\"https://github.com/ddiiwoong/synology-prometheus\">this handy all-in-one docker-compose setup that runs on Synology NAS</a>. It fired up with minimal fuss, and soon I had metrics machinery humming in my basement—except the package didn't include Loki. A quick <a href=\"https://grafana.com/docs/loki/latest/setup/install/docker/\">docs consultation</a> got it running alongside the rest.</p>\n<p>My blog is a static site hosted via AWS S3 and CloudFront. Both services dump logs into an S3 bucket, but I'd never bothered reading them before—and didn't want to start now. Instead, I loaded up Claude.ai and described my problem:</p>\n<blockquote>\n<p>I want to get logs out of CloudFront. I have enabled new-style log delivery that stores gzipped JSON logs in an S3 bucket at s3://lmorchard-logs/blog.lmorchard.com/ with names like E5YXU82LZHZCM.2025-06-04-04.d024d283.gz</p>\n<p>Can you help me write a script for my home Loki server to download only new log files and push them into Loki?</p>\n</blockquote>\n<p>Claude stepped right up:</p>\n<blockquote>\n<p> I'll help you create a script to process CloudFront logs and push them to Loki. Let me write a Python script that tracks processed files and handles the gzipped JSON format.</p>\n</blockquote>\n<p>After some vibey iteration, we <a href=\"https://claude.ai/public/artifacts/9fa52759-3b21-4e5a-a854-222d1696802b\">landed at this artifact</a>:</p>\n<div style=\"height: 400px; overflow-y: auto;\">\n<script src=\"https://gist.github.com/lmorchard/97c532df654d6e135cf7ce4f1ad8846a.js\"></script>\n</div>\n\n\n\n<p>It's quite verbose and could use some tightening up. But, I really don't care—it does the quick &amp; dirty needful.</p>\n<p>I wrote zero Python. I just henpecked Claude to add features until the script did what I needed. I wasn't even in an IDE, just the Claude.ai interface in a browser. An interesting thing to note is that Claude didn't have access to my AWS resources—I didn't even give it a sample of my logs. But, still, what I told it about JSON, S3, and CloudFront was enough for it to be off to the races.</p>\n<p>Anyway, after a quick review and a satisfactory dry run, I dropped it into a cronjob to grab new logs every 5 minutes. Then I pestered Claude with Grafana dashboard questions I <em>could</em> have figured out myself. But why read docs when you can just ask? (Which I realize is ironic, since I wrote <a href=\"https://blog.lmorchard.com/2013/02/25/too-long-read-anyway/index.html\">Too long? Read anyway.</a> but I think I make an exception for LLMs.)</p>\n<p>Total time from idea to working dashboard: about an hour.</p>\n<img src=\"attachments/2025-06-04-blog-lmorchard-graphs.png\" width=\"\" height=\"\">\n\n<p>Not revolutionary, but pretty satisfying for barely having to think about it.</p>\n",
  "body": "\nSince re-launching my blog, I wanted to monitor traffic and logs more closely. Nothing groundbreaking, but it had been a while since I'd run Grafana, Prometheus, and Loki on my own hardware.\n\nTurns out there's [this handy all-in-one docker-compose setup that runs on Synology NAS](https://github.com/ddiiwoong/synology-prometheus). It fired up with minimal fuss, and soon I had metrics machinery humming in my basement—except the package didn't include Loki. A quick [docs consultation](https://grafana.com/docs/loki/latest/setup/install/docker/) got it running alongside the rest.\n\nMy blog is a static site hosted via AWS S3 and CloudFront. Both services dump logs into an S3 bucket, but I'd never bothered reading them before—and didn't want to start now. Instead, I loaded up Claude.ai and described my problem:\n\n> I want to get logs out of CloudFront. I have enabled new-style log delivery that stores gzipped JSON logs in an S3 bucket at s3://lmorchard-logs/blog.lmorchard.com/ with names like E5YXU82LZHZCM.2025-06-04-04.d024d283.gz\n> \n> Can you help me write a script for my home Loki server to download only new log files and push them into Loki?\n\nClaude stepped right up:\n\n>  I'll help you create a script to process CloudFront logs and push them to Loki. Let me write a Python script that tracks processed files and handles the gzipped JSON format.\n\nAfter some vibey iteration, we [landed at this artifact](https://claude.ai/public/artifacts/9fa52759-3b21-4e5a-a854-222d1696802b):\n\n<div style=\"height: 400px; overflow-y: auto;\">\n<script src=\"https://gist.github.com/lmorchard/97c532df654d6e135cf7ce4f1ad8846a.js\"></script>\n</div>\n\nIt's quite verbose and could use some tightening up. But, I really don't care—it does the quick & dirty needful.\n\nI wrote zero Python. I just henpecked Claude to add features until the script did what I needed. I wasn't even in an IDE, just the Claude.ai interface in a browser. An interesting thing to note is that Claude didn't have access to my AWS resources—I didn't even give it a sample of my logs. But, still, what I told it about JSON, S3, and CloudFront was enough for it to be off to the races.\n\nAnyway, after a quick review and a satisfactory dry run, I dropped it into a cronjob to grab new logs every 5 minutes. Then I pestered Claude with Grafana dashboard questions I _could_ have figured out myself. But why read docs when you can just ask? (Which I realize is ironic, since I wrote [Too long? Read anyway.](https://blog.lmorchard.com/2013/02/25/too-long-read-anyway/index.html) but I think I make an exception for LLMs.)\n\nTotal time from idea to working dashboard: about an hour.\n\n![[attachments/2025-06-04-blog-lmorchard-graphs.png]]\n\nNot revolutionary, but pretty satisfying for barely having to think about it.",
  "parentPath": "./content/posts/2025",
  "path": "2025/06/04/vibe-coding-claude-grafana",
  "thumbnail": "/2025/06/04/vibe-coding-claude-grafana/attachments/2025-06-04-blog-lmorchard-graphs.png",
  "needsBuild": true,
  "prevPostPath": "2025/06/02/miscellanea",
  "prevPostTitle": "Miscellanea for 2025-06-02",
  "nextPostPath": "2025/06/04/miscellanea",
  "nextPostTitle": "Miscellanea for 2025-06-04"
}