Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add loki role #188

Merged
merged 21 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/loki-molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Loki Molecule

on:

Check warning on line 4 in .github/workflows/loki-molecule.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

4:1 [truthy] truthy value should be one of [false, true]
push:
branches:
- main
pull_request:
branches:
- main

defaults:
run:
working-directory: roles/loki

jobs:
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
distro:
- rockylinux9
- ubuntu2204
- debian12

steps:
- name: Check out the codebase.
uses: actions/checkout@v4

- name: Set up Python 3.
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install ansible molecule molecule-plugins[docker] docker

- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
11 changes: 7 additions & 4 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
./ @ishanjainn
/roles/grafana @gardar @ishanjainn
/roles/grafana_agent @ishanjainn @v-zhuravlev @gardar
/roles/mimir @GVengelen @gardar @ishanjainn
./ @ishanjainn
/roles/grafana @gardar @ishanjainn
/roles/grafana_agent @ishanjainn @v-zhuravlev @gardar
/roles/alloy @ishanjainn @v-zhuravlev @gardar
/roles/opentelemetry_collector @ishanjainn
/roles/loki @voidquark @ishanjainn
/roles/mimir @GVengelen @gardar @ishanjainn
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![GitHub Last Commit](https://img.shields.io/github/last-commit/grafana/grafana-ansible-collection)](https://github.com/grafana/grafana-ansible-collection/tags)
[![GitHub Contributors](https://img.shields.io/github/contributors/grafana/grafana-ansible-collection)](https://github.com/grafana/grafana-ansible-collection/tags)

This collection (`grafana.grafana`) contains modules and roles to assist in automating the management of resources in **Grafana**, **Grafana Agent**, and **OpenTelemetry Collector** with Ansible.
This collection (`grafana.grafana`) contains modules and roles to assist in automating the management of resources in **Grafana**, **Grafana Agent**, **OpenTelemetry Collector**, and **Loki** with Ansible.

- [Ansible collection Documentation](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/)
- [Grafana](https://grafana.com)
Expand Down Expand Up @@ -43,11 +43,12 @@ collections:

## Roles included in the collection

This collection includes the following roles to help set up and manage Grafana, Grafana Agent, and OpenTelemetry Collector:
This collection includes the following roles to help set up and manage Grafana, Grafana Agent, OpenTelemetry Collector, and Loki:

- **Grafana**: Installs and configures Grafana on your target hosts.
- **Grafana Agent**: Deploys and configures Grafana Agent, allowing for efficient metrics, logs, and trace data shipping to Grafana Cloud or other endpoints.
- **OpenTelemetry Collector**: Sets up and configures the OpenTelemetry Collector, enabling advanced observability features through data collection and transmission.
- **Loki**: Deploy and manage Loki, the log aggregation system.

## Using this collection

Expand Down
6 changes: 6 additions & 0 deletions examples/loki-basic-no-options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Deploy Loki using the default configuration
hosts: all
become: true
roles:
- role: grafana.grafana.loki
70 changes: 70 additions & 0 deletions examples/loki-local-filesystem-with-retention-and-alert.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
- name: Deploy Loki using the local filesystem
hosts: all
become: true
roles:
- role: grafana.grafana.loki
vars:
loki_querier:
max_concurrent: 16
engine:
max_look_back_period: 8760h
loki_storage_config:
tsdb_shipper:
active_index_directory: "{{ loki_working_path }}/tsdb-index"
cache_location: "{{ loki_working_path }}/tsdb-cache"
filesystem:
directory: "{{ loki_working_path }}/chunks"
loki_ingester:
wal:
enabled: true
dir: "{{ loki_working_path }}/wal"
lifecycler:
address: 127.0.0.1
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 1h
max_chunk_age: 2h
chunk_target_size: 1048576
query_store_max_look_back_period: 8760h
loki_limits_config:
split_queries_by_interval: 0
reject_old_samples: true
reject_old_samples_max_age: 168h
max_query_length: 0
max_query_series: 50000
retention_period: 8760h
allow_structured_metadata: false
max_query_lookback: 8760h
loki_compactor:
working_directory: "{{ loki_working_path }}/compactor"
compaction_interval: 10m
retention_enabled: true
retention_delete_delay: 2h
retention_delete_worker_count: 150
delete_request_store: filesystem
loki_common:
path_prefix: "{{ loki_working_path }}"
storage:
filesystem:
rules_directory: "{{ loki_working_path }}/rules"
replication_factor: 1
ring:
instance_addr: 127.0.0.1
kvstore:
store: inmemory
loki_ruler_alerts:
- name: Logs.sshd
rules:
- alert: SshLoginFailed

Check failure on line 62 in examples/loki-local-filesystem-with-retention-and-alert.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

62:9 [indentation] wrong indentation: expected 10 but found 8
expr: |
count_over_time({job=~"secure"} |="sshd[" |~": Failed|: Invalid|: Connection closed by authenticating user" | __error__="" [15m]) > 6
for: 0m
labels:
severity: critical
annotations:
summary: "{% raw %}SSH authentication failure (instance {{ $labels.instance }}).{% endraw %}"
description: "{% raw %}Increase of SSH authentication failures in last 15 minutes\\n VALUE = {{ $value }}{% endraw %}"
2 changes: 2 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ collections:
type: git
- name: https://github.com/ansible-collections/community.grafana.git
type: git
- name: https://github.com/ansible-collections/ansible.posix.git
type: git
Loading
Loading