add Container Loki
This commit is contained in:
parent
626f20daee
commit
66bd76cf48
10 changed files with 96 additions and 0 deletions
|
@ -56,3 +56,8 @@
|
||||||
tags:
|
tags:
|
||||||
- grafana
|
- grafana
|
||||||
- docker-container
|
- docker-container
|
||||||
|
|
||||||
|
- role: deploy_container_loki
|
||||||
|
tags:
|
||||||
|
- loki
|
||||||
|
- docker-container
|
3
ansible/roles/deploy_container_loki/defaults/main.yml
Normal file
3
ansible/roles/deploy_container_loki/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
container_loki_version: latest
|
||||||
|
container_loki_domain: loki.example.com
|
0
ansible/roles/deploy_container_loki/files/.gitkeep
Normal file
0
ansible/roles/deploy_container_loki/files/.gitkeep
Normal file
0
ansible/roles/deploy_container_loki/handlers/main.yml
Normal file
0
ansible/roles/deploy_container_loki/handlers/main.yml
Normal file
0
ansible/roles/deploy_container_loki/meta/main.yml
Normal file
0
ansible/roles/deploy_container_loki/meta/main.yml
Normal file
27
ansible/roles/deploy_container_loki/tasks/main.yml
Normal file
27
ansible/roles/deploy_container_loki/tasks/main.yml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
- name: Ensure data directories exist
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ container_base_dir }}/{{ item.dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
become: false
|
||||||
|
loop:
|
||||||
|
- {dir: "data"}
|
||||||
|
|
||||||
|
- name: Deploy Docker Compose and .env files
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ container_base_dir }}/{{ item.dest }}"
|
||||||
|
mode: '0644'
|
||||||
|
loop:
|
||||||
|
- { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' }
|
||||||
|
- { src: '.env.j2', dest: '.env' }
|
||||||
|
- { src: 'local-config.yaml.j2', dest: 'data/local-config.yaml' }
|
||||||
|
become: false
|
||||||
|
|
||||||
|
- name: Start Container
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ container_base_dir }}"
|
||||||
|
pull: always
|
||||||
|
docker_host: "unix:///run/user/1000/docker.sock"
|
||||||
|
become: false
|
2
ansible/roles/deploy_container_loki/templates/.env.j2
Normal file
2
ansible/roles/deploy_container_loki/templates/.env.j2
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
LOKI_VERSION={{ container_loki_version }}
|
||||||
|
LOKI_DOMAIN={{ container_loki_domain }}
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
services:
|
||||||
|
loki:
|
||||||
|
image: grafana/loki:${LOKI_VERSION}
|
||||||
|
container_name: loki
|
||||||
|
networks:
|
||||||
|
traefik:
|
||||||
|
volumes:
|
||||||
|
- ./data/local-config.yaml:/etc/loki/local-config.yaml
|
||||||
|
command: -config.file=/etc/loki/local-config.yaml
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.docker.network=traefik"
|
||||||
|
- "traefik.http.routers.loki.entrypoints=http"
|
||||||
|
- "traefik.http.routers.loki.rule=Host(`${LOKI_DOMAIN}`)"
|
||||||
|
- "traefik.http.middlewares.loki-https-redirect.redirectscheme.scheme=https"
|
||||||
|
- "traefik.http.routers.loki.middlewares=loki-https-redirect"
|
||||||
|
- "traefik.http.routers.loki-secure.entrypoints=https"
|
||||||
|
- "traefik.http.routers.loki-secure.rule=Host(`${LOKI_DOMAIN}`)"
|
||||||
|
- "traefik.http.routers.loki-secure.tls=true"
|
||||||
|
- "traefik.http.routers.loki-secure.service=loki"
|
||||||
|
- "traefik.http.services.loki.loadbalancer.server.port=3100"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
traefik:
|
||||||
|
external: true
|
|
@ -0,0 +1,32 @@
|
||||||
|
auth_enabled: false
|
||||||
|
|
||||||
|
server:
|
||||||
|
http_listen_port: 3100
|
||||||
|
|
||||||
|
common:
|
||||||
|
instance_addr: 0.0.0.0
|
||||||
|
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: tsdb
|
||||||
|
object_store: filesystem
|
||||||
|
schema: v13
|
||||||
|
index:
|
||||||
|
prefix: index_
|
||||||
|
period: 24h
|
||||||
|
|
||||||
|
ruler:
|
||||||
|
alertmanager_url: http://localhost:9093
|
||||||
|
|
||||||
|
analytics:
|
||||||
|
reporting_enabled: false
|
1
ansible/roles/deploy_container_loki/vars/main.yml
Normal file
1
ansible/roles/deploy_container_loki/vars/main.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
container_base_dir: /opt/docker/loki
|
Loading…
Add table
Reference in a new issue