Merge "Automatically add Prometheus as a Grafana datasource"

This commit is contained in:
Zuul 2018-05-07 09:00:23 +00:00 committed by Gerrit Code Review
commit ef228c3d61
5 changed files with 38 additions and 0 deletions

View File

@ -20,3 +20,4 @@
or grafana_conf.changed | bool
or grafana_container.changed | bool
or grafana_home_dashboard.changed | bool
or grafana_prometheus_data_source.changed | bool

View File

@ -80,6 +80,26 @@
notify:
- 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
kolla_docker:
action: "compare_container"

View File

@ -2,6 +2,7 @@
data = /var/lib/grafana
logs = /var/log/kolla/grafana
plugins = /var/lib/grafana/plugins
provisioning = /etc/grafana/provisioning
[server]
protocol = http

View File

@ -21,6 +21,13 @@
"owner": "root",
"perm": "0644",
"optional": true
},
{
"source": "{{ container_config_directory }}/prometheus.yaml",
"dest": "/etc/grafana/provisioning/datasources/prometheus.yaml",
"owner": "root",
"perm": "0644",
"optional": true
}
],
"permissions": [

View 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