From 506a63697c71fcd70f1d3149a3794e650fc6c080 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Fri, 13 Nov 2020 00:31:15 +0900 Subject: [PATCH] Deploy `Grafana` provision data for Datasources. --- .../provisioning/datasources/loki.yaml | 25 +++++++++++++++++++ .../provisioning/datasources/prometheus.yaml | 25 +++++++++++++++++++ cookbooks/grafana/setup.rb | 8 ++++++ 3 files changed, 58 insertions(+) create mode 100644 cookbooks/grafana/files/etc/grafana/provisioning/datasources/loki.yaml create mode 100644 cookbooks/grafana/files/etc/grafana/provisioning/datasources/prometheus.yaml diff --git a/cookbooks/grafana/files/etc/grafana/provisioning/datasources/loki.yaml b/cookbooks/grafana/files/etc/grafana/provisioning/datasources/loki.yaml new file mode 100644 index 0000000..c0666fa --- /dev/null +++ b/cookbooks/grafana/files/etc/grafana/provisioning/datasources/loki.yaml @@ -0,0 +1,25 @@ +# # config file version +apiVersion: 1 + +# # list of datasources that should be deleted from the database +deleteDatasources: + - name: Loki + orgId: 1 + +# # list of datasources to insert/update depending +# # on what's available in the database +datasources: + # name of the datasource. Required + - name: Loki + # datasource type. Required + type: loki + # access mode. direct or proxy. Required + access: proxy + # org id. will default to orgId 1 if not specified + orgId: 1 + # url + url: http://localhost:3100 + version: 1 + # allow users to edit datasources from the UI. + editable: false + diff --git a/cookbooks/grafana/files/etc/grafana/provisioning/datasources/prometheus.yaml b/cookbooks/grafana/files/etc/grafana/provisioning/datasources/prometheus.yaml new file mode 100644 index 0000000..852acec --- /dev/null +++ b/cookbooks/grafana/files/etc/grafana/provisioning/datasources/prometheus.yaml @@ -0,0 +1,25 @@ +# # config file version +apiVersion: 1 + +# # list of datasources that should be deleted from the database +deleteDatasources: + - name: Prometheus + orgId: 1 + +# # list of datasources to insert/update depending +# # on what's available in the database +datasources: + # name of the datasource. Required + - name: Prometheus + # datasource type. Required + type: prometheus + # access mode. direct or proxy. Required + access: proxy + # org id. will default to orgId 1 if not specified + orgId: 1 + # url + url: http://localhost:9090 + version: 1 + # allow users to edit datasources from the UI. + editable: false + diff --git a/cookbooks/grafana/setup.rb b/cookbooks/grafana/setup.rb index 3e6a7e4..90c04d3 100644 --- a/cookbooks/grafana/setup.rb +++ b/cookbooks/grafana/setup.rb @@ -7,6 +7,14 @@ end end +%w(loki.yaml prometheus.yaml).each do |conf| + remote_file "/etc/grafana/provisioning/datasources/#{conf}" do + owner 'root' + group 'grafana' + mode '640' + end +end + # Start/Enable `grafana`: service 'grafana-server' do action [ :enable, :start ]