Skip to content

Commit 470692e

Browse files
committed
feat(loki): add scraper and make retention configurable
1 parent 91928fd commit 470692e

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

roles/loki/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ loki_data_dir: /usr/share/loki # default: "/usr/share/{{ loki_hostname }}"
1818
loki_requires_package: python2-passlib # default: python3-passlib
1919
loki_proxy_basic_auth_username: log # default: loki
2020
loki_proxy_basic_auth_password: # default: "{{ vault_loki_proxy_basic_auth_password }}"
21+
loki_retention_period: 7d # default: 14d
2122
```
2223
2324
Ensure the nginx proxy includes the loki config:

roles/loki/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ loki_data_dir: /usr/share/{{ loki_hostname }}
55
loki_nginx_data_dir: "{{ nginx_data_dir }}/proxies"
66
loki_proxy_basic_auth_username: loki
77
loki_proxy_basic_auth_password: "{{ vault_loki_proxy_basic_auth_password }}"
8+
loki_retention_period: 14d

roles/loki/templates/local-config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ query_range:
2828

2929
limits_config:
3030
metric_aggregation_enabled: true
31-
retention_period: 30d
31+
retention_period: {{ loki_retention_period }}
3232

3333
schema_config:
3434
configs:
@@ -64,4 +64,4 @@ frontend:
6464
#
6565
# If you would like to disable reporting, uncomment the following lines:
6666
analytics:
67-
reporting_enabled: false
67+
reporting_enabled: false

roles/prometheus/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ The `prometheus.yml` template contains predefined srcape jobs that lookup proxy
9696
* **n8n https**: Targets are `nginx_proxies` with exporter `n8n`.
9797
* **uptime-kuma https**: Targets are `nginx_proxies` with exporter `uptime-kuma`.
9898
* **meilisearch https**: Targets are `nginx_proxies` with exporter `meilisearch`.
99-
* **blackbox**: Targets are `nginx_proxies` with `monitor` not false and host is `blackbox01:9115`.
99+
* **blackbox**: Target is `blackbox_exporter_hostname`.
100+
* **loki http**: Targetis `loki_hostname`.
100101

101102
### Custom scrapers
102103

roles/prometheus/templates/prometheus.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,5 +186,15 @@ scrape_configs:
186186
target_label: instance
187187
- target_label: __address__
188188
replacement: {{ blackbox_exporter_hostname }}:9115
189+
{% endif %}
190+
{% if loki_hostname is defined %}
191+
- job_name: loki
192+
metrics_path: "/metrics"
193+
scrape_interval: 60s
194+
honor_labels: true
195+
scheme: http
196+
static_configs:
197+
- targets:
198+
- {{ loki_hostname }}:3100
189199
{% endif %}
190200
{{ prometheus_custom_scrapers | indent(2) }}

0 commit comments

Comments
 (0)