-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Amadeusz Kryze
committed
Dec 21, 2021
1 parent
9c4a711
commit 6ae93d7
Showing
62 changed files
with
2,807 additions
and
29 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,56 @@ | ||
- name: Add prometheus to grafana | ||
loop: | ||
- home | ||
uri: | ||
url: "http://{{ inventory_hostname }}:{{ port_definition[ 'grafana_server' ] }}/api/datasources" | ||
method: POST | ||
user: root | ||
password: "{{ user_password }}" | ||
body: | ||
name: "prometheus-{{ item }}" | ||
type: "prometheus" | ||
url: "http://prometheus.{{ item }}.localhost:{{ port_definition[ 'prometheus_server' ] }}" | ||
access: "proxy" | ||
force_basic_auth: yes | ||
status_code: 200, 409 | ||
body_format: json | ||
|
||
- name: Add prometheus delta cached (trickster) to grafana | ||
loop: | ||
- home | ||
uri: | ||
url: "http://{{ inventory_hostname }}:{{ port_definition[ 'grafana_server' ] }}/api/datasources" | ||
method: POST | ||
user: root | ||
password: "{{ user_password }}" | ||
body: | ||
name: "prometheus-cached-{{ item }}" | ||
type: "prometheus" | ||
url: "http://prometheus.{{ item }}.localhost:{{ port_definition[ 'trickster' ] }}" | ||
access: "proxy" | ||
force_basic_auth: yes | ||
status_code: 200, 409 | ||
body_format: json | ||
|
||
- name: Add thanos to grafana | ||
loop: | ||
- {name: thanos, port: 10904, customQueryParameters: "max_source_resolution=1h&partial_response=true"} | ||
- {name: thanos-cached, port: 8000, customQueryParameters: "max_source_resolution=1h&partial_response=true"} | ||
- {name: thanos-cached-raw, port: 8000, customQueryParameters: "max_source_resolution=0"} | ||
- {name: thanos-objectstorage-only, port: 10911, customQueryParameters: "max_source_resolution=1h&partial_response=true"} | ||
uri: | ||
url: "http://{{ inventory_hostname }}:{{ port_definition[ 'grafana_server' ] }}/api/datasources" | ||
method: POST | ||
user: root | ||
password: "{{ user_password }}" | ||
body: | ||
type: prometheus | ||
name: "{{ item.name }}" | ||
access: "proxy" | ||
url: "http://thanos.nas.localhost:{{ item.port }}" | ||
jsonData: | ||
customQueryParameters: "{{ item.customQueryParameters }}" | ||
force_basic_auth: yes | ||
status_code: 200, 409 | ||
body_format: json | ||
|
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,102 @@ | ||
- name: Install deps | ||
become: True | ||
package: | ||
name: "{{ item }}" | ||
state: present | ||
loop: | ||
- python3-docker | ||
|
||
- name: Checking grafana directory | ||
become: True | ||
file: | ||
path: /opt/grafana/data | ||
state: directory | ||
|
||
- name: Docker run grafana-renderer | ||
docker_container: | ||
image: "grafana/grafana-image-renderer:{{ grafana_image_renderer_version }}" | ||
hostname: "{{ inventory_hostname }}" | ||
name: grafana-renderer | ||
state: started | ||
restart_policy: unless-stopped | ||
ports: | ||
- "0.0.0.0:{{ port_definition[ 'grafana_renderer' ] }}:{{ port_definition[ 'grafana_renderer' ] }}" | ||
pull: true | ||
recreate: true | ||
env: | ||
IGNORE_HTTPS_ERRORS: 'true' | ||
ENABLE_METRICS: 'true' | ||
# RENDERING_ARGS: --no-sandbox,--disable-setuid-sandbox,--disable-dev-shm-usage,--disable-accelerated-2d-canvas,--disable-gpu,--window-size=1280x720 | ||
|
||
- name: Docker run grafana | ||
docker_container: | ||
image: "grafana/grafana:{{ grafana_version }}" | ||
hostname: "{{ inventory_hostname }}" | ||
name: grafana | ||
state: started | ||
restart_policy: unless-stopped | ||
ports: | ||
- "0.0.0.0:{{ port_definition[ 'grafana_server' ] }}:{{ port_definition[ 'grafana_server' ] }}" | ||
pull: true | ||
recreate: true | ||
env: | ||
GF_INSTALL_PLUGINS: grafana-piechart-panel,neocat-cal-heatmap-panel | ||
GF_AUTH_ANONYMOUS_ENABLED: 'false' | ||
GF_AUTH_ANONYMOUS_ORG_NAME: 'AK95' | ||
GF_AUTH_ANONYMOUS_ORG_ROLE: 'Viewer' | ||
GF_SECURITY_ADMIN_USER: root | ||
GF_SECURITY_ADMIN_PASSWORD: "{{ user_password }}" | ||
GF_SERVER_DOMAIN: grafana.nas.localhost | ||
GF_SERVER_ENABLE_GZIP: 'true' | ||
GF_RENDERING_SERVER_URL: "http://{{ inventory_hostname }}:8081/render" | ||
GF_RENDERING_CALLBACK_URL: "renderer.nas.localhost" | ||
volumes: | ||
- /opt/grafana/data:/var/lib/grafana | ||
|
||
- name: "Wait for grafana #1" | ||
wait_for: | ||
host: "{{ inventory_hostname }}" | ||
port: "{{ port_definition[ 'grafana_server' ] }}" | ||
delay: 5 | ||
sleep: 5 | ||
timeout: 60 | ||
active_connection_states: | ||
- ESTABLISHED | ||
|
||
- name: Rename organisation | ||
uri: | ||
url: "http://{{ inventory_hostname }}:{{ port_definition[ 'grafana_server' ] }}/api/orgs/1" | ||
method: PUT | ||
user: root | ||
password: "{{ user_password }}" | ||
body: | ||
name: "AK95" | ||
force_basic_auth: yes | ||
status_code: 200 | ||
body_format: json | ||
|
||
- include_role: | ||
name: setup_grafana | ||
tasks_from: datasources.yml | ||
|
||
- name: Reload grafana config | ||
docker_container: | ||
name: grafana | ||
state: stopped | ||
force_kill: True | ||
kill_signal: HUP | ||
|
||
- name: "Wait for grafana #2" | ||
wait_for: | ||
host: "{{ inventory_hostname }}" | ||
port: "{{ port_definition[ 'grafana_server' ] }}" | ||
delay: 5 | ||
sleep: 5 | ||
timeout: 60 | ||
active_connection_states: | ||
- ESTABLISHED | ||
|
||
- name: "Wait for grafana #3" | ||
uri: | ||
timeout: 120 | ||
url: http://{{ inventory_hostname }}:{{ port_definition[ 'grafana_server' ] }}/ |
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,50 @@ | ||
- name: Install deps | ||
become: True | ||
package: | ||
name: "{{ item }}" | ||
state: present | ||
loop: | ||
- python3-docker | ||
|
||
- name: Create root karma folder | ||
become: True | ||
file: | ||
path: /opt/karma/ | ||
state: directory | ||
|
||
- name: Copy karma config | ||
template: | ||
src: config.yml.j2 | ||
dest: /opt/karma/config.yml | ||
mode: 0644 | ||
|
||
- name: Run karma | ||
docker_container: | ||
image: "lmierzwa/karma:{{ karma_version }}" | ||
hostname: "{{ inventory_hostname }}" | ||
name: karma | ||
state: started | ||
restart_policy: unless-stopped | ||
volumes: | ||
- "/opt/karma:/karmaui" | ||
ports: | ||
- "0.0.0.0:{{ port_definition[ 'prometheus_karma' ] }}:{{ port_definition[ 'prometheus_karma' ] }}" | ||
pull: true | ||
recreate: true | ||
command: | ||
- '--config.file /karmaui/config.yml' | ||
|
||
- name: "Wait for karma #1" | ||
wait_for: | ||
host: "{{ inventory_hostname }}" | ||
port: "{{ port_definition[ 'prometheus_karma' ] }}" | ||
delay: 5 | ||
sleep: 3 | ||
timeout: 1200 | ||
active_connection_states: | ||
- ESTABLISHED | ||
|
||
- name: "Wait for karma #2" | ||
uri: | ||
timeout: 120 | ||
url: "http://{{ inventory_hostname }}:{{ port_definition[ 'prometheus_karma' ] }}/" |
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,104 @@ | ||
alertmanager: | ||
interval: 15s | ||
servers: | ||
{% for instance in ['nas'] %} | ||
- name: "prometheus-{{ instance }}" | ||
uri: "http://prometheus.{{ instance }}.localhost:{{ port_definition[ 'prometheus_alertmanager' ] }}" | ||
proxy: true | ||
timeout: 20s | ||
{% endfor %} | ||
- name: "thanos-globalview" | ||
uri: "http://thanos.nas.localhost:{{ port_definition[ 'prometheus_alertmanager' ] }}" | ||
proxy: true | ||
timeout: 20s | ||
|
||
karma: | ||
name: Karma | ||
|
||
ui: | ||
refresh: 30s | ||
hideFiltersWhenIdle: False | ||
colorTitlebar: False | ||
minimalGroupWidth: 500 | ||
alertsPerGroup: 5 | ||
collapseGroups: collapsedOnMobile | ||
theme: dark | ||
multiGridLabel: severity | ||
|
||
listen: | ||
address: "0.0.0.0" | ||
port: {{ port_definition[ 'prometheus_karma' ] }} | ||
prefix: / | ||
|
||
receivers: | ||
strip: | ||
- opsgenie | ||
- pagerduty | ||
|
||
labels: | ||
color: | ||
unique: | ||
- "@alertmanager" | ||
- "@receiver" | ||
- "@cluster" | ||
- alertname | ||
- code | ||
- env | ||
- instance | ||
- job | ||
- level | ||
- method | ||
- origin | ||
- path | ||
- server | ||
- service_name | ||
- service_number | ||
- stack | ||
- status | ||
- task_id | ||
- type | ||
custom: | ||
severity: | ||
- value: warning | ||
color: "#264653" | ||
- value: low | ||
color: "#2a9d8f" | ||
- value: medium | ||
color: "#e9c46a" | ||
- value: high | ||
color: "#f4a261" | ||
- value: critical | ||
color: "#e76f51" | ||
strip: | ||
- host | ||
|
||
annotations: | ||
strip: | ||
- identifier | ||
|
||
grid: | ||
sorting: | ||
order: label | ||
reverse: false | ||
label: severity | ||
customValues: | ||
labels: | ||
severity: | ||
critical: 1 | ||
high: 2 | ||
medium: 3 | ||
low: 4 | ||
warning: 5 | ||
|
||
alertAcknowledgement: | ||
enabled: True | ||
duration: 20m0s | ||
author: Karma | ||
commentPrefix: Someone is fixing it. | ||
|
||
silences: | ||
comments: | ||
linkDetect: | ||
rules: | ||
- regex: "((T)-[0-9]+)" | ||
uriTemplate: https://jira.nas.localhost/browse/$1 |
Oops, something went wrong.