Skip to content

Implement filter metrics list command#2

Merged
vishrutshah merged 2 commits intomonitor-clifrom
implement-filter-metrics
Feb 28, 2017
Merged

Implement filter metrics list command#2
vishrutshah merged 2 commits intomonitor-clifrom
implement-filter-metrics

Conversation

@vishrutshah
Copy link
Owner

Before:

(env) D:\Repos\azure-cli>az monitor metrics list -h

Command
    az monitor metrics list: **Lists the metric values for a resource**.
        <br>The **$filter** is used to reduce the set of metric data returned. Some common
        properties for this expression will be: name.value, aggregationType, startTime, endTime,
        timeGrain. The filter expression uses these properties with comparison operators (eg. eq,
        gt, lt) and multiple expressions can be combined with parentheses and 'and/or'
        operators.<br>Some example filter expressions are:<br>- $filter=(name.value eq
        'RunsSucceeded') and aggregationType eq 'Total' and startTime eq 2016-02-20 and endTime eq
        2016-02-21 and timeGrain eq duration'PT1M',<br>- $filter=(name.value eq 'RunsSucceeded') and
        (aggregationType eq 'Total' or aggregationType eq 'Average') and startTime eq 2016-02-20 and
        endTime eq 2016-02-21 and timeGrain eq duration'PT1H',<br>- $filter=(name.value eq
        'ActionsCompleted' or name.value eq 'RunsSucceeded') and (aggregationType eq 'Total' or
        aggregationType eq 'Average') and startTime eq 2016-02-20 and endTime eq 2016-02-21 and
        timeGrain eq duration'PT1M'.<br><br> >**NOTE**: When a metrics query comes in with multiple
        metrics, but with no aggregation types defined, the service will pick the Primary
        aggregation type of the first metrics to be used as the default aggregation type for all the
        metrics.

Arguments
    --resource-uri [Required]: The identifier of the resource.
    --filter                 : Reduces the set of data collected. The syntax allowed depends on the
                               operation. See the operation's description for details.

Global Arguments
    --debug                  : Increase logging verbosity to show all debug logs.
    --help -h                : Show this help message and exit.
    --output -o              : Output format.  Allowed values: json, jsonc, table, tsv.  Default:
                               json.
    --query                  : JMESPath query string. See http://jmespath.org/ for more information
                               and examples.
    --verbose                : Increase logging verbosity. Use --debug for full debug logs.

After:

(env) vishrut@visshamac azure-cli (implement-filter-metrics) $ az monitor metrics list -h

Command
    az monitor metrics list: Lists the metric values for a resource.

Arguments
    --resource-uri [Required]: The identifier of the resource.
    --time-grain   [Required]: The time grain. Granularity of the metric data returned in ISO 8601
                               duration format, eg "duration'PT1M'".
    --end-time               : The end time of the query. In ISO format with explicit indication of
                               timezone: 1970-01-01T00:00:00Z, 1970-01-01T00:00:00-0500.
    --metric-names           : The list of metric names.
    --start-time             : The start time of the query. In ISO format with explicit indication
                               of timezone: 1970-01-01T00:00:00Z, 1970-01-01T00:00:00-0500.

Global Arguments
    --debug                  : Increase logging verbosity to show all debug logs.
    --help -h                : Show this help message and exit.
    --output -o              : Output format.  Allowed values: json, jsonc, table, tsv.  Default:
                               json.
    --query                  : JMESPath query string. See http://jmespath.org/ for more information
                               and examples.
    --verbose                : Increase logging verbosity. Use --debug for full debug logs.

Example 1:

az monitor metrics list --resource-uri '/subscriptions/xxxxx-xxx-xxx-xxx-xxx/resourceGroups/vishrutrg/providers/Microsoft.Web/sites/vishrutwebapp' --metric-names AverageResponseTime AverageMemoryWorkingSet --time-grain PT1M

Example 2:

az monitor metrics list --resource-uri '/subscriptions/xxxxx-xxx-xxx-xxx-xxx/resourceGroups/vishrutrg/providers/Microsoft.Web/sites/vishrutwebapp' --time-grain PT1M --metric-names AverageMemoryWorkingSet --start-time  2017-01-11T12:59:59Z --end-time 2017-01-30T12:59:59Z

XPlat CLI Reference: https://github.com/Azure/azure-xplat-cli/blob/dev/lib/commands/arm/insights/insights.metrics._js#L44

@troydai @tjprescott @derekbekoe Please review the PR when you get a chance. Thanks!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed. i missed it :)

Copy link

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly questions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way for us to simplify this? Why would I have to type "duration'PT1M'"?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we can converts HH:mm:ss into ISO 8601. Let me look and see whether we have done it somewhere or not or how can we do that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should clarify "The space separated list of metric names." Otherwise you will get people using comma separated values.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

filters.append('({})'.format(metrics_filter))

if time_grain:
filters.append("timeGrain eq duration'{}'".format(time_grain))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this would read "timeGrain eq duration'duration'PT1M''"?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps the help message is wrong. Help message should not be 'duration'PT1M'' only 'PT1M'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the None?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha..silly i can just avoid that.

@vishrutshah vishrutshah merged commit 60972c4 into monitor-cli Feb 28, 2017
@vishrutshah vishrutshah deleted the implement-filter-metrics branch February 28, 2017 01:20
vishrutshah pushed a commit that referenced this pull request May 10, 2017
* initial update

* update

* add the CLI for 2017-04-18 swagger file

* cognitive service cli - inital version'

* rollback debug code change

* style refactoring update

* update

* change the term text to yellow highlighted

* code comment fix - update #1

* fix code comments - update #2

* 1.fix flake 8 styling error
2. add the depedencies in setup,

* fix an change in our service legal terms.

* fix a help.py styling issue

* update the setup.py

* update description of setup.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments