Data source API

Get all datasources

GET /api/datasources

Example Request:

  1. GET /api/datasources 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. {
  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. "password":"",
  11. "user":"",
  12. "database":"",
  13. "basicAuth":false,
  14. "basicAuthUser":"",
  15. "basicAuthPassword":"",
  16. "isDefault":false,
  17. "jsonData":null
  18. }

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:

  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. "password":"",
  11. "user":"",
  12. "database":"",
  13. "basicAuth":false,
  14. "basicAuthUser":"",
  15. "basicAuthPassword":"",
  16. "isDefault":false,
  17. "jsonData":null
  18. }

Get data source Id by Name

GET /api/datasources/id/:name

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. "jsonData": {
  11. "authType": "keys",
  12. "defaultRegion": "us-west-1"
  13. },
  14. "secureJsonData": {
  15. "accessKey": "Ol4pIDpeKSA6XikgOl4p",
  16. "secretKey": "dGVzdCBrZXkgYmxlYXNlIGRvbid0IHN0ZWFs"
  17. }
  18. }

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"id":1,"message":"Datasource added", "name": "test_datasource"}

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. }

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {"message":"Datasource updated", "id": 1, "name": "test_datasource"}

Delete an existing data source by id

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:

  1. DELETE /api/datasources/name/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. {"message":"Data source deleted"}

Data source proxy calls

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

Proxies all calls to the actual datasource.