Provisioned Cloudwatch datasource not working

cloudwatch

#1

Hello everyone,
I want to preconfigure a few datasources in my Grafana server. I have a yml file named /etc/grafana/provisioning/datasources/ansible-configuration.yml

The contents of the file are:

    datasources:
    -   access: proxy
        isDefault: true
        name: Prometheus
        type: prometheus
        url: http://localhost:9090
    -   access: proxy
        name: Alertmanager
        type: prometheus-alertmanager
        url: htp://localhost:9093
    -   type: cloudwatch
        jsonData:
           authType: keys
           defaultRegion: eu-west-1
        secureJsonData:
           accessKey: <AWS ACCESS KEY>
           secretKey: <AWS SECRET KEY>
        type: cloudwatch
        name: AWS Account

My problem is that it’s not working!
I have a few dashboards that I copied from my Test Environment to the Production one. But they do not gather stats because (according to logs) there is a credentials issue. In the UI I get a

Templating init failed
Metric request error

error, which is translated to an issue with the provisioned datasource:

t=2018-12-05T11:24:46+0000 lvl=eror msg="Metric request error" logger=context userId=1 orgId=1 uname=grafanaadmin error="Failed to call cloudwatch:ListMetrics, NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors"

Obviously the credentials are checked and work just fine.

So, what is the problem here?


#2

OK, since I have my Grafana up and running again, I searched in the database to see what is going on.
Obviously, I hit bug #11537 because:

select * from data_source; 
id: 3
org_id: 1
version: 1
type: cloudwatch
name: AWS Account
access: proxy
url: 
password: 
user: 
database: 
basic_auth: 0
basic_auth_user: 
basic_auth_password: 
is_default: 0
json_data: {}
created: 2018-12-05 13:15:35
updated: 2018-12-05 16:43:41
with_credentials: 0
secure_json_data: {}
read_only: 1

So:
Can someone tell me what do I need to write in the json_data and mainly the secure_json_data fields in order to make it work?
I have no issue to create a script that will fix this until the bug is resolved.


#3

So, it’s not working even if I pass the values as JSON.
Obviously it’s a bug and I quite sure it will not be fixed soon.