-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cratedb-wtf: Add
cratedb-wtf
diagnostics program
- Loading branch information
Showing
21 changed files
with
1,555 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ __pycache__ | |
dist | ||
.coverage* | ||
coverage.xml | ||
/foo | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import io | ||
import json | ||
from contextlib import redirect_stdout | ||
|
||
|
||
class PlatformInfo: | ||
@staticmethod | ||
def application(): | ||
import platform | ||
|
||
from cratedb_toolkit import __appname__, __version__ | ||
|
||
data = {} | ||
|
||
data["platform"] = platform.platform() | ||
data["version"] = __version__ | ||
data["name"] = __appname__ | ||
return data | ||
|
||
@staticmethod | ||
def libraries(): | ||
data = {} | ||
|
||
# SQLAlchemy | ||
from importlib.metadata import entry_points | ||
|
||
try: | ||
import sqlalchemy.dialects.plugins | ||
import sqlalchemy.dialects.registry | ||
|
||
data["sqlalchemy"] = { | ||
"dialects_builtin": list(sqlalchemy.dialects.registry.impls.keys()), | ||
"dialects_3rdparty": [dialect.name for dialect in entry_points(group="sqlalchemy.dialects")], # type: ignore[attr-defined,call-arg] | ||
"plugins": list(sqlalchemy.dialects.plugins.impls.keys()), | ||
} | ||
except Exception: # noqa: S110 | ||
pass | ||
|
||
# pandas | ||
try: | ||
import pandas | ||
|
||
buffer = io.StringIO() | ||
with redirect_stdout(buffer): | ||
pandas.show_versions(as_json=True) | ||
buffer.seek(0) | ||
data["pandas"] = json.load(buffer) | ||
except Exception: # noqa: S110 | ||
pass | ||
|
||
# fsspec | ||
import fsspec | ||
|
||
data["fsspec"] = {"protocols": fsspec.available_protocols(), "compressions": fsspec.available_compressions()} | ||
|
||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) 2021-2023, Crate.io Inc. | ||
# Distributed under the terms of the AGPLv3 license, see LICENSE. | ||
import logging | ||
import typing as t | ||
|
||
from cratedb_toolkit.util.common import setup_logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def start_service(app: str, listen_address: t.Union[str, None] = None, reload: bool = False): # pragma: no cover | ||
setup_logging() | ||
from uvicorn import run | ||
|
||
if listen_address is None: | ||
listen_address = "127.0.0.1:4242" | ||
|
||
host, port = listen_address.split(":") | ||
port_int = int(port) | ||
|
||
logger.info(f"Starting HTTP web service on http://{listen_address}") | ||
|
||
run(app=app, host=host, port=port_int, reload=reload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# cratedb-wtf | ||
|
||
A diagnostics utility in the spirit of [git-wtf], [grafana-wtf], and [pip.wtf]. | ||
It is still a work-in-progress, but it is usable already. | ||
|
||
|
||
## Synopsis | ||
|
||
Define CrateDB database cluster address. | ||
```shell | ||
export CRATEDB_SQLALCHEMY_URL=crate://localhost/ | ||
``` | ||
|
||
Display system and database cluster information. | ||
```shell | ||
cratedb-wtf info | ||
``` | ||
|
||
Display database cluster job information. | ||
```shell | ||
cratedb-wtf job-info | ||
``` | ||
|
||
Display database cluster log messages. | ||
```shell | ||
cratedb-wtf logs | ||
``` | ||
|
||
Statistics. | ||
```shell | ||
cratedb-wtf job-statistics collect | ||
cratedb-wtf job-statistics view | ||
``` | ||
|
||
|
||
## HTTP API | ||
|
||
Expose collected status information. | ||
```shell | ||
cratedb-wtf --debug serve --reload | ||
``` | ||
Consume collected status information via HTTP. | ||
```shell | ||
http http://127.0.0.1:4242/info/all | ||
``` | ||
|
||
|
||
|
||
[git-wtf]: http://thrawn01.org/posts/2014/03/03/git-wtf/ | ||
[grafana-wtf]: https://github.com/panodata/grafana-wtf | ||
[pip.wtf]: https://github.com/sabslikesobs/pip.wtf |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# cratedb-wtf backlog | ||
|
||
## Iteration +1 | ||
- Expose collected data via Glances-like UI | ||
- Experimental UI using Grafana Scenes | ||
|
||
## Iteration +2 | ||
- Make `cratedb-wtf logs` also optionally consider `sys.` tables. | ||
- cratedb-wtf explore table|shard|partition|node | ||
- High-level analysis, evaluating a set of threshold rules | ||
- Network diagnostics? | ||
|
||
## Iteration +3 | ||
- Make it work with CrateDB Cloud. | ||
``` | ||
ctk cluster info | ||
ctk cluster health | ||
ctk cluster logs --slow-queries | ||
``` | ||
|
||
## Done | ||
- Make it work | ||
- Proper marshalling of timestamp values (ISO 8601) | ||
- Expose collected data via HTTP API | ||
``` | ||
cratedb-wtf serve | ||
``` | ||
- Provide `scrub` option also via HTTP | ||
- Complete collected queries and code snippets | ||
- Harvest queries from Admin UI, crash, crate-admin-alt | ||
- Harvest queries from experts | ||
- https://tools.cr8.net/grafana/d/RkpNJx84z/cratedb-jobs-log?orgId=1&refresh=5m&var-datasource=crate-production | ||
- https://tools.cr8.net/grafana/d/RkpNJx84z/cratedb-jobs-log?orgId=1&refresh=5m&var-datasource=crate-production&viewPanel=44 | ||
- Add `description` and `unit` fields to each `InfoElement` definition |
Oops, something went wrong.