diff --git a/lotus-land-story/caddy.yml b/lotus-land-story/caddy.yml
index 1c9de52..7429f56 100644
--- a/lotus-land-story/caddy.yml
+++ b/lotus-land-story/caddy.yml
@@ -22,6 +22,7 @@
- name: Run caddy
community.docker.docker_compose:
project_name: caddy
+ remove_orphans: true
definition:
version: "3.3"
services:
diff --git a/lotus-land-story/docker.yml b/lotus-land-story/docker.yml
index 4000841..d39d7b5 100644
--- a/lotus-land-story/docker.yml
+++ b/lotus-land-story/docker.yml
@@ -45,6 +45,12 @@
- docker-compose-plugin
update_cache: true
+ - name: Install Loki Docker driver
+ community.docker.docker_plugin:
+ plugin_name: grafana/loki-docker-driver
+ alias: loki
+ state: enable
+
- name: Create Docker volume location
ansible.builtin.file:
path: /mnt/lotus-land-story/docker
diff --git a/lotus-land-story/grafana.yml b/lotus-land-story/grafana.yml
index 2c6fc5d..1c250a3 100644
--- a/lotus-land-story/grafana.yml
+++ b/lotus-land-story/grafana.yml
@@ -10,16 +10,18 @@
loop:
- datasources
- - name: Configure grafana
+ - name: Configure Grafana
ansible.builtin.copy:
dest: /mnt/lotus-land-story/grafana/grafana.ini
content: |
[metrics]
enabled = true
disable_total_stats = false
+ [server]
+ domain = grafana.{{ domain }}
mode: "0644"
- - name: Provision Grafana
+ - name: Provision Prometheus
ansible.builtin.copy:
dest: /mnt/lotus-land-story/grafana/provisioning/datasources/prometheus.yml
content: |
diff --git a/lotus-land-story/loki.yml b/lotus-land-story/loki.yml
new file mode 100644
index 0000000..a455092
--- /dev/null
+++ b/lotus-land-story/loki.yml
@@ -0,0 +1,87 @@
+# https://raw.githubusercontent.com/grafana/loki/v2.8.0/production/docker-compose.yaml
+# https://grafana.com/docs/loki/latest/clients/docker-driver/
+
+- name: Set up Loki
+ hosts: lotus-land-story
+ tasks:
+
+ - name: Provision Grafana
+ ansible.builtin.copy:
+ dest: /mnt/lotus-land-story/grafana/provisioning/datasources/loki.yml
+ content: |
+ apiVersion: 1
+
+ datasources:
+ - name: Loki
+ type: loki
+ access: proxy
+ url: http://host.docker.internal:3100
+ mode: "0644"
+
+ - name: Create Loki config dirs
+ ansible.builtin.file:
+ path: /mnt/lotus-land-story/loki/{{ item }}
+ state: directory
+ mode: "0755"
+ loop:
+ - config
+ - data
+
+ - name: Configure Loki
+ ansible.builtin.copy:
+ dest: /mnt/lotus-land-story/loki/config/config.yml
+ content: |
+ auth_enabled: false
+
+ server:
+ http_listen_port: 3100
+
+ common:
+ path_prefix: /loki
+ storage:
+ filesystem:
+ chunks_directory: /loki/chunks
+ rules_directory: /loki/rules
+ replication_factor: 1
+ ring:
+ kvstore:
+ store: inmemory
+
+ schema_config:
+ configs:
+ - from: 2020-10-24
+ store: boltdb-shipper
+ object_store: filesystem
+ schema: v11
+ index:
+ prefix: index_
+ period: 24h
+
+ storage_config:
+ filesystem:
+ directory: /data
+
+ ruler:
+ alertmanager_url: http://localhost:9093
+ mode: "0644"
+
+ - name: Run Loki
+ community.docker.docker_compose:
+ project_name: loki
+ remove_orphans: true
+ definition:
+ version: "3.3"
+ services:
+ loki:
+ image: grafana/loki:2.8.0
+ ports:
+ - "3100:3100"
+ command: -config.file=/mnt/config/config.yml
+ volumes:
+ - /mnt/lotus-land-story/loki/config:/mnt/config
+ - /mnt/lotus-land-story/loki/data:/data
+ restart: unless-stopped
+ extra_hosts:
+ - "host.docker.internal:host-gateway"
+
+# vim: ft=yaml.ansible
diff --git a/lotus-land-story/main.tf b/lotus-land-story/main.tf
index cfc9bd7..cbf4f76 100644
--- a/lotus-land-story/main.tf
+++ b/lotus-land-story/main.tf
@@ -57,7 +57,7 @@ resource "linode_domain_record" "subdomains" {
record_type = "A"
target = resource.linode_instance.lotus_land_story.ip_address
- for_each = toset(["rss", "prometheus", "grafana"])
+ for_each = toset(["rss", "prometheus", "grafana", "loki"])
name = each.key
}
diff --git a/lotus-land-story/miniflux.yml b/lotus-land-story/miniflux.yml
index 8413ec5..8df8271 100644
--- a/lotus-land-story/miniflux.yml
+++ b/lotus-land-story/miniflux.yml
@@ -49,6 +49,7 @@
- name: Run miniflux
community.docker.docker_compose:
project_name: miniflux
+ remove_orphans: true
definition:
version: "3.3"
services:
diff --git a/lotus-land-story/templates/Caddyfile b/lotus-land-story/templates/Caddyfile
index 4bd1534..77fd166 100644
--- a/lotus-land-story/templates/Caddyfile
+++ b/lotus-land-story/templates/Caddyfile
@@ -13,3 +13,7 @@ prometheus.{{ domain }} {
grafana.{{ domain }} {
reverse_proxy host.docker.internal:3000
}
+
+loki.{{ domain }} {
+ reverse_proxy host.docker.internal:3100
+}
diff --git a/lotus-land-story/templates/daemon.json b/lotus-land-story/templates/daemon.json
index ba28dd9..8c88120 100644
--- a/lotus-land-story/templates/daemon.json
+++ b/lotus-land-story/templates/daemon.json
@@ -1,4 +1,8 @@
{
"data-root": "/mnt/lotus-land-story/docker",
- "metrics-addr": "{{ docker_ip.address }}:9323"
+ "metrics-addr": "{{ docker_ip.address }}:9323",
+ "log-driver": "loki",
+ "log-opts": {
+ "loki-url": "http://localhost:3100/loki/api/v1/push"
+ }
}