Giter VIP home page Giter VIP logo

ansible-prometheus's Introduction

Ansible Role: Prometheus

Build Status Galaxy

Installs Prometheus on Ubuntu 16.04 (Xenial)

Requirements

This role requires Ansible 2.4 or higher.

Role Variables

The role defines most of its variables in defaults/main.yml:

prometheus_components

  • List of components to be installed.
  • Default value: ["prometheus", "alertmanager", "telegram_bot"]

Telegram bot will install docker

prometheus_alertmanager_url

  • Url of the Alertmanager service.

  • Default value: http://{{alertmanager_url}}:{{alertmanager_port}}

  • Result Value "http://localhost:9093/"

alertmanager_url

  • Default Value: localhost

alertmanager_port:

  • Default : 9093

prometheus_version

  • Version of the Prometheus service.
  • Default value: 2.4.2

alertmanager_version

  • Version of the Alertmanager service.
  • Default value: 0.15.2

prometheus_prometheus_web_external_url:

  • The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically.
  • Default value: Not defined (By default get hostname)

prometheus_prometheus_web_route_prefix:

  • Prefix forthe internal routes of web endpoints.
  • Default value: Void

prometheus_alertmanager_web_external_url:

  • The URL under which Alertmanager is externally reachable (for example, if Alertmanagr is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Alertmanager. If omitted, relevant URL components will be derived automatically.
  • Default value: Not defined (By default get hostname)

prometheus_alertmanager_web_route_prefix:

  • Prefix forthe internal routes of web endpoints.
  • Default value: Void

Playbook Example

Basic Playbook

Run with default vars:

    - hosts: all
      roles:
        - role: ansible-prometheus
          prometheus_server: prometheus_hostname

Production Playbook

Run with default vars:
- hosts: all
      roles:
      - role: entercloudsuite.prometheus
        prometheus_conf_main: "prometheus/prometheus.yml"
        prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
        prometheus_rule_files:
          basic_rules:
            src:  "prometheus/rules/basic.rules"
            dest: basic.rules
          black_box_rules:
            src:  "prometheus/rules/black_box.rules"
            dest: black_box.rules

Production Tree Example

├── group_vars
│   └── all
├── host
├── playbook.yml
├── prometheus
│   ├── alertmanager.yml
│   ├── prometheus.yml
│   ├── rules
│   │   ├── basic.rules
│   │   └── black_box.rules
│   └── telegram_bot
│       ├── config.yaml
│       └── template.tmpl
├── requirements.yaml
└── roles

Prometheus bot configuration

Run with default vars:
- hosts: all
      roles:
      - role: entercloudsuite.prometheus
        prometheus_conf_main: "prometheus/prometheus.yml"
        prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
        prometheus_prometheus_bot_template_conf: prometheus/telegram_bot/template.tmpl
        prometheus_prometheus_bot_conf: prometheus/telegram_bot/config.yaml
        prometheus_rule_files:
          basic_rules:
            src:  "prometheus/rules/basic.rules"
            dest: basic.rules
          black_box_rules:
            src:  "prometheus/rules/black_box.rules"
            dest: black_box.rules

Configure Rules by git repository

you can manage rules by git repository, in 4 ways.

1. Open Repository

In case you wanna clone rules from openrepository. Example: https://github.com/entercloudsuite/prometheus-rules-collections.git

you nead configure just var prometheus_rule_git_repo

- hosts: all
      roles:
      - role: entercloudsuite.prometheus
        prometheus_conf_main: "prometheus/prometheus.yml"
        prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
        prometheus_rule_git_repo: https://github.com/entercloudsuite/prometheus-rules-collections.git

2. Private ssh repository wit pre loaded keys

- hosts: all
      roles:
      - role: entercloudsuite.prometheus
        prometheus_conf_main: "prometheus/prometheus.yml"
        prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
        prometheus_rule_git_repo: [email protected]:myuser/my_repo.git
        prometheus_rule_git_key_pathfile: /path_to_key/inmyserver/private.pem

3. Private ssh repository wit not pre loaded keys ( Example new clear installation)

- hosts: all
      roles:
      - role: entercloudsuite.prometheus
        prometheus_conf_main: "prometheus/prometheus.yml"
        prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
        prometheus_rule_git_repo: [email protected]:myuser/my_repo.git
        prometheus_rule_git_key: |
          -----BEGIN OPENSSH PRIVATE KEY-----
          MY_KEY
          -----END OPENSSH PRIVATE KEY-----

4. Private https repository

- hosts: all
      roles:
      - role: entercloudsuite.prometheus
        prometheus_conf_main: "prometheus/prometheus.yml"
        prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
        prometheus_rule_git_repo: https://git_username:[email protected]/myuser/my_repo.git

Testing

Tests are performed using Molecule.

Install Molecule or use docker-compose run --rm molecule to run a local Docker container, based on the enterclousuite/molecule project, from where you can use molecule.

  1. Run molecule create to start the target Docker container on your local engine.
  2. Use molecule login to log in to the running container.
  3. Edit the role files.
  4. Add other required roles (external) in the molecule/default/requirements.yml file.
  5. Edit the molecule/default/playbook.yml.
  6. Define infra tests under the molecule/default/tests folder using the goos verifier.
  7. When ready, use molecule converge to run the Ansible Playbook and molecule verify to execute the test suite.
    Note that the converge process starts performing a syntax check of the role.
    Destroy the Docker container with the command molecule destroy.

To run all the steps with just one command, run molecule test.

In order to run the role targeting a VM, use the playbook_deploy.yml file for example with the following command: ansible-playbook ansible-prometheus/molecule/default/playbook_deploy.yml -i VM_IP_OR_FQDN, -u ubuntu --private-key private.pem.

Fast Test

docker-compose run --rm molecule molecule create molecule converge

License

MIT

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.