vectordotdev / vector

A high-performance observability data pipeline.
https://vector.dev
Mozilla Public License 2.0
18.16k stars 1.6k forks source link

Add a mode for `vector graph` to output an ASCII graph #9851

Open jszwedko opened 3 years ago

jszwedko commented 3 years ago

Came up in the Dash workshop. A user was interested in getting an ASCII representation of the graph, as a quick reference, rather than needing to process the DOT output.

hhromic commented 3 years ago

Like this? :) https://dot-to-ascii.ggerganov.com/

Ref: https://github.com/ggerganov/dot-to-ascii

EDIT: It actually uses this under the hood: http://search.cpan.org/~tels/Graph-Easy/

jszwedko commented 3 years ago

Nice, that is very pretty!

hhromic commented 3 years ago

Given that Vector already can output the DOT representation to stdout, I think the best way to "implement" this feature is to simply pipe this output into GraphEasy like this:

vector graph -c my-pipeline.yaml | graph-easy

I.e. to follow the Unix philosophy.

There is a Docker image for GraphEasy that makes this possible already without modifying Vector at all.

For example, to plot the wrapped_json.toml example pipeline with simple ASCII characters:

$ vector graph -c wrapped_json.toml | docker run --rm -i tsub/graph-easy
+-------------------+
|       logs        |
+-------------------+
  |
  |
  v
+-------------------+
|  parse_root_json  |
+-------------------+
  |
  |
  v
+-------------------+
| parse_parent_json |
+-------------------+
  |
  |
  v
+-------------------+
| parse_child_json  |
+-------------------+
  |
  |
  v
+-------------------+
|        out        |
+-------------------+

Or the file_to_prometheus.toml example pipeline with fancier box art (looks better on the console):

$ vector graph -c file_to_prometheus.toml | docker run --rm -i tsub/graph-easy --as_boxart
                     ┌─────────────────┐
                     │      file       │
                     └─────────────────┘
                       │
                       │
                       ▼
┌──────────────┐     ┌─────────────────┐
│ console_logs │ ◀── │  regex_parser   │
└──────────────┘     └─────────────────┘
                       │
                       │
                       ▼
┌──────────────┐     ┌─────────────────┐
│  prometheus  │ ◀── │  log_to_metric  │
└──────────────┘     └─────────────────┘
                       │
                       │
                       ▼
                     ┌─────────────────┐
                     │ console_metrics │
                     └─────────────────┘