-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathe2k.py
executable file
·75 lines (56 loc) · 2.36 KB
/
e2k.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2019 Bitergia
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Authors:
# Alvaro del Castillo San Felix <[email protected]>
#
import argparse
import logging
from os import sys
from grimoire_elk.raw.elastic import ElasticOcean
from grimoire_elk.panels import create_dashboard
from grimoire_elk.utils import config_logging
def get_params_parser_create_dash():
"""Parse command line arguments"""
parser = argparse.ArgumentParser(usage="usage: e2k.py [options]",
description="Create a Kibana dashboard from a template")
ElasticOcean.add_params(parser)
parser.add_argument("-d", "--dashboard", help="dashboard to be used as template")
parser.add_argument("-i", "--index", help="enriched index to be used as data source")
parser.add_argument("--kibana", dest="kibana_index", default=".kibana",
help="Kibana index name (.kibana default)")
parser.add_argument('-g', '--debug', dest='debug', action='store_true')
return parser
def get_params():
parser = get_params_parser_create_dash()
args = parser.parse_args()
return args
if __name__ == '__main__':
"""Enriched to Kibana Publisher"""
args = get_params()
config_logging(args.debug)
# TODO: Use param to build a real URL if possible
kibana_host = "http://localhost:5601"
try:
url = create_dashboard(args.elastic_url, args.dashboard, args.index,
kibana_host, args.kibana_index)
except KeyboardInterrupt:
logging.info("\n\nReceived Ctrl-C or other break signal. Exiting.\n")
sys.exit(0)
logging.info("Kibana dashboard generated %s", url)