def __init__(self, **kwargs): super(GrafanaExporter, self).__init__() self._host = os.getenv('GRAFANA_HOST', kwargs.get('host')) password = os.getenv('GRAFANA_PASSWORD', kwargs.get('password')) username = os.getenv('GRAFANA_USERNAME', kwargs.get('username')) self._connection = Connection(username, password, self._host)
def test_elastic_search(): connection = Connection('username', 'password', 'https://host') connection._opener = MagicMock() # noinspection PyProtectedMember connection._opener.open().read.return_value = '{"hello":"world"}' assert connection.make_request('/uri', {'it\'s': 'alive'}) == { 'hello': 'world' } request = urllib2.Request('https://host/uri', '{"it\'s": "alive"}', headers={ 'Content-type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=' }) capture = Capture() # noinspection PyProtectedMember connection._opener.open.assert_called_with(capture) assert request.get_full_url() == capture.value.get_full_url() assert request.header_items() == capture.value.header_items() assert request.get_method() == capture.value.get_method() assert request.get_data() == capture.value.get_data()
def __init__(self, **kwargs): super(ElasticSearchExporter, self).__init__() self._host = os.getenv('ES_HOST', kwargs.get('host')) password = os.getenv('ES_PASSWORD', kwargs.get('password')) username = os.getenv('ES_USERNAME', kwargs.get('username')) self._connection = Connection(username, password, self._host)
def __init__(self, **kwargs): super(ElasticSearchExporter, self).__init__() self._host = os.getenv('ES_HOST', kwargs.get('host')) password = os.getenv('ES_PASSWORD', kwargs.get('password')) username = os.getenv('ES_USERNAME', kwargs.get('username')) use_kerberos = os.getenv('ES_USE_KERBEROS', kwargs.get('use_kerberos')) if use_kerberos: self._connection = KerberosConnection(self._host) else: self._connection = Connection(username, password, self._host)
class GrafanaExporter(DashboardExporter): def __init__(self, **kwargs): super(GrafanaExporter, self).__init__() self._host = os.getenv('GRAFANA_HOST', kwargs.get('host')) password = os.getenv('GRAFANA_PASSWORD', kwargs.get('password')) username = os.getenv('GRAFANA_USERNAME', kwargs.get('username')) self._connection = Connection(username, password, self._host) def process_dashboard(self, project_name, dashboard_name, dashboard_data): super(GrafanaExporter, self).process_dashboard(project_name, dashboard_name, dashboard_data) body = {'overwrite': True, 'dashboard': dashboard_data} logger.info("Uploading dashboard '%s' to %s", dashboard_name, self._host) self._connection.make_request('/api/dashboards/db', body)
class ElasticSearchExporter(DashboardExporter): def __init__(self, **kwargs): super(ElasticSearchExporter, self).__init__() self._host = os.getenv('ES_HOST', kwargs.get('host')) password = os.getenv('ES_PASSWORD', kwargs.get('password')) username = os.getenv('ES_USERNAME', kwargs.get('username')) self._connection = Connection(username, password, self._host) def process_dashboard(self, project_name, dashboard_name, dashboard_data): super(ElasticSearchExporter, self).process_dashboard(project_name, dashboard_name, dashboard_data) body = {'user': '******', 'group': 'guest', 'title': dashboard_data['title'], 'tags': dashboard_data['tags'], 'dashboard': json.dumps(dashboard_data)} logger.info("Uploading dashboard '%s' to %s", dashboard_name, self._host) self._connection.make_request('/es/grafana-dash/dashboard/{0}'.format(dashboard_name), body)
def test_elastic_search(): connection = Connection('username', 'password', 'https://host') connection._opener = MagicMock() # noinspection PyProtectedMember connection._opener.open().read.return_value = '{"hello":"world"}' assert connection.make_request('/uri', {'it\'s': 'alive'}) == {'hello': 'world'} request = urllib2.Request('https://host/uri', '{"it\'s":"alive"}', headers={ 'Content-type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=' }) # noinspection PyProtectedMember,PyUnresolvedReferences connection._opener.open.verify_called_once_with(request)
class ElasticSearchExporter(DashboardExporter): def __init__(self, **kwargs): super(ElasticSearchExporter, self).__init__() self._host = os.getenv('ES_HOST', kwargs.get('host')) password = os.getenv('ES_PASSWORD', kwargs.get('password')) username = os.getenv('ES_USERNAME', kwargs.get('username')) use_kerberos = os.getenv('ES_USE_KERBEROS', kwargs.get('use_kerberos')) if use_kerberos: self._connection = KerberosConnection(self._host) else: self._connection = Connection(username, password, self._host) def process_dashboard(self, project_name, dashboard_name, dashboard_data): super(ElasticSearchExporter, self).process_dashboard(project_name, dashboard_name, dashboard_data) body = {'user': '******', 'group': 'guest', 'title': dashboard_data['title'], 'tags': dashboard_data['tags'], 'dashboard': json.dumps(dashboard_data)} logger.info("Uploading dashboard '%s' to %s", dashboard_name, self._host) self._connection.make_request('/es/grafana-dash/dashboard/{0}'.format(dashboard_name), body)