-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ansible Role for deploying grafana-agent
Signed-off-by: Adam Kraitman <[email protected]>
- Loading branch information
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- hosts: all | ||
strategy: free | ||
roles: | ||
- grafana_agent | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
# Mimir URL and creds | ||
agent_mimir_url: "http://sepia-grafana.front.sepia.ceph.com:9009/api/v1/push" | ||
agent_mimir_username: "admin" | ||
|
||
scrape_interval_global: "60s" | ||
scrape_interval_node: "30s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: "Restart grafana agent instance" | ||
become: true | ||
ansible.builtin.service: | ||
name: "grafana-agent" | ||
state: "restarted" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
dependencies: | ||
- role: secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
- name: Include secrets | ||
include_vars: "{{ secrets_path | mandatory }}/mimir_password.yml" | ||
no_log: true | ||
tags: | ||
- always | ||
|
||
- name: "Import Grafana GPG key" | ||
become: true | ||
ansible.builtin.apt_key: | ||
url: "https://apt.grafana.com/gpg.key" | ||
state: "present" | ||
when: ansible_pkg_mgr == "apt" | ||
|
||
- name: "Add Grafana's repository to APT sources list" | ||
become: true | ||
ansible.builtin.apt_repository: | ||
repo: "deb https://apt.grafana.com stable main" | ||
state: present | ||
when: ansible_pkg_mgr == "apt" | ||
|
||
- name: "Add Grafana's repository to yum/dnf systems" | ||
become: true | ||
ansible.builtin.yum_repository: | ||
baseurl: "https://rpm.grafana.com" | ||
name: "grafana" | ||
description: "grafana" | ||
gpgcheck: true | ||
gpgkey: "https://rpm.grafana.com/gpg.key" | ||
state: present | ||
when: ansible_os_family == "RedHat" | ||
|
||
- name: "Install grafana-agent" | ||
become: true | ||
ansible.builtin.package: | ||
name: "grafana-agent" | ||
state: "present" | ||
|
||
- name: "Enable grafana-agent" | ||
become: true | ||
ansible.builtin.service: | ||
name: "grafana-agent" | ||
state: "started" | ||
enabled: true | ||
|
||
# Deploy config file from template and restart the agent | ||
- name: "Configure agent" | ||
become: true | ||
ansible.builtin.template: | ||
src: "templates/grafana-agent.yaml.j2" | ||
dest: "/etc/grafana-agent.yaml" | ||
mode: "0440" | ||
owner: "root" | ||
group: "grafana-agent" | ||
notify: "Restart grafana agent instance" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
server: | ||
log_level: info | ||
|
||
metrics: | ||
global: | ||
remote_write: | ||
- url: {{ agent_mimir_url }} | ||
basic_auth: | ||
username: {{ agent_mimir_username }} | ||
password: {{ agent_mimir_password }} | ||
queue_config: | ||
max_backoff: 5m | ||
external_labels: | ||
nodetype: unknown_nodetype | ||
ingest_instance: {{ inventory_hostname }} | ||
scrape_interval: {{ scrape_interval_global }} | ||
configs: | ||
- name: {{ inventory_hostname }} | ||
scrape_configs: | ||
- job_name: 'grafana-agent-exporter' | ||
relabel_configs: | ||
- source_labels: [__address__] | ||
target_label: instance | ||
replacement: {{ inventory_hostname }} | ||
|
||
integrations: | ||
node_exporter: | ||
enabled: true | ||
scrape_interval: {{ scrape_interval_node }} | ||
instance: {{ inventory_hostname }} | ||
rootfs_path: / | ||
sysfs_path: /sys | ||
procfs_path: /proc |