Exemplo n.º 1
0
    def create_dashboard(self, panel_file, data_sources=None, strict=True):
        """Upload a panel to Elasticsearch if it does not exist yet.

        If a list of data sources is specified, upload only those
        elements (visualizations, searches) that match that data source.

        :param panel_file: file name of panel (dashobard) to upload
        :param data_sources: list of data sources
        :param strict: only upload a dashboard if it is newer than the one already existing
        """
        es_enrich = self.conf['es_enrichment']['url']

        if data_sources and ('pipermail' in data_sources or 'hyperkitty' in data_sources):
            # the dashboard for mbox and pipermail and hyperkitty are the same
            data_sources = list(data_sources)
            data_sources.append('mbox')
        if data_sources and 'stackexchange' in data_sources:
            # stackexchange is called stackoverflow in panels
            data_sources = list(data_sources)
            data_sources.append('stackoverflow')
        try:
            import_dashboard(es_enrich, panel_file, data_sources=data_sources, strict=strict)
        except ValueError:
            logger.error("%s does not include release field. Overwritten it always.", panel_file)
            import_dashboard(es_enrich, panel_file, data_sources=data_sources, strict=False)
        except RuntimeError:
            logger.error("Can not load the panel %s", panel_file)
Exemplo n.º 2
0
    def create_dashboard(self, panel_file, data_sources=None):
        """Upload a panel to Elasticsearch if it does not exist yet.

        If a list of data sources is specified, upload only those
        elements (visualizations, searches) that match that data source.

        :param panel_file: file name of panel (dashobard) to upload
        :param data_sources: list of data sources
        """
        es_enrich = self.conf['es_enrichment']['url']
        # If the panel (dashboard) already exists, don't load it
        dash_id = get_dashboard_name(panel_file)
        if exists_dashboard(es_enrich, dash_id):
            logger.info("Not creating a panel that exists already: %s",
                        dash_id)
        else:
            logger.info("Creating the panel: %s", dash_id)
            if data_sources and ('pipermail' in data_sources
                                 or 'hyperkitty' in data_sources):
                # the dashboard for mbox and pipermail and hyperkitty are the same
                data_sources = list(data_sources)
                data_sources.append('mbox')
            if data_sources and 'stackexchange' in data_sources:
                # stackexchange is called stackoverflow in panels
                data_sources = list(data_sources)
                data_sources.append('stackoverflow')
            import_dashboard(es_enrich, panel_file, data_sources=data_sources)
Exemplo n.º 3
0
def main():

    args = get_params()

    config_logging(args.debug)

    try:
        if args.import_file:
            import_dashboard(args.elastic_url, args.kibana_url,
                             args.import_file, args.kibana_index,
                             args.data_sources, args.add_vis_studies,
                             args.strict)
        elif args.export_file:
            if args.dashboard:
                export_dashboard(args.elastic_url, args.dashboard,
                                 args.export_file, args.kibana_index,
                                 args.split_index_patterns)
        elif args.list:
            list_dashboards(args.elastic_url, args.kibana_index)

    except HTTPError as http_error:
        res = http_error.response
        error_msg = u'%s. Content: %s' % (http_error, res.content)
        logging.error(error_msg)

    except ValueError as value_error:
        logging.error(value_error)

    except RuntimeError as runtime_error:
        logging.error(runtime_error)
Exemplo n.º 4
0
    def create_dashboard(self, panel_file, data_sources=None):
        """Upload a panel to Elasticsearch if it does not exist yet.

        If a list of data sources is specified, upload only those
        elements (visualizations, searches) that match that data source.

        :param panel_file: file name of panel (dashobard) to upload
        :param data_sources: list of data sources
        """
        es_enrich = self.conf['es_enrichment']['url']
        # If the panel (dashboard) already exists, don't load it
        dash_id = get_dashboard_name(panel_file)
        if exists_dashboard(es_enrich, dash_id):
            logger.info("Not creating a panel that exists already: %s", dash_id)
        else:
            logger.info("Creating the panel: %s", dash_id)
            if data_sources and ('pipermail' in data_sources or 'hyperkitty' in data_sources):
                # the dashboard for mbox and pipermail and hyperkitty are the same
                data_sources = list(data_sources)
                data_sources.append('mbox')
            if data_sources and 'stackexchange' in data_sources:
                # stackexchange is called stackoverflow in panels
                data_sources = list(data_sources)
                data_sources.append('stackoverflow')
            import_dashboard(es_enrich, panel_file, data_sources=data_sources)
def import_dash():
    '''
    imports all dashboards stored in the dashboards directory to the kibana index.
    '''
    for file in os.listdir('dashboards'):
        if file.endswith((".json")):
            print('Importing dashboard: ' + file)
            import_dashboard(os.environ['ELASTIC_URL'],
                             os.environ['KIBANA_URL'],
                             ('dashboards/%s' % file))
Exemplo n.º 6
0
    def create_dashboard(self, panel_file, data_sources=None, strict=True):
        """Upload a panel to Elasticsearch if it does not exist yet.

        If a list of data sources is specified, upload only those
        elements (visualizations, searches) that match that data source.

        :param panel_file: file name of panel (dashobard) to upload
        :param data_sources: list of data sources
        :param strict: only upload a dashboard if it is newer than the one already existing
        """
        es_enrich = self.conf['es_enrichment']['url']
        kibana_url = self.conf['panels']['kibiter_url']

        mboxes_sources = set(['pipermail', 'hyperkitty', 'groupsio', 'nntp'])
        if data_sources and any(x in data_sources for x in mboxes_sources):
            data_sources = list(data_sources)
            data_sources.append('mbox')
        if data_sources and ('supybot' in data_sources):
            data_sources = list(data_sources)
            data_sources.append('irc')
        if data_sources and 'google_hits' in data_sources:
            data_sources = list(data_sources)
            data_sources.append('googlehits')
        if data_sources and 'stackexchange' in data_sources:
            # stackexchange is called stackoverflow in panels
            data_sources = list(data_sources)
            data_sources.append('stackoverflow')
        if data_sources and 'phabricator' in data_sources:
            data_sources = list(data_sources)
            data_sources.append('maniphest')

        panels_path = get_sigils_path() + panel_file
        try:
            import_dashboard(es_enrich,
                             kibana_url,
                             panels_path,
                             data_sources=data_sources,
                             strict=strict)
        except ValueError:
            logger.error(
                "%s does not include release field. Not loading the panel.",
                panels_path)
        except RuntimeError:
            logger.error("Can not load the panel %s", panels_path)