Giter Club home page Giter Club logo

ansible-role-promtail's Introduction

Ansible Role: promtail

Build Status License Ansible Role GitHub tag

Description

Deploy promtail using ansible. Supports amd64 and arm architectures. For recent changes, please check the CHANGELOG or have a look at github releases

Requirements

  • Ansible >= 2.7

Role Variables

All variables which can be overridden are stored in defaults/main.yml file as well as in table below.

Name Default Value Description
promtail_version "1.5.0" promtail package version. Also accepts latest as parameter.
promtail_config_dir /etc/promtail Directory for storing promtail configuration file
promtail_config_file_sd_dir "{{ promtail_config_dir }}/file_sd" Default directory for file_sd discovery
promtail_config_file "{{ promtail_config_dir }}/promtail.yml" Configuration file used by promtail
promtail_system_user promtail User the promtail process will run at
promtail_system_group "{{ promtail_system_user }}" Group of the promtail user
promtail_user_additional_groups "adm" Additional groups to be added to promtail user to give access to allow scraping of specific log files
promtail_config_clients see defaults/main.yml promtail client_config section
promtail_loki_server_url http://127.0.0.1:3100 Server url where promtail will push its result
promtail_config_server see defaults/main.yml promtail server_config section
promtail_config_positions {} promtail position_config section
promtail_config_scrape_configs [] promtail scrap_configs section
promtail_target_config {} promtail target_config section
promtail_log_level "info" Loglevel of promtail (one of: debug,info,warn,error )
promtail_config_include_default_file_sd_config "True" When set to false, the default file_sd will not be provisioned

For each section (promtail_config_clients, promtail_config_server,promtail_config_positions,promtail_config_scrape_configs,promtail_target_config) the configuration can be passed accrodingly to the official promtail configuration. The role will converte the ansible vars into the respective yaml configuration for loki.

Example Playbook

Basic playbook that will assume that loki will be listening at http://127.0.0.1:3100 and a simple configuration to scrape /var/log logs

---
- hosts: all
  roles:
    - role: patrickjahns.promtail
      vars: 
        promtail_config_scrape_configs:
          - job_name: system
            entry_parser: raw
            static_configs:
            - targets:
                - localhost
              labels:
                job: varlogs
                __path__: /var/log/*log

More complex example, that overrides server, client, positions configuration and provides a scrap configuration for /var/log

---
- hosts: all
  roles:
    - role: patrickjahns.promtail
      vars: 
        promtail_config_server:
          http_listen_port: 9080
          grpc_listen_port: 9081
        promtail_config_clients:
          - url: "http://prometheus.domain.tld:3100/loki/api/v1/push"
            external_labels:
              host: "{{ ansible_hostname }}"
        promtail_config_positions:
          filename: /tmp/positions.yaml

        promtail_config_scrape_configs:
          - job_name: system
            entry_parser: raw
            static_configs:
            - targets:
                - localhost
              labels:
                job: varlogs
                __path__: /var/log/*log

Local Testing

The preferred way of locally testing the role is to use Docker and molecule (v3.x). You will have to install Docker on your system. See "Get started" for a Docker package suitable to for your system. We are using tox to simplify process of testing on multiple ansible versions. To install tox execute:

pip3 install tox

To run tests on all ansible versions (WARNING: this can take some time)

tox

To run a custom molecule command on custom environment with only default test scenario:

tox -e ansible29 -- molecule test -s default

For more information about molecule go to their docs.

If you would like to run tests on remote docker host just specify DOCKER_HOST variable before running tox tests.

CI

Travis

Combining molecule and travis CI allows us to test how new PRs will behave when used with multiple ansible versions and multiple operating systems. This also allows use to create test scenarios for different role configurations. As a result we have a quite large test matrix which will take more time than local testing, so please be patient.

Github Actions

Additionally to TravisCI some github actions are run to perform static code analysis

License

This project is licensed under MIT License. See LICENSE for more details.

Maintainers and Contributors

ansible-role-promtail's People

Contributors

actions-user avatar github-actions[bot] avatar mkeesey avatar patrickjahns avatar riptl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.