Git Product home page Git Product logo

zmon-cli's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zmon-cli's Issues

Exception when updating a grafana dashboard using Zmon Update

When using Zmon Update, I get an exception at the end of the update command, However the dashboard seems to be updated anyway.

$> zmon graf update <yaml file>                                                                                                  

Updating dashboard XXXXXX ...
 EXCEPTION OCCURRED: 'id'
Traceback (most recent call last):
  File "/usr/local/bin/zmon", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/zmon_cli/main.py", line 9, in main
    cli()
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 27, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/zmon_cli/cmds/grafana.py", line 47, in grafana_update
    ok(client.grafana_dashboard_url(dashboard))
  File "/usr/local/lib/python3.6/site-packages/zmon_cli/client.py", line 252, in grafana_dashboard_url
    return self.endpoint(GRAFANA_DASHBOARD_URL, dashboard['id'], base_url=self.base_url)
KeyError: 'id'

reported by @kabdelrahman on zalando/zmon#35

KeyError: 'dashboard' when running zmon search keyword

I am getting this error

$ zmon search keyword
 EXCEPTION OCCURRED: 'dashboard'
Traceback (most recent call last):
  File "/usr/local/bin/zmon", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/zmon_cli/main.py", line 9, in main
    cli()
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 27, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/zmon_cli/cmds/search.py", line 40, in search
    dashboard['link'] = client.grafana_dashboard_url(dashboard)
  File "/usr/local/lib/python3.6/site-packages/zmon_cli/client.py", line 252, in grafana_dashboard_url
    return self.endpoint(GRAFANA_DASHBOARD_URL, dashboard['dashboard']['id'], base_url=self.base_url)
KeyError: 'dashboard'

Handle invalid credentials issue

As a zmon-cli user
given I have wrong credentials in zmon config file
I want to get "invalid credentials" error message.

detailed info:

When ~/.zmon-cli.yaml has invalid credentials, zmon-cli does not report the problem with credentials correctly, but throws an exception not being helpful in finding the problem:

$ zmon entities
Traceback (most recent call last):
  File "/usr/local/bin/zmon", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.4/dist-packages/zmon_cli/main.py", line 610, in main
    cli()
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 700, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 680, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1027, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1007, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 873, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 508, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 16, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/zmon_cli/main.py", line 371, in entities
    render_entities(output)
  File "/usr/local/lib/python3.4/dist-packages/zmon_cli/main.py", line 353, in render_entities
    s = sorted(e.keys())
AttributeError: 'str' object has no attribute 'keys'

Wrong Error message when deleting non-orphan check definition

When deleting a non-orphan check definition, I am getting the following error:

zmon check-definitions delete 12345 
Deleting check 12345 ... EXCEPTION OCCURRED: 404 Client Error: Not Found for url: https://zmon.example.net/api/v1/check-definitions/12345/
HTTP error: 404 - Not Found
"Id not found or not part of owning team"

Create multiple entities formatting

Creating new entities do not always go on a new line in case of mixed success and failures

Creating new entities ...
Creating entity zmon-dummy-1 ...Creating entity zmon-dummy-2 ... ZMON client error: Entity "id" and "type" are required.

ZMON CLI users on windows should be able to use the default temp directory

Currently on windows, if a user attempts to use the ZMON CLI, they'll get the following error:

Traceback (most recent call last):
  File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\Scripts\zmon.exe\__main__.py", line 9, in <module>
  File "c:\program files\python36\lib\site-packages\zmon_cli\main.py", line 9, in main
    cli()
  File "c:\program files\python36\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\program files\python36\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\program files\python36\lib\site-packages\click\core.py", line 1134, in invoke
    Command.invoke(self, ctx)
  File "c:\program files\python36\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\program files\python36\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python36\lib\site-packages\click\decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\program files\python36\lib\site-packages\zmon_cli\cmds\command.py", line 63, in cli
    configure_logging(logging.DEBUG if verbose else logging.INFO)
  File "c:\program files\python36\lib\site-packages\zmon_cli\config.py", line 19, in configure_logging
    format='%(asctime)s %(levelname)s %(name)s: %(message)s')
  File "c:\program files\python36\lib\logging\__init__.py", line 1781, in basicConfig
    h = FileHandler(filename, mode)
  File "c:\program files\python36\lib\logging\__init__.py", line 1030, in __init__
    StreamHandler.__init__(self, self._open())
  File "c:\program files\python36\lib\logging\__init__.py", line 1059, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\tmp\\zmon-cli.log'

This might be because the default temp directory on windows is c:\temp and not c:\tmp. Once I made a c:\tmp directory, the issue was solved.

Pre Requisites

  • Windows machine
  • Set up for running python commands

Steps to Reproduce

  1. run pip install zmon-cli in your terminal
  2. run the zmon command, confirm that you get a list of options and that it was installed correctly.
  3. run zmon e (or any other command other than just zmon)

Observed Result
The above stack trace.

Expected Result
The command works normally and is able to create a log file.

--output json not applied as shown in help

A zmon entities --output json filter key value renders as text, while zmon entities filter --output json key value correctly returns json.
According to the help, it should work in both positions:

$ zmon entities filter --help
Usage: zmon entities filter [OPTIONS] KEY VALUE

  List entities filtered by a certain key

Options:
  -o, --output [text|json|yaml]  Use alternative output format
  --pretty                       Pretty print JSON output. Ignored if output
                                 format is not JSON
  -h, --help                     Show this message and exit.
$ zmon entities --help
Usage: zmon entities [OPTIONS] COMMAND [ARGS]...

  Manage entities

Options:
  -o, --output [text|json|yaml]  Use alternative output format
  --pretty                       Pretty print JSON output. Ignored if output
                                 format is not JSON
  -h, --help                     Show this message and exit.

Commands:
  delete  Delete a single entity by ID
  filter  List entities filtered by a certain key
  get     Get a single entity by ID
  push    Push one or more entities

Failed to intitialize ZMON client

I have installed zmon cli and configured zmon contoller and can access it via gui by port forwarding it to my local machine but cant connect via zmon cli, i have configured zmon ui on GKE.
I'm accessing zmon ui as https://localhost:8444
Please help me out, how can I configure using CLI ?


Traceback (most recent call last):
File "/home/shudhanshu/.local/bin/zmon", line 10, in
sys.exit(main())
File "/home/shudhanshu/.local/lib/python3.7/site-packages/zmon_cli/main.py", line 9, in main
cli()
File "/home/shudhanshu/.local/lib/python3.7/site-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/home/shudhanshu/.local/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/shudhanshu/.local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/shudhanshu/.local/lib/python3.7/site-packages/click/core.py", line 1114, in invoke
return Command.invoke(self, ctx)
File "/home/shudhanshu/.local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/shudhanshu/.local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/shudhanshu/.local/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/shudhanshu/.local/lib/python3.7/site-packages/zmon_cli/cmds/entity.py", line 37, in entities
client = get_client(ctx.obj.config)
File "/home/shudhanshu/.local/lib/python3.7/site-packages/zmon_cli/cmds/command.py", line 49, in get_client
raise RuntimeError('Failed to intitialize ZMON client. Invalid configuration!')
RuntimeError: Failed to intitialize ZMON client. Invalid configuration!

Allow .yml file extension or provide a better error message when encountering it.

Using .yml instead of .yaml is currently not supported, but the error message is very cryptic about wrong extension name.

# zmon e push website.yml                                                                                                                                    
Traceback (most recent call last):
  File "/usr/bin/zmon", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/zmon_cli/main.py", line 9, in main
    cli()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/decorators.py", line 27, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/zmon_cli/cmds/entity.py", line 74, in push_entity
    data = json.loads(entity)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Add "keyrings.alt" dependency to make it work again regardless of platform

Sadly the maintainer of "keyring" is convinced that the encrypted file backend (which works regardless of platform!) should not be in the core "keyring" module anymore, see jaraco/keyring#196

So we need to add the "keyrings.alt" dependency in most of our CLI tools to ensure same user experience, otherwise users might get:

File "/foo/bar/lib/python3.5/site-packages/keyring/backends/fail.py", line 18, in get_password
    raise RuntimeError("No recommended backend was available")
RuntimeError: No recommended backend was available

Inconsistent behaviour for update_check_definition wtr to last_modified_by attribute

When updating check definition via the python client (but not via the command line cli), the 'last_modified_by' field is required.
The python docs only states that the owing team is required :

Proposed Solutions:

  • Update the docs to make it required by the python client
  • Attempt to read the user name if not provided (Similar to cmd line client)

I believe that the second option is better as more consistent with the cmd line client.

Test-run checks from CLI

Developing/debugging python snippets from UI is often frustrating for non-trivial cases. Having check test run function in CLI would allow more streamlined edit/run/inspect workflow which would allow using local Python's development tools and VCS to store snippets.

Implement simple alert dashboard

The ZMON CLI could benefit from providing a console-based alert dashboard.

For example:

$ zmon dashboards view [DASHBOARD-NAME] [-W|--watch]

Add documentation

Thanks for this tool!

However the README is a bit tiny, can you add more documentation or the link to it?

Potential solution field is missing in check definition

While getting a check definition, the field of 'potential_solution' is not returned.

For example:

> zmon check-definitions get 3305 | grep potential_solution | wc -l
0

I found this issue by automatically updating checks (changing ownership), so potential_solution field was erased.

Simplify "-definitions" parameters

It's possible to replace check-definitions and alerts-definitions command line switches with 'checks' and 'alerts'. There are no other switches that might cause ambiguities and without autocompletion typing '-definitions' is tedious.

Implement system diagnostics (Redis read/write) again

The zmon status command now uses the REST API (which is good), but we also need another special command or separate script to do low-level system diagnostics:

  • directly connect to Redis instances
  • check Redis replication
  • check Redis write access
  • check worker and scheduler health

Creating grafana dashboard fails

Bug in grafana_dashboard_url

    return self.endpoint(GRAFANA_DASHBOARD_URL, dashboard['id'], base_url=self.base_url)
KeyError: 'id'

Support filtering by tag

When filtering alerts or checks via zmon alert-definitions filter some-field some-value only equality checks are performed. This makes it impossible to filter by tag as tags are a list. I guess usability-wise the least intrusive way of incorporating this feature would be to just change the logic for the tags to check if any tag matches the tag from the command line.


Initially I wanted to propose lots of other filter mechanisms but then I found out that the zmon Rest API only supports fetching all resources and filtering is done on the client-side anyway so piping the output of zmon *-definitions list --output json to jq is no worse performance-wise. Still, being able to have multiple filter, filtering case-insensitively and having things like "contains" for searching alert descriptions directly from the zmon CLI could be interesting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.