Compare commits
No commits in common. "v1.1.2" and "v1.1.1" have entirely different histories.
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
### [1.1.2](https://git.laurivan.com/Dev/ansible-role-grafana/compare/v1.1.1...v1.1.2) (2023-04-12)
|
|
||||||
|
|
||||||
### [1.1.1](https://git.laurivan.com/Dev/ansible-role-grafana/compare/v1.1.0...v1.1.1) (2023-04-03)
|
### [1.1.1](https://git.laurivan.com/Dev/ansible-role-grafana/compare/v1.1.0...v1.1.1) (2023-04-03)
|
||||||
|
|
||||||
|
|
||||||
|
23
README.md
23
README.md
@ -1,6 +1,6 @@
|
|||||||
# laurivan.grafana
|
# laurivan.grafana
|
||||||
|
|
||||||
This role installs Grafana, InfluxDB and Prometheus via Docker.
|
This role installs Grafana via Docker.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@ -19,7 +19,6 @@ grafana_volume_base: "/mnt/data/grafana"
|
|||||||
grafana_setup_path: "{{ grafana_volume_base }}/config"
|
grafana_setup_path: "{{ grafana_volume_base }}/config"
|
||||||
grafana_volume_grafana: "{{ grafana_volume_base }}/grafana"
|
grafana_volume_grafana: "{{ grafana_volume_base }}/grafana"
|
||||||
grafana_volume_influxdb: "{{ grafana_volume_base }}/influxdb"
|
grafana_volume_influxdb: "{{ grafana_volume_base }}/influxdb"
|
||||||
grafana_volume_prometheus: "{{ grafana_volume_base }}/prometheus"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can however define specific volumes for the individual items:
|
You can however define specific volumes for the individual items:
|
||||||
@ -27,7 +26,6 @@ You can however define specific volumes for the individual items:
|
|||||||
- `grafana_setup_path` - where the Docker compose files are placed
|
- `grafana_setup_path` - where the Docker compose files are placed
|
||||||
- `grafana_volume_grafana` - volume for the grafana docker container
|
- `grafana_volume_grafana` - volume for the grafana docker container
|
||||||
- `grafana_volume_influxdb` - volume for InfluxDB
|
- `grafana_volume_influxdb` - volume for InfluxDB
|
||||||
- `grafana_volume_prometheus` - volume for Prometheus.io
|
|
||||||
|
|
||||||
### InfluxDB
|
### InfluxDB
|
||||||
|
|
||||||
@ -42,25 +40,6 @@ influxdb:
|
|||||||
admin_token: change_me
|
admin_token: change_me
|
||||||
```
|
```
|
||||||
|
|
||||||
### Prometheus
|
|
||||||
|
|
||||||
We define Prometheus variables:
|
|
||||||
|
|
||||||
```yml
|
|
||||||
prometheus_port: "9090"
|
|
||||||
|
|
||||||
grafana_prometheus_project: my-project
|
|
||||||
grafana_prometheus_job_name: prometheus
|
|
||||||
grafana_prometheus_scrape_interval: '120s'
|
|
||||||
grafana_prometheus_targets:
|
|
||||||
- "10.0.0.35:9100"
|
|
||||||
- "10.0.0.35:8080"
|
|
||||||
```
|
|
||||||
|
|
||||||
The targets are locations (ip address + port) where Prometheus polls for new data. This can be [cadvisor](https://github.com/google/cadvisor) or [node exporter](https://github.com/prometheus/node_exporter) for example.
|
|
||||||
|
|
||||||
**Note**: Prometheus should be an internal service (i.e., empty `prometheus_port`). Hence, it doesn't have any security in place.
|
|
||||||
|
|
||||||
### Grafana
|
### Grafana
|
||||||
|
|
||||||
We also define several variables for grafana
|
We also define several variables for grafana
|
||||||
|
@ -14,26 +14,10 @@ grafana:
|
|||||||
password: changeme
|
password: changeme
|
||||||
port: "3001"
|
port: "3001"
|
||||||
|
|
||||||
prometheus_port: "9090"
|
|
||||||
|
|
||||||
# Grafana and InfluxDB volumes
|
|
||||||
#
|
|
||||||
grafana_volume_base: "/mnt/grafana"
|
grafana_volume_base: "/mnt/grafana"
|
||||||
grafana_setup_path: "{{ grafana_volume_base }}/config"
|
grafana_setup_path: "{{ grafana_volume_base }}/config"
|
||||||
grafana_volume_grafana: "{{ grafana_volume_base }}/grafana"
|
grafana_volume_grafana: "{{ grafana_volume_base }}/grafana"
|
||||||
grafana_volume_influxdb: "{{ grafana_volume_base }}/influxdb"
|
grafana_volume_influxdb: "{{ grafana_volume_base }}/influxdb"
|
||||||
|
|
||||||
# Prometheus volumes
|
grafana_uid:
|
||||||
#
|
grafana_gid:
|
||||||
grafana_volume_prometheus: "{{ grafana_volume_base }}/prometheus"
|
|
||||||
|
|
||||||
grafana_prometheus_project: my-project
|
|
||||||
grafana_prometheus_job_name: prometheus
|
|
||||||
grafana_prometheus_scrape_interval: '120s'
|
|
||||||
grafana_prometheus_targets:
|
|
||||||
- "10.0.0.35:9100"
|
|
||||||
- "10.0.0.35:8080"
|
|
||||||
|
|
||||||
|
|
||||||
grafana_uid: "472"
|
|
||||||
grafana_gid: "0"
|
|
||||||
|
@ -16,7 +16,6 @@ platforms:
|
|||||||
volumes:
|
volumes:
|
||||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
- /var/run/docker.sock:/tmp/docker_mounted.sock
|
- /var/run/docker.sock:/tmp/docker_mounted.sock
|
||||||
- /mnt:/mnt
|
|
||||||
privileged: true
|
privileged: true
|
||||||
pre_build_image: true
|
pre_build_image: true
|
||||||
provisioner:
|
provisioner:
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- name: GRAFANA | Set up main directory
|
|
||||||
ansible.builtin.file:
|
|
||||||
state: directory
|
|
||||||
path: "{{ item }}"
|
|
||||||
owner: "{{ ansible_effective_user_id }}"
|
|
||||||
group: "{{ ansible_effective_group_id }}"
|
|
||||||
mode: "0750"
|
|
||||||
with_items:
|
|
||||||
- "{{ grafana_setup_path | expanduser | realpath }}/grafana-provisioning/"
|
|
||||||
- "{{ grafana_setup_path | expanduser | realpath }}/grafana-provisioning/datasources/"
|
|
||||||
tags:
|
|
||||||
- configuration
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: GRAFANA | Set up prometheus configuration directory
|
|
||||||
ansible.builtin.file:
|
|
||||||
state: directory
|
|
||||||
path: "{{ item }}"
|
|
||||||
owner: "{{ ansible_effective_user_id }}"
|
|
||||||
group: "{{ ansible_effective_group_id }}"
|
|
||||||
mode: "0755"
|
|
||||||
with_items:
|
|
||||||
- "{{ grafana_setup_path | expanduser | realpath }}/prometheus/"
|
|
||||||
tags:
|
|
||||||
- configuration
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: GRAFANA | Set up prometheus data directory
|
|
||||||
ansible.builtin.file:
|
|
||||||
state: directory
|
|
||||||
path: "{{ item }}"
|
|
||||||
owner: "{{ ansible_effective_user_id }}"
|
|
||||||
group: "{{ ansible_effective_group_id }}"
|
|
||||||
mode: "0777"
|
|
||||||
with_items:
|
|
||||||
- "{{ grafana_volume_prometheus | expanduser | realpath }}"
|
|
||||||
tags:
|
|
||||||
- configuration
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: GRAFANA | Set up influxdb mount point
|
|
||||||
ansible.builtin.file:
|
|
||||||
state: directory
|
|
||||||
path: "{{ item }}"
|
|
||||||
mode: "0750"
|
|
||||||
with_items:
|
|
||||||
- "{{ grafana_volume_influxdb | expanduser | realpath }}"
|
|
||||||
tags:
|
|
||||||
- configuration
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: GRAFANA | Set up grafana mount point
|
|
||||||
ansible.builtin.file:
|
|
||||||
state: directory
|
|
||||||
path: "{{ item }}"
|
|
||||||
owner: "{% if grafana_uid %}{{ grafana_uid }}{% else %}{{ ansible_effective_user_id }}{% endif %}"
|
|
||||||
group: "{% if grafana_gid %}{{ grafana_gid }}{% else %}{{ ansible_effective_group_id }}{% endif %}"
|
|
||||||
mode: "0777"
|
|
||||||
with_items:
|
|
||||||
- "{{ grafana_volume_grafana | expanduser | realpath }}"
|
|
||||||
- "{{ grafana_volume_grafana | expanduser | realpath }}/plugins"
|
|
||||||
tags:
|
|
||||||
- configuration
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: GRAFANA | Write docker-compose configuration files
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: "{{ item }}.j2"
|
|
||||||
dest: "{{ grafana_setup_path | expanduser | realpath }}/{{ item }}"
|
|
||||||
mode: '0640'
|
|
||||||
loop:
|
|
||||||
- "docker-compose.yml"
|
|
||||||
- "env.grafana.conf"
|
|
||||||
- "env.influxdb.conf"
|
|
||||||
tags:
|
|
||||||
- configuration
|
|
||||||
|
|
||||||
- name: GRAFANA | Write InfluxDB provisioning files
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: "grafana-provisioning/datasources/{{ item }}.j2"
|
|
||||||
dest: "{{ grafana_setup_path | expanduser | realpath }}/grafana-provisioning/datasources/{{ item }}"
|
|
||||||
mode: '0640'
|
|
||||||
loop:
|
|
||||||
- "datasource.yml"
|
|
||||||
tags:
|
|
||||||
- configuration
|
|
||||||
|
|
||||||
- name: GRAFANA | Write Prometheus configuration
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: "prometheus-provisioning/prometheus.yml.j2"
|
|
||||||
dest: "{{ grafana_setup_path | expanduser | realpath }}/prometheus/prometheus.yml"
|
|
||||||
mode: '0644'
|
|
||||||
tags:
|
|
||||||
- configuration
|
|
@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- name: Ensure all requested components are running.
|
|
||||||
community.docker.docker_compose:
|
|
||||||
project_src: "{{ grafana_setup_path | expanduser | realpath }}"
|
|
||||||
build: false
|
|
||||||
become: true
|
|
@ -1,14 +1,72 @@
|
|||||||
---
|
---
|
||||||
# tasks file for grafana
|
# tasks file for grafana
|
||||||
|
- name: Set up main directory
|
||||||
- name: "GRAFANA | Configure"
|
ansible.builtin.file:
|
||||||
import_tasks: config.yml
|
state: directory
|
||||||
|
path: "{{ item }}"
|
||||||
|
owner: "{{ ansible_effective_user_id }}"
|
||||||
|
group: "{{ ansible_effective_group_id }}"
|
||||||
|
mode: "0750"
|
||||||
|
with_items:
|
||||||
|
- "{{ grafana_setup_path | expanduser | realpath }}/grafana-provisioning/"
|
||||||
|
- "{{ grafana_setup_path | expanduser | realpath }}/grafana-provisioning/datasources/"
|
||||||
tags:
|
tags:
|
||||||
- configure
|
- configuration
|
||||||
- grafana
|
become: true
|
||||||
|
|
||||||
- name: "GRAFANA | Install"
|
- name: Set up influxdb mount point
|
||||||
import_tasks: install.yml
|
ansible.builtin.file:
|
||||||
|
state: directory
|
||||||
|
path: "{{ item }}"
|
||||||
|
owner: "{% if grafana_uid %}{{ grafana_uid }}{% else %}{{ ansible_effective_user_id }}{% endif %}"
|
||||||
|
group: "{% if grafana_gid %}{{ grafana_gid }}{% else %}{{ ansible_effective_group_id }}{% endif %}"
|
||||||
|
mode: "0750"
|
||||||
|
with_items:
|
||||||
|
- "{{ grafana_volume_influxdb | expanduser | realpath }}"
|
||||||
tags:
|
tags:
|
||||||
- install
|
- configuration
|
||||||
- grafana
|
become: true
|
||||||
|
|
||||||
|
- name: Set up grafana mount point
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: directory
|
||||||
|
path: "{{ item }}"
|
||||||
|
# owner: "{% if grafana_uid %}{{ grafana_uid }}{% else %}{{ ansible_effective_user_id }}{% endif %}"
|
||||||
|
# group: "{% if grafana_gid %}{{ grafana_gid }}{% else %}{{ ansible_effective_group_id }}{% endif %}"
|
||||||
|
owner: "472"
|
||||||
|
group: "0"
|
||||||
|
mode: "0777"
|
||||||
|
with_items:
|
||||||
|
- "{{ grafana_volume_grafana | expanduser | realpath }}"
|
||||||
|
- "{{ grafana_volume_grafana | expanduser | realpath }}/plugins"
|
||||||
|
tags:
|
||||||
|
- configuration
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Write configuration files
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "{{ item }}.j2"
|
||||||
|
dest: "{{ grafana_setup_path | expanduser | realpath }}/{{ item }}"
|
||||||
|
mode: '0640'
|
||||||
|
loop:
|
||||||
|
- "docker-compose.yml"
|
||||||
|
- "env.grafana.conf"
|
||||||
|
- "env.influxdb.conf"
|
||||||
|
tags:
|
||||||
|
- configuration
|
||||||
|
|
||||||
|
- name: Write datasource provisioning files
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "grafana-provisioning/datasources/{{ item }}.j2"
|
||||||
|
dest: "{{ grafana_setup_path | expanduser | realpath }}/grafana-provisioning/datasources/{{ item }}"
|
||||||
|
mode: '0640'
|
||||||
|
loop:
|
||||||
|
- "datasource.yml"
|
||||||
|
tags:
|
||||||
|
- configuration
|
||||||
|
|
||||||
|
- name: Ensure all requested components are running.
|
||||||
|
community.docker.docker_compose:
|
||||||
|
project_src: "{{ grafana_setup_path | expanduser | realpath }}"
|
||||||
|
build: false
|
||||||
|
become: true
|
||||||
|
@ -1,21 +1,7 @@
|
|||||||
version: '3.9'
|
version: '3.9'
|
||||||
services:
|
services:
|
||||||
prometheus:
|
|
||||||
image: prom/prometheus:latest
|
|
||||||
container_name: monitoring_prometheus
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
|
||||||
- '{{ grafana_setup_path | expanduser | realpath }}/prometheus:/etc/prometheus'
|
|
||||||
- '{{ grafana_volume_prometheus | expanduser | realpath }}:/prometheus'
|
|
||||||
ports:
|
|
||||||
{% if prometheus_port is defined %}- "{{ prometheus_port }}:9090"{% endif %}
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- grafana
|
|
||||||
|
|
||||||
influxdb:
|
influxdb:
|
||||||
image: influxdb:latest
|
image: influxdb:latest
|
||||||
container_name: monitoring_influxdb
|
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- '{{ influxdb.port }}:8086'
|
- '{{ influxdb.port }}:8086'
|
||||||
@ -28,7 +14,6 @@ services:
|
|||||||
|
|
||||||
grafana:
|
grafana:
|
||||||
image: grafana/grafana-oss:latest
|
image: grafana/grafana-oss:latest
|
||||||
container_name: monitoring_grafana
|
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- '{{ grafana.port }}:3000'
|
- '{{ grafana.port }}:3000'
|
||||||
@ -37,11 +22,14 @@ services:
|
|||||||
- "{{ grafana_setup_path | expanduser | realpath }}/grafana-provisioning/:/etc/grafana/provisioning/"
|
- "{{ grafana_setup_path | expanduser | realpath }}/grafana-provisioning/:/etc/grafana/provisioning/"
|
||||||
depends_on:
|
depends_on:
|
||||||
- influxdb
|
- influxdb
|
||||||
- prometheus
|
|
||||||
env_file:
|
env_file:
|
||||||
- "{{ grafana_setup_path | expanduser | realpath }}/env.grafana.conf"
|
- "{{ grafana_setup_path | expanduser | realpath }}/env.grafana.conf"
|
||||||
networks:
|
networks:
|
||||||
- grafana
|
- grafana
|
||||||
|
|
||||||
|
# Run as user:
|
||||||
|
# owner: "{% if grafana_uid %}{{ grafana_uid }}{% else %}{{ ansible_effective_user_id }}{% endif %}"
|
||||||
|
# group: "{% if grafana_gid %}{{ grafana_gid }}{% else %}{{ ansible_effective_group_id }}{% endif %}"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
grafana: {}
|
grafana: {}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
---
|
lines (14 sloc) 345 Bytes
|
||||||
apiVersion: 1
|
apiVersion: 1
|
||||||
datasources:
|
datasources:
|
||||||
- name: InfluxDB
|
- name: InfluxDB
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
# my global config
|
|
||||||
global:
|
|
||||||
scrape_interval: 120s # By default, scrape targets every 15 seconds.
|
|
||||||
evaluation_interval: 120s # By default, scrape targets every 15 seconds.
|
|
||||||
# scrape_timeout is set to the global default (10s).
|
|
||||||
|
|
||||||
# Attach these labels to any time series or alerts when communicating with
|
|
||||||
# external systems (federation, remote storage, Alertmanager).
|
|
||||||
external_labels:
|
|
||||||
monitor: "{{ grafana_prometheus_project }}"
|
|
||||||
|
|
||||||
# Load and evaluate rules in this file every 'evaluation_interval' seconds.
|
|
||||||
rule_files:
|
|
||||||
# - "alert.rules"
|
|
||||||
# - "first.rules"
|
|
||||||
# - "second.rules"
|
|
||||||
|
|
||||||
# A scrape configuration containing exactly one endpoint to scrape:
|
|
||||||
# Here it's Prometheus itself.
|
|
||||||
scrape_configs:
|
|
||||||
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
|
||||||
- job_name: "{{ grafana_prometheus_job_name }}"
|
|
||||||
|
|
||||||
# Override the global default and scrape targets from this job every 5 seconds.
|
|
||||||
scrape_interval: "{{ grafana_prometheus_scrape_interval }}"
|
|
||||||
|
|
||||||
# metrics_path defaults to '/metrics'
|
|
||||||
# scheme defaults to 'http'.
|
|
||||||
|
|
||||||
static_configs:
|
|
||||||
- targets:
|
|
||||||
- 'localhost:9090'
|
|
||||||
{% for target in grafana_prometheus_targets %}
|
|
||||||
- "{{ target }}""
|
|
||||||
{% endfor %}
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
|||||||
---
|
---
|
||||||
# vars file for grafana
|
# vars file for grafana
|
Loading…
Reference in New Issue
Block a user