Skip to content

Commit

Permalink
Merge pull request #112 from rafaelweingartner/introduce-use_history-…
Browse files Browse the repository at this point in the history
…option

Introduce use history option
  • Loading branch information
tobias-urdin authored Sep 30, 2022
2 parents ae6f8a5 + 884d0f2 commit e52b2b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion gnocchiclient/v1/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
class AggregatesManager(base.Manager):
def fetch(self, operations, search=None,
resource_type='generic', start=None, stop=None, granularity=None,
needed_overlap=None, groupby=None, fill=None, details=False):
needed_overlap=None, groupby=None, fill=None, details=False,
use_history=False):
"""Get measurements of an aggregated metrics.
:param operations: operations
Expand All @@ -44,6 +45,10 @@ def fetch(self, operations, search=None,
:param details: also returns the list of metrics or resources
associated to the operations
:type details: boolean
:param use_history: indicates if Gnocchi server must include in the
response the tag history for resources. The
default value is `False`.
:type use_history: boolean
See Gnocchi REST API documentation for the format
of *query dictionary*
Expand All @@ -66,6 +71,8 @@ def fetch(self, operations, search=None,
data["resource_type"] = resource_type
params["groupby"] = groupby

params['use_history'] = use_history

aggregates = self._post("v1/aggregates?%s" % (
utils.dict_to_querystring(params)),
headers={'Content-Type': "application/json"},
Expand Down
12 changes: 11 additions & 1 deletion gnocchiclient/v1/aggregates_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ def get_parser(self, prog_name):
parser.add_argument("--fill",
help=("Value to use when backfilling timestamps "
"with missing values in a subset of series. "
"Value should be a float or 'null'."))
"Value should be a float or 'null'.")),
parser.add_argument("--use-history", default=False,
help=("Indicates if Gnocchi server should respond "
"with the resource tags history for the "
"aggregation query. If set to `False`, only "
"the latest tag values will be returned. "
"Otherwise, the measures will be split "
"proportionally if a tag has been changed "
"in the `granularity` requested.")
)
return parser

def take_action(self, parsed_args):
Expand All @@ -56,6 +65,7 @@ def take_action(self, parsed_args):
needed_overlap=parsed_args.needed_overlap,
groupby=parsed_args.groupby,
fill=parsed_args.fill,
use_history=parsed_args.use_history
)

if parsed_args.search and parsed_args.groupby:
Expand Down

0 comments on commit e52b2b8

Please sign in to comment.