I need to integrate grafana with cockroachdb/postgress database.
I can reach to cockroachdb with cockroach binary with certificates, e.g below
[root@grafana1 ~]# cockroach sql --url “postgres://root@x.x.x.x:26257/?sslmode=verify-full” --certs-dir=/var/lib/cockroach/certs/
Welcome to the CockroachDB SQL shell.
All statements must be terminated by a semicolon.
To exit, type: \q.
Server version: CockroachDB CCL v19.2.4 (x86_64-unknown-linux-gnu, built 2020/02/06 21:55:19, go1.12.12) (same version as client)
Cluster ID: 1a058745-10ad-47ad-a692-c3cee13435ff
Enter ? for a brief introduction.
root@x.x.x.x:26257/defaultdb>
However, if I am connecting via grafana portal and add the datasource, it says x509: certificate signed by unknown authority. I have put the required cockroach certificates in /etc/ssl/certs as below.
[root@grafana1 ~]# ls -ltr /etc/ssl/certs/
total 32
-rwxr-xr-x. 1 root root 829 Aug 9 2019 renew-dummy-cert
-rw-r–r–. 1 root root 2516 Aug 9 2019 Makefile
-rwxr-xr-x. 1 root root 610 Aug 9 2019 make-dummy-cert
lrwxrwxrwx. 1 root root 55 Feb 6 06:51 ca-bundle.trust.crt → /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
lrwxrwxrwx. 1 root root 49 Feb 6 06:51 ca-bundle.crt → /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
-rw-r–r–. 1 grafana grafana 1139 Apr 14 05:02 node.crt
-rw-------. 1 grafana grafana 1679 Apr 14 05:03 node.key
-rw-r–r–. 1 grafana grafana 1111 Apr 14 05:04 ca.crt
-rw-------. 1 grafana grafana 1103 Apr 14 05:05 client.root.crt
-rw-------. 1 grafana grafana 1679 Apr 14 05:06 client.root.key
[root@grafana1 ~]#
I have tried to put the configuration in grafana.ini as below
[database]
url = postgres://root@10.102.10.58:26257/grafana
ca_cert_path = /var/lib/cockroach/certs/ca.crt
client_key_path = /var/lib/cockroach/certs/node.key
client_cert_path = /var/lib/cockroach/certs/node.crt
server_cert_name = Cockroach CA
When I restarted the grafana-server service it progressed a bit(can see many tables created under “grafana” daabase) and failed and never came up, with below error.
t=2020-04-16T08:15:56+0000 lvl=dbug msg=“Skipping migration: Already executed” logger=migrator id=“add unique index cache_data.cache_key”
t=2020-04-16T08:15:56+0000 lvl=eror msg=“Server shutdown” logger=server reason=“Service init failed: Failed to create admin user: failed to sync primary key for org table: pq: setval(): relation "org_id_seq" does not exist”
Now, I have another node, grafana2 where I tried to integrate postgres with grafana portal and there I got error (see attached
). I have put the certificates same as in grafana1.Could you please help me out how can I integrate it as I am not able to achoeve it using portal/cli.
Also, is the configuration of [database] in grafana.ini is same as adding a data store from portal ?