Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/issue209/prometheus consolidation #210

Merged
merged 11 commits into from
Nov 22, 2023
55 changes: 10 additions & 45 deletions powerapi/cli/common_cli_parsing_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,69 +250,34 @@
subgroup_parser=subparser_mongo_output
)

subparser_prom_output = SubgroupConfigParsingManager("prom")
subparser_prom_output.add_argument("t", "tags", help_text="specify report tags")
subparser_prom_output.add_argument("u", "uri", help_text="specify server uri")
subparser_prom_output.add_argument(
subparser_prometheus_output = SubgroupConfigParsingManager("prometheus")
subparser_prometheus_output.add_argument("t", "tags", help_text="specify report tags")
subparser_prometheus_output.add_argument("u", "uri", help_text="specify server uri")
subparser_prometheus_output.add_argument(

Check warning on line 256 in powerapi/cli/common_cli_parsing_manager.py

View check run for this annotation

Codecov / codecov/patch

powerapi/cli/common_cli_parsing_manager.py#L253-L256

Added lines #L253 - L256 were not covered by tests
"p", "port", help_text="specify server port", argument_type=int
)
subparser_prom_output.add_argument(
subparser_prometheus_output.add_argument(

Check warning on line 259 in powerapi/cli/common_cli_parsing_manager.py

View check run for this annotation

Codecov / codecov/patch

powerapi/cli/common_cli_parsing_manager.py#L259

Added line #L259 was not covered by tests
"M", "metric_name", help_text="specify metric name"
)
subparser_prom_output.add_argument(
subparser_prometheus_output.add_argument(

Check warning on line 262 in powerapi/cli/common_cli_parsing_manager.py

View check run for this annotation

Codecov / codecov/patch

powerapi/cli/common_cli_parsing_manager.py#L262

Added line #L262 was not covered by tests
"d",
"metric_description",
help_text="specify metric description",
default_value="energy consumption",
)
help_text = "specify number of second for the value must be aggregated before compute statistics on them"
subparser_prom_output.add_argument(
"A", "aggregation_period", help_text=help_text, default_value=15, argument_type=int
)

subparser_prom_output.add_argument(
"m",
"model",
help_text="specify data type that will be stored in the database",
default_value="PowerReport",
)
subparser_prom_output.add_argument(
"n", "name", help_text="specify pusher name", default_value="pusher_prom"
)
self.add_subgroup_parser(
subgroup_name="output",
subgroup_parser=subparser_prom_output
)

subparser_direct_prom_output = SubgroupConfigParsingManager("direct_prom")
subparser_direct_prom_output.add_argument(
"t", "tags", help_text="specify report tags"
)
subparser_direct_prom_output.add_argument("a", "uri", help_text="specify server uri")
subparser_direct_prom_output.add_argument(
"p", "port", help_text="specify server port", argument_type=int
)
subparser_direct_prom_output.add_argument(
"M", "metric_name", help_text="specify metric name"
)
subparser_direct_prom_output.add_argument(
"d",
"metric_description",
help_text="specify metric description",
default_value="energy consumption",
)
subparser_direct_prom_output.add_argument(
subparser_prometheus_output.add_argument(

Check warning on line 269 in powerapi/cli/common_cli_parsing_manager.py

View check run for this annotation

Codecov / codecov/patch

powerapi/cli/common_cli_parsing_manager.py#L269

Added line #L269 was not covered by tests
"m",
"model",
help_text="specify data type that will be stored in the database",
default_value="PowerReport",
)
subparser_direct_prom_output.add_argument(
"n", "name", help_text="specify pusher name", default_value="pusher_prom"
subparser_prometheus_output.add_argument(

Check warning on line 275 in powerapi/cli/common_cli_parsing_manager.py

View check run for this annotation

Codecov / codecov/patch

powerapi/cli/common_cli_parsing_manager.py#L275

Added line #L275 was not covered by tests
"n", "name", help_text="specify pusher name", default_value="pusher_prometheus"
)
self.add_subgroup_parser(
subgroup_name="output",
subgroup_parser=subparser_direct_prom_output
subgroup_parser=subparser_prometheus_output
)

subparser_csv_output = SubgroupConfigParsingManager("csv")
Expand Down
22 changes: 10 additions & 12 deletions powerapi/cli/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

from powerapi.actor import Actor
from powerapi.database.influxdb2 import InfluxDB2
from powerapi.database.prometheus_db import DEFAULT_ADDRESS
from powerapi.exception import PowerAPIException, ModelNameAlreadyUsed, DatabaseNameDoesNotExist, ModelNameDoesNotExist, \
DatabaseNameAlreadyUsed, ProcessorTypeDoesNotExist, ProcessorTypeAlreadyUsed, MonitorTypeDoesNotExist
from powerapi.filter import Filter
Expand All @@ -42,7 +43,7 @@
TIMEOUT_QUERY_DEFAULT_VALUE
from powerapi.processor.pre.libvirt.libvirt_pre_processor_actor import LibvirtPreProcessorActor
from powerapi.report import HWPCReport, PowerReport, ControlReport, ProcfsReport, Report, FormulaReport
from powerapi.database import MongoDB, CsvDB, InfluxDB, OpenTSDB, SocketDB, PrometheusDB, DirectPrometheusDB, \
from powerapi.database import MongoDB, CsvDB, InfluxDB, OpenTSDB, SocketDB, PrometheusDB, \
VirtioFSDB, FileDB
from powerapi.puller import PullerActor
from powerapi.pusher import PusherActor
Expand Down Expand Up @@ -181,7 +182,7 @@ def __init__(self, component_group_name: str):
self.db_factory = {
'mongodb': lambda db_config: MongoDB(report_type=db_config['model'], uri=db_config['uri'],
db_name=db_config['db'], collection_name=db_config['collection']),
'socket': lambda db_config: SocketDB(db_config['model'], db_config['port']),
'socket': lambda db_config: SocketDB(report_type=db_config['model'], port=db_config['port']),
'csv': lambda db_config: CsvDB(report_type=db_config['model'], tags=gen_tag_list(db_config),
current_path=os.getcwd() if 'directory' not in db_config else db_config[
'directory'],
Expand All @@ -196,16 +197,13 @@ def __init__(self, component_group_name: str):
port=None if 'port' not in db_config else db_config['port']),
'opentsdb': lambda db_config: OpenTSDB(report_type=db_config['model'], host=db_config['uri'],
port=db_config['port'], metric_name=db_config['metric_name']),
'prom': lambda db_config: PrometheusDB(report_type=db_config['model'], port=db_config['port'],
address=db_config['uri'], metric_name=db_config['metric_name'],
metric_description=db_config['metric_description'],
aggregation_periode=db_config['aggregation_period'],
tags=gen_tag_list(db_config)),
'direct_prom': lambda db_config: DirectPrometheusDB(report_type=db_config['model'], port=db_config['port'],
address=db_config['uri'],
metric_name=db_config['metric_name'],
metric_description=db_config['metric_description'],
tags=gen_tag_list(db_config)),
'prometheus': lambda db_config: PrometheusDB(report_type=db_config['model'],
port=db_config['port'],
address=db_config['uri'] if 'uri' in db_config else
DEFAULT_ADDRESS,
metric_name=db_config['metric_name'],
metric_description=db_config['metric_description'],
tags=gen_tag_list(db_config)),
'virtiofs': lambda db_config: VirtioFSDB(report_type=db_config['model'],
vm_name_regexp=db_config['vm_name_regexp'],
root_directory_name=db_config['root_directory_name'],
Expand Down
1 change: 0 additions & 1 deletion powerapi/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
from powerapi.database.influxdb2 import InfluxDB2
from powerapi.database.prometheus_db import PrometheusDB
from powerapi.database.virtiofs_db import VirtioFSDB
from powerapi.database.direct_prometheus_db import DirectPrometheusDB
from powerapi.database.socket_db import SocketDB
from powerapi.database.file_db import FileDB
112 changes: 0 additions & 112 deletions powerapi/database/direct_prometheus_db.py

This file was deleted.

Loading