forked from logzio/dashboard-metrics-extractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings_reader.py
28 lines (22 loc) · 1.01 KB
/
settings_reader.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
import logging
import os
import yaml
logger = logging.getLogger()
def read_menu_input()->int:
menu_choice = input(
"Please enter 1 for extracting data from grafana and prometheus endpoints, or 2 for extracting metrics from "
"logz.io: ")
return int(menu_choice)
def get_config()->dict:
config_path = input('Please enter config file path, or enter to insert input manually: ')
if config_path is not None:
try:
with open(f'{config_path}', 'r') as config:
config = yaml.safe_load(config)
return config
except FileNotFoundError:
grafana_endpoint = input('No config file found, please enter grafana endpoint: ')
grafana_api_token = input('Please enter grafana api token: ')
prometheus_api_token = input('Please enter prometheus endpoint: ')
return {'grafana': {'endpoint': grafana_endpoint, 'token': grafana_api_token},
'prometheus': {'endpoint': prometheus_api_token}}