Automatically add Prometheus as a Grafana datasource
Assuming both Prometheus and Grafana are enabled, this change configures Grafana such that it can use data collected by the Prometheus server. Partially-Implements: blueprint prometheus Change-Id: I0290806d0c622b1de33cf7047f099795b4c780b9
This commit is contained in:
parent
32fa09968b
commit
6777c903a0
@ -20,3 +20,4 @@
|
|||||||
or grafana_conf.changed | bool
|
or grafana_conf.changed | bool
|
||||||
or grafana_container.changed | bool
|
or grafana_container.changed | bool
|
||||||
or grafana_home_dashboard.changed | bool
|
or grafana_home_dashboard.changed | bool
|
||||||
|
or grafana_prometheus_data_source.changed | bool
|
||||||
|
@ -80,6 +80,26 @@
|
|||||||
notify:
|
notify:
|
||||||
- Restart grafana container
|
- Restart grafana container
|
||||||
|
|
||||||
|
- name: Configuring Prometheus as data source for Grafana
|
||||||
|
vars:
|
||||||
|
service: "{{ grafana_services['grafana'] }}"
|
||||||
|
template:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: "{{ node_config_directory }}/grafana/prometheus.yaml"
|
||||||
|
mode: "0660"
|
||||||
|
become: true
|
||||||
|
register: grafana_prometheus_data_source
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
- enable_prometheus | bool
|
||||||
|
with_first_found:
|
||||||
|
- "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/prometheus.yaml"
|
||||||
|
- "{{ node_custom_config }}/grafana/prometheus.yaml"
|
||||||
|
- "prometheus.yaml.j2"
|
||||||
|
notify:
|
||||||
|
- Restart grafana container
|
||||||
|
|
||||||
- name: Check grafana containers
|
- name: Check grafana containers
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "compare_container"
|
action: "compare_container"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
data = /var/lib/grafana
|
data = /var/lib/grafana
|
||||||
logs = /var/log/kolla/grafana
|
logs = /var/log/kolla/grafana
|
||||||
plugins = /var/lib/grafana/plugins
|
plugins = /var/lib/grafana/plugins
|
||||||
|
provisioning = /etc/grafana/provisioning
|
||||||
|
|
||||||
[server]
|
[server]
|
||||||
protocol = http
|
protocol = http
|
||||||
|
@ -21,6 +21,13 @@
|
|||||||
"owner": "root",
|
"owner": "root",
|
||||||
"perm": "0644",
|
"perm": "0644",
|
||||||
"optional": true
|
"optional": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "{{ container_config_directory }}/prometheus.yaml",
|
||||||
|
"dest": "/etc/grafana/provisioning/datasources/prometheus.yaml",
|
||||||
|
"owner": "root",
|
||||||
|
"perm": "0644",
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
9
ansible/roles/grafana/templates/prometheus.yaml.j2
Normal file
9
ansible/roles/grafana/templates/prometheus.yaml.j2
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
|
||||||
|
datasources:
|
||||||
|
- name: Prometheus
|
||||||
|
type: prometheus
|
||||||
|
access: proxy
|
||||||
|
orgId: 1
|
||||||
|
url: http://{{ kolla_internal_vip_address }}:{{ prometheus_port }}
|
||||||
|
version: 1
|
Loading…
x
Reference in New Issue
Block a user