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

az monitor diagnostic-settings create will not accept same json as returned by show for 'logs' #2913

Closed
nneul opened this issue Apr 19, 2017 · 7 comments
Assignees
Labels
Monitor az monitor

Comments

@nneul
Copy link
Contributor

nneul commented Apr 19, 2017

Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: script

CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here: 2.0.3

OS Version: What OS and version are you using?
Answer here: Ubuntu 16.04 x64

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here: bash


Description

The input to logs option for monitor create won't accept the logs array as returned by 'az monitor diagnostics-settings show' - you have to strip out the 'retentionPolicy' elements. This seems incorrect.

Example in my case:

  "logs": [
    {
      "category": "ApplicationGatewayAccessLog",
      "enabled": false,
      "retentionPolicy": {
        "days": 0,
        "enabled": false
      }
    },
    {
      "category": "ApplicationGatewayPerformanceLog",
      "enabled": false,
      "retentionPolicy": {
        "days": 0,
        "enabled": false
      }
    },
    {
      "category": "ApplicationGatewayFirewallLog",
      "enabled": true,
      "retentionPolicy": {
        "days": 0,
        "enabled": false
      }
    }
  ],

It fails with:

u'retentionPolicy'
Traceback (most recent call last):
  File "/users/nneul/lib/azure-cli/local/lib/python2.7/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/users/nneul/lib/azure-cli/local/lib/python2.7/site-packages/azure/cli/core/application.py", line 201, in execute
    result = expanded_arg.func(params)
  File "/users/nneul/lib/azure-cli/local/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 403, in _execute_command
    raise ex
KeyError: u'retentionPolicy'
@tjprescott tjprescott added the Monitor az monitor label Apr 19, 2017
@tjprescott
Copy link
Member

@vishrutshah it looks like the UX here could use improvement.

  1. Command insists on 'resource-id' when it should support names or IDs.
  2. It really doesn't seem like "create" is the right verb here. If anything it seems more like a "configure" command.
  3. The JSON dump doesn't seem necessary at all. It seems I should be able to simply specify the name, whether it is enabled or not, and a retention period (optional).

@nneul
Copy link
Contributor Author

nneul commented Apr 19, 2017

No disagreement with @tjprescott comments, my issue was more: If it's going to take json for the settings, it should at least accept the same json as input that is output by the same command.

@tjprescott
Copy link
Member

@nneul agreed.

@vishrutshah
Copy link
Contributor

@nneul Thanks for reporting this issue. Yes we agree that it should take the logs.

I see that you mentioned that you have to stip out retentionPolicy. Could you please try keeping them but renaming it retention_policy. I believe that is the case for the issue. Let me know if that works or not.

Meanwhile, I am working on fixing the issues to take the same json as input. 👍 Thanks again for reporting the issue.

@nneul
Copy link
Contributor Author

nneul commented Apr 25, 2017

Yes, using retention_policy proceeds without error.

@vishrutshah
Copy link
Contributor

@nneul Closing the bug as PR is merged in. Could please use the nightly tomorrow and let us know whether things are good on you end or not. Appreciate your help.

@nneul
Copy link
Contributor Author

nneul commented Apr 27, 2017

Confirmed that this is now working. Thank you!

@vishrutshah vishrutshah added this to the Build Milestone milestone Apr 28, 2017
@haroldrandom haroldrandom added the Monitor az monitor label Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monitor az monitor
Projects
None yet
Development

No branches or pull requests

4 participants