mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
ansible: add monitoring setup playbook
This commit is contained in:
committed by
Dan Christian Bogos
parent
954be1d480
commit
2968cc5e3c
43
data/ansible/monitoring/README.md
Normal file
43
data/ansible/monitoring/README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
### CGRateS Monitoring Setup Playbook
|
||||
|
||||
#### Inventory (inventory.ini):
|
||||
|
||||
```ini
|
||||
[monit]
|
||||
foo.example.com ansible_host=myserverip ansible_port=22 ansible_user=myuser
|
||||
|
||||
[monit:vars]
|
||||
install_or_update_cgrates=true
|
||||
```
|
||||
|
||||
#### Run playbook:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory.ini /path/to/playbook/main.yml
|
||||
```
|
||||
|
||||
#### Access Grafana:
|
||||
|
||||
```bash
|
||||
ssh -L 8080:localhost:3000 myuser@myserverip
|
||||
```
|
||||
|
||||
Browse to http://localhost:8080 and login
|
||||
|
||||
username: admin
|
||||
password: admin
|
||||
|
||||
#### Components and their ports:
|
||||
CGRateS: 2012
|
||||
Node Exporter: 9100
|
||||
Prometheus: 9090
|
||||
Grafana: 3000
|
||||
|
||||
#### Imported Grafana dashboards:
|
||||
- Go Metrics (ID: 13240) - a custom solution for this one would be preferred
|
||||
- Node Exporter (ID: 1860)
|
||||
|
||||
> [!NOTE]
|
||||
> Go Metrics tracks both the node_exporter and prometheus alongside CGRateS (all written in go). Make sure that job "cgrates" is the one selected.
|
||||
|
||||
Services can be managed via systemd
|
||||
6
data/ansible/monitoring/grafana.ini
Normal file
6
data/ansible/monitoring/grafana.ini
Normal file
@@ -0,0 +1,6 @@
|
||||
[paths]
|
||||
provisioning = /etc/grafana/provisioning
|
||||
|
||||
[dashboards]
|
||||
providers.file.enabled = true
|
||||
providers.file.path = /etc/grafana/provisioning/dashboards
|
||||
9
data/ansible/monitoring/grafana_dashboard.yaml
Normal file
9
data/ansible/monitoring/grafana_dashboard.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: dashboards
|
||||
type: file
|
||||
disableDeletion: false
|
||||
allowUiUpdates: true
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
10
data/ansible/monitoring/grafana_datasource.yaml
Normal file
10
data/ansible/monitoring/grafana_datasource.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://localhost:9090
|
||||
isDefault: true
|
||||
editable: true
|
||||
version: 1
|
||||
81
data/ansible/monitoring/main.yaml
Normal file
81
data/ansible/monitoring/main.yaml
Normal file
@@ -0,0 +1,81 @@
|
||||
---
|
||||
- name: Set up monitoring for CGRateS
|
||||
hosts: all
|
||||
vars:
|
||||
cgrates_dependencies:
|
||||
- wget
|
||||
- gnupg
|
||||
tasks:
|
||||
- name: CGRateS install/update tasks
|
||||
when: install_or_update_cgrates | default(false) | bool
|
||||
block:
|
||||
- name: Install CGRateS dependencies
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: "{{ cgrates_dependencies }}"
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Download the GPG Key
|
||||
ansible.builtin.get_url:
|
||||
url: https://apt.cgrates.org/apt.cgrates.org.gpg.key
|
||||
dest: /tmp/apt.cgrates.org.asc
|
||||
|
||||
- name: Move the GPG Key to the trusted area
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
src: /tmp/apt.cgrates.org.asc
|
||||
dest: /etc/apt/trusted.gpg.d/apt.cgrates.org.asc
|
||||
remote_src: true
|
||||
|
||||
- name: Add the CGRateS repository to the sources list
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
content: "deb http://apt.cgrates.org/debian/ 1.0-bookworm main\n"
|
||||
dest: /etc/apt/sources.list.d/cgrates.list
|
||||
|
||||
- name: Install or upgrade CGRateS
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: cgrates
|
||||
state: latest
|
||||
update_cache: true
|
||||
|
||||
- name: Start the CGRateS service
|
||||
become: true
|
||||
ansible.builtin.systemd_service:
|
||||
name: cgrates
|
||||
state: restarted
|
||||
roles:
|
||||
- role: ../roles/node_exporter
|
||||
vars:
|
||||
node_exporter_service_state: started
|
||||
|
||||
- role: ../roles/prometheus
|
||||
vars:
|
||||
prometheus_config_file: prometheus.yml
|
||||
prometheus_service_state: started
|
||||
|
||||
- role: ../roles/grafana
|
||||
vars:
|
||||
grafana_service_state: started
|
||||
grafana_config_file: grafana.ini
|
||||
grafana_datasource_config_file: grafana_datasource.yaml
|
||||
grafana_dashboard_config_file: grafana_dashboard.yaml
|
||||
grafana_dashboard_sources:
|
||||
- type: url
|
||||
path: https://grafana.com/api/dashboards/13240/revisions/2/download
|
||||
alias: go_metrics.json
|
||||
modify_datasources: true # see https://github.com/grafana/grafana/issues/10786
|
||||
- type: url
|
||||
path: https://grafana.com/api/dashboards/1860/revisions/37/download
|
||||
alias: node_exporter.json
|
||||
|
||||
# - ../roles/go
|
||||
# - role: ../../roles/cgrates
|
||||
# vars:
|
||||
# # To avoid tasks/dependencies we don't need.
|
||||
# cgrates_dbs:
|
||||
# cgrates_dependencies:
|
||||
# - git
|
||||
# - redis
|
||||
15
data/ansible/monitoring/prometheus.yml
Normal file
15
data/ansible/monitoring/prometheus.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
scrape_configs:
|
||||
- job_name: prometheus
|
||||
static_configs:
|
||||
- targets: ['localhost:9090']
|
||||
|
||||
- job_name: node
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['localhost:9100']
|
||||
|
||||
- job_name: cgrates
|
||||
metrics_path: /prometheus
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['localhost:2080']
|
||||
Reference in New Issue
Block a user