YAML code to add postgresql instance host to grafana dashboard
- name: Add PostgreSQL as a data source in Grafana
hosts: grafana
gather_facts: false
vars:
grafana_url: "http://your-grafana-url"
grafana_user: "admin"
grafana_password: "Netradyne$456"
postgresql_host: "host"
postgresql_dbname: "netradyne-testing"
postgresql_user: "grafana-ro"
postgresql_password: "c81538a599"
service: "db-service"
datasource_name: "grafana-postgresql-{{ service }}-datasource"
tasks:
- name: Add PostgreSQL data source
uri:
url: "{{ grafana_url }}/api/datasources"
method: POST
user: "{{ grafana_user }}"
password: "{{ grafana_password }}"
body_format: json
headers:
Content-Type: "application/json"
Accept: "application/json"
body:
name: "{{ datasource_name }}"
type: "postgres"
url: "postgres://{{ postgresql_user }}:{{ postgresql_password }}@{{ postgresql_host }}:5432/{{ postgresql_dbname }}"
access: "proxy"
isDefault: true
jsonData:
postgresVersion: 1400
tlsAuth: false
tlsAuthWithCACert: false
sslmode: "disable"
timescaledb: false
secureJsonData:
password: "{{ postgresql_password }}"
ENV=staging make configure-task name=grafana-staging db-service=driveriplatform host=pgdriveriplatform.service.consul
Comments
Post a Comment