# August 19, 2024

## Things That I Discovered

### 1. Logging in Caddy Server

* It's been a long since I've run [Caddy Server](https://caddyserver.com/), but hardly used any logging, thought of exploring logs which is easy to setup.
* **Logging in Caddyfile**:

  ```
  example.domain.com {
      reverse_proxy localhost:8080
      log {
          output file /var/log/caddy/example.domain.com-access.log
      }
  }
  ```
* **Reference**: [Log Caddyfile Directive - Caddy Server Documentation](https://caddyserver.com/docs/caddyfile/directives/log)
* To avoid repeating the same log block again, and we can use snippets instead.
* **Logging using Snippets in Caddyfile**:

  ```
  (logging) {
      log {
          output file /var/log/{args[0]}-access.log
      }
  }
  example.domain.com {
      reverse_proxy localhost:8080
      import logging example.domain.com
  }
  ```
* **Reference**: [Snippets Caddyfile Directive - Caddy Server Documentation](https://caddyserver.com/docs/caddyfile/concepts#snippets)

### 2. Getting Started with Grafana Loki & Promtail

* Today I explored [Grafana Loki](https://grafana.com/docs/loki/latest/) and [Promtail](https://grafana.com/docs/loki/latest/send-data/promtail/) as part of my effort to streamline log access from my remote servers.
* **Grafana Loki**: A horizontally scalable, highly available, multi-tenant log aggregation system inspired by Prometheus.
* **Promtail**: An agent that ships the contents of local logs to a private Loki instance, scraping logs and labeling them for efficient querying.
* This setup will significantly improve my ability to monitor and analyze logs from various servers in a centralized and organized manner.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://my-learning-journey.devjugal.com/content/2024/august/day-19.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
