Data source API

    Example Request:

    Example Response:

    1. HTTP/1.1 200
    2. Content-Type: application/json
    3. [
    4. {
    5. "id":1,
    6. "orgId":1,
    7. "name":"datasource_elastic",
    8. "type":"elasticsearch",
    9. "access":"proxy",
    10. "url":"http://mydatasource.com",
    11. "password":"",
    12. "user":"",
    13. "database":"grafana-dash",
    14. "basicAuth":false,
    15. "basicAuthUser":"",
    16. "basicAuthPassword":"",
    17. "isDefault":false,
    18. "jsonData":null
    19. }
    20. ]

    Get a single data source by Id

    GET /api/datasources/:datasourceId

    Example Request:

    1. GET /api/datasources/1 HTTP/1.1
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

    Example Response:

    1. HTTP/1.1 200
    2. Content-Type: application/json
    3. {
    4. "id":1,
    5. "orgId":1,
    6. "name":"test_datasource",
    7. "type":"graphite",
    8. "access":"proxy",
    9. "url":"http://mydatasource.com",
    10. "user":"",
    11. "database":"",
    12. "basicAuth":false,
    13. "basicAuthUser":"",
    14. "basicAuthPassword":"",
    15. "isDefault":false,
    16. "jsonData":null

    Get a single data source by Name

    GET /api/datasources/name/:name

    Example Request:

    1. GET /api/datasources/name/test_datasource HTTP/1.1
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

    Example Response:

    Example Request:

    1. GET /api/datasources/id/test_datasource HTTP/1.1
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

    Example Response:

    1. HTTP/1.1 200
    2. Content-Type: application/json
    3. {
    4. "id":1
    5. }

    Create a data source

    POST /api/datasources

    Example Graphite Request:

    1. POST /api/datasources HTTP/1.1
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
    5. {
    6. "name":"test_datasource",
    7. "type":"graphite",
    8. "url":"http://mydatasource.com",
    9. "access":"proxy",
    10. "basicAuth":false
    11. }

    Example CloudWatch Request:

    1. POST /api/datasources HTTP/1.1
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
    5. {
    6. "name": "test_datasource",
    7. "type": "cloudwatch",
    8. "url": "http://monitoring.us-west-1.amazonaws.com",
    9. "access": "proxy",
    10. "authType": "keys",
    11. "defaultRegion": "us-west-1"
    12. },
    13. "secureJsonData": {
    14. "secretKey": "dGVzdCBrZXkgYmxlYXNlIGRvbid0IHN0ZWFs"
    15. }
    16. }

    Example Response:

    Update an existing data source

    PUT /api/datasources/:datasourceId

    Example Request:

    1. PUT /api/datasources/1 HTTP/1.1
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
    5. {
    6. "id":1,
    7. "orgId":1,
    8. "name":"test_datasource",
    9. "type":"graphite",
    10. "access":"proxy",
    11. "url":"http://mydatasource.com",
    12. "password":"",
    13. "user":"",
    14. "database":"",
    15. "basicAuth":true,
    16. "basicAuthUser":"basicuser",
    17. "basicAuthPassword":"basicuser",
    18. "isDefault":false,
    19. "jsonData":null
    20. }
    1. HTTP/1.1 200
    2. Content-Type: application/json
    3. {"message":"Datasource updated", "id": 1, "name": "test_datasource"}

    DELETE /api/datasources/:datasourceId

    Example Request:

    1. DELETE /api/datasources/1 HTTP/1.1
    2. Accept: application/json
    3. Content-Type: application/json
    4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

    Example Response:

    1. HTTP/1.1 200
    2. Content-Type: application/json
    3. {"message":"Data source deleted"}

    Delete an existing data source by name

    DELETE /api/datasources/name/:datasourceName

    Example Request:

    Example Response:

    1. HTTP/1.1 200
    2. Content-Type: application/json

    Data source proxy calls

    GET /api/datasources/proxy/:datasourceId/*

    Proxies all calls to the actual datasource.