Add Prometheus datasource for Grafana

The commit reworks the layout to allow composable configurations by
splitting out server and datasource configurations.

The change stays backward compatible.

Change-Id: Id674840ca0947ccff44cb444d3eddcc51afc5e56
diff --git a/README.rst b/README.rst
index 1f1c8f4..b418f37 100644
--- a/README.rst
+++ b/README.rst
@@ -79,6 +79,45 @@
                 echo 7 > /sys/class/net/eth4/device/sriov_numvfs; sleep 2; ip link set eth4 up
                 exit 0
 
+Grafana
+=======
+
+Configure Grafana client
+------------------------
+
+The grafana.client talks to Grafana server to create datasource(s) and install
+Grafana plugin(s).
+
+User models must first include this class and define corresponding parameters:
+
+- grafana.client
+  - grafana_protocol (default: http)
+  - grafana_address
+  - grafana_port (default: 3000)
+  - grafana_user
+  - grafana_password
+
+Then include datasource(s) and define corresponding parameters:
+
+- grafana.client.datasource.influxdb
+  - grafana_influxdb_address
+  - grafana_influxdb_port
+  - grafana_influxdb_user
+  - grafana_influxdb_password
+  - grafana_influxdb_database
+  - grafana_influxdb_is_default (default true)
+
+- grafana.client.datasource.prometheus
+  - grafana_prometheus_address
+  - grafana_prometheus_port
+  - grafana_prometheus_is_default (default true)
+
+Backwark compatiblity
+---------------------
+
+The class **grafana.client.single** configures grafana client and an InfluxDB
+datasource. This is the legacy of LMA (aka StackLight) integration with Grafana
+and InfluxDB.
 
 Nagios Monitoring
 =================
diff --git a/grafana/client/datasource/influxdb.yml b/grafana/client/datasource/influxdb.yml
new file mode 100644
index 0000000..7abe22f
--- /dev/null
+++ b/grafana/client/datasource/influxdb.yml
@@ -0,0 +1,17 @@
+parameters:
+  _param:
+    grafana_influxdb_is_default: true
+    grafana_influxdb_ds_name: influxdb
+  grafana:
+    client:
+      datasource:
+        influxdb:
+          type: influxdb
+          name: ${_param:grafana_influxdb_ds_name}
+          host: ${_param:grafana_influxdb_address}
+          port: ${_param:grafana_influxdb_port}
+          user: ${_param:grafana_influxdb_user}
+          password: ${_param:grafana_influxdb_password}
+          database: ${_param:grafana_influxdb_database}
+          is_default: ${_param:grafana_influxdb_is_default}
+
diff --git a/grafana/client/datasource/prometheus.yml b/grafana/client/datasource/prometheus.yml
new file mode 100644
index 0000000..c4835ef
--- /dev/null
+++ b/grafana/client/datasource/prometheus.yml
@@ -0,0 +1,14 @@
+parameters:
+  _param:
+    grafana_prometheus_is_default: true
+    grafana_prometheus_ds_name: prometheus
+  grafana:
+    client:
+      datasource:
+        prometheus:
+          type: prometheus
+          name: ${_param:grafana_prometheus_ds_name}
+          host: ${_param:grafana_prometheus_address}
+          port: ${_param:grafana_prometheus_port}
+          is_default: ${_param:grafana_prometheus_is_default}
+
diff --git a/grafana/client/init.yml b/grafana/client/init.yml
new file mode 100644
index 0000000..08a9be8
--- /dev/null
+++ b/grafana/client/init.yml
@@ -0,0 +1,17 @@
+classes:
+- service.grafana.client.single
+parameters:
+  _param:
+    grafana_protocol: http
+    grafana_port: 3000
+  grafana:
+    client:
+      enabled: true
+      server:
+        protocol: ${_param:grafana_protocol}
+        host: ${_param:grafana_address}
+        port: ${_param:grafana_port}
+        user: ${_param:grafana_user}
+        password: ${_param:grafana_password}
+      remote_data:
+        engine: 'salt_mine'
diff --git a/grafana/client/single.yml b/grafana/client/single.yml
index 49ac876..87992a7 100644
--- a/grafana/client/single.yml
+++ b/grafana/client/single.yml
@@ -1,23 +1,12 @@
 classes:
-- service.grafana.client.single
+- system.grafana.client
+- system.grafana.client.datasource.influxdb
 parameters:
-  grafana:
-    client:
-      enabled: true
-      server:
-        protocol: http
-        host: ${_param:stacklight_monitor_address}
-        port: 3000
-        user: ${_param:grafana_user}
-        password: ${_param:grafana_password}
-      remote_data:
-        engine: 'salt_mine'
-      datasource:
-        lma:
-          type: influxdb
-          host: ${_param:grafana_influxdb_host}
-          port: ${_param:influxdb_port}
-          user: lma
-          password: ${_param:influxdb_stacklight_password}
-          database: lma
-          is_default: true
+  _param:
+    grafana_address: ${_param:stacklight_monitor_address}
+    grafana_influxdb_address: ${_param:grafana_influxdb_host}
+    grafana_influxdb_port: ${_param:influxdb_port}
+    grafana_influxdb_user: lma
+    grafana_influxdb_password: ${_param:influxdb_stacklight_password}
+    grafana_influxdb_database: lma
+    grafana_influxdb_ds_name: lma