zalando-zmon / zmon-cli Goto Github PK
View Code? Open in Web Editor NEWZMON Command Line Interface
Home Page: http://zmon.readthedocs.org/en/latest/developer/zmon-cli.html
License: Other
ZMON Command Line Interface
Home Page: http://zmon.readthedocs.org/en/latest/developer/zmon-cli.html
License: Other
Failing to accomplish any command should provide more informative messages that could point the user to possible solutions and easier investigations. (e.g zalando-zmon/zmon-controller#230)
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
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'
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'
ZMON CLI needs to support OAuth 2 authentication with Bearer tokens.
zmon entities filter type instance application_id my-app
zmon entities
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"
For now allow skipping parsing the check command (until worker is running python3)
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.
timeout should be specified per request call rather than on the session
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
Steps to Reproduce
Observed Result
The above stack trace.
Expected Result
The command works normally and is able to create a log file.
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
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!
zmon alert filter check_definition_id 2026
Field types mismatch (2026
vs "2026"
)
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)
As search
is part now of ZMON API, we need to implement search command for CLI.
At the moment, there is a cap of 25 entries per group. It would be great to have an option to raise that limit and be able to fetch all results matching a given query, similarly to the web interface.
TypeError: datetime.datetime(2016, 8, 10, 15, 0, tzinfo=tzlocal()) is not JSON serializable
The ZMON CLI should also provide list/search access for alert and check definitions. Currently we can only create/update/delete single alert/check definitions.
Updating Grafana dashboard from JSON file fails but YAML works.
Exception:
...
740, in update_grafana_dashboard
if 'id' not in grafana_dashboard['dashboard']:
KeyError: 'dashboard'
Since ZMON client is often used in services as well, we can benefit from adding tracing support.
API supports creating downtimes for entities only belonging to specific alert definitions.
http://zmon.readthedocs.io/en/latest/developer/rest-api.html#scheduling-a-downtime
Searching for everything of a team does not work (easily) currently. A query like
zmon search -t TeamName
should be valid.
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
Useful for auto-doc generation.
Kind of a bug in API, but CLI could implement a workaround for now!
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:
I believe that the second option is better as more consistent with the cmd line client.
Client should use JsonDate encoder.
Coveralls settings is not properly configured for zalando-zmon/zmon-cli
Not found: https://coveralls.io/github/zalando-zmon/zmon-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.
The ZMON CLI could benefit from providing a console-based alert dashboard.
For example:
$ zmon dashboards view [DASHBOARD-NAME] [-W|--watch]
Special handling of HTTPError
with proper logging is definitely helpful.
Thanks for this tool!
However the README is a bit tiny, can you add more documentation or the link to it?
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.
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.
We need a consistent naming (with aliases, backward compatibility)
add
vs create
vs push
etc ...
zmon-cli/zmon_cli/cmds/downtime.py
Line 30 in 375550a
By default, zmon down create -o yaml "entitidy-id" creates a downtime for 60!! minutes and it is not possible to delete a downtime.
In compare_entities
method
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:
Bug in grafana_dashboard_url
return self.endpoint(GRAFANA_DASHBOARD_URL, dashboard['id'], base_url=self.base_url)
KeyError: 'id'
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.