How to automatically connect Grafana (with PostgreSQL instead of SQLite 3) to Prometheus when using Helm

4/30/2018

I am using Helm as for Kubernetes deployment (Grafana and Prometheus) specifically. I have specified values.yaml files for both of them. It works amazingly.

Since I have changed Grafana datasource from default sqlite3 to PostgreSQL - data-source configuration is now stored in PostgreSQL database.

Well, the problem is that in my values.yaml file* for **Grafana I have specified datasource as following:

datasources: {}
datasources.yaml:
  apiVersion: 1
  datasources:
  - name: on-premis
    type: prometheus
    url: http://prom-helmf-ns-monitoring-prometheus-server
    access: direct
    isDefault: true
...
...


grafana.ini:
  paths:
    data: /var/lib/grafana/data
    logs: /var/log/grafana
    plugins: /var/lib/grafana/plugins
  analytics:
    check_for_updates: true
  log:
    mode: console
  grafana_net:
    url: https://grafana.net
  database:
  ## You can configure the database connection by specifying type, host, name, user and password
  ## # as separate properties or as on string using the URL property.
  ## # Either "mysql", "postgres" or "sqlite3", it's your choice
    type: postgres
    host: qa.com:5432
    name: grafana
    user: grafana
    # If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;"""
    password: passwd
    ssl_mode: disable

Unfortunately this does not take an effect and I have to configure connection to in Grafana web interface manually - which is not what I need. How do I specify this section correctly?

datasources: {}
datasources.yaml:
  apiVersion: 1
  datasources:
  - name: on-premis
    type: prometheus
    url: http://prom-helmf-ns-monitoring-prometheus-server
    access: direct
    isDefault: true
-- user2156115
grafana
kubernetes
kubernetes-helm
prometheus

1 Answer

11/16/2018

remove '{}' after section datasources. like this

    datasources:
      datasources.yaml:
        apiVersion: 1
        datasources:
        - name: Prometheus
          type: prometheus
          url: http://prometheus-server
          access: proxy
          isDefault: true
-- NINJACOREjZ
Source: StackOverflow