Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grafana_api/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
from .annotations import Annotations
from .snapshots import Snapshots
from .notifications import Notifications

from .health import Health
30 changes: 30 additions & 0 deletions grafana_api/api/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,33 @@ def delete_datasource_by_name(self, datasource_name):
delete_datasource = "/datasources/name/%s" % datasource_name
r = self.api.DELETE(delete_datasource)
return r

def get_datasource_proxy_data(self, datasource_id
, query_type='query'
, version='v1'
, expr=None
, time=None
, start=None
, end=None
, step=None
):
"""

:param datasource_id:
:param version: api_version currently v1
:param query_type: query_range |query
:param expr: expr to query

:return:
"""
get_datasource_path = "/datasources/proxy/{}" \
'/api/{}/{}?query={}'.format( datasource_id, version, query_type, expr)
if query_type == 'query_range':
get_datasource_path = get_datasource_path + '&start={}&end={}&step={}'.format(
start, end, step)
else:
get_datasource_path = get_datasource_path + '&time={}'.format(time)
r = self.api.GET(get_datasource_path)
return r


18 changes: 18 additions & 0 deletions grafana_api/api/health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from .base import Base


class Health(Base):
def __init__(self, api):
super(Health, self).__init__(api)
self.api = api

def check(self):
"""

:return:
"""
path = "/health"
r = self.api.GET(path)
return r


4 changes: 3 additions & 1 deletion grafana_api/grafana_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
Teams,
Snapshots,
Annotations,
Notifications
Notifications,
Health
)


Expand Down Expand Up @@ -49,3 +50,4 @@ def __init__(
self.annotations = Annotations(self.api)
self.snapshots = Snapshots(self.api)
self.notifications = Notifications(self.api)
self.health = Health(self.api)