Code Monkey home page Code Monkey logo

jplot's Introduction

jplot

license

Jplot tracks expvar-like (JSON) metrics and plot their evolution over time right into your iTerm2 terminal (or DRCS Sixel Graphics).

Above capture is jplot monitoring a Go service's expvar:

jplot --url http://:8080/debug/vars \
    memstats.HeapSys+memstats.HeapAlloc+memstats.HeapIdle+marker,counter:memstats.NumGC \
    counter:memstats.TotalAlloc \
    memstats.HeapObjects \
    memstats.StackSys+memstats.StackInuse

By default, jplot uses the full size of the terminal, but it is possible to limit the render to a few rows:

Install

Using homebrew:

brew install rs/tap/jplot

From source:

go install github.com/rs/jplot@latest

This tool does only work with iTerm2, or terminals support DRCS Sixel Graphics.

Usage

Given the following JSON output:

{
    "mem": {
        "Heap": 1234,
        "Sys": 4321,
        "Stack": 203
    },
    "cpu": {
        "STime": 123,
        "UTime":1234
    },
    "Threads": 2
}

You can graph the number of thread over time:

jplot --url http://:8080/debug/vars Threads

Or create a graph with both Utime and Stime growth rate on the same axis by using + between two field paths:

jplot --url http://:8080/debug/vars counter:cpu.STime+counter:cpu.UTime

Note: the counter: prefix instructs jplot to compute the difference between the values instead of showing their absolute value.

Or create several graphs by providing groups of fields as separate arguments; each argument creates a new graph:

jplot --url http://:8080/debug/vars mem.Heap+mem.Sys+mem.Stack counter:cpu.STime+cpu.UTime Threads

Spec Syntax

Each positional arguments given to jplot create a stacked graph with the specified values. To reference the values, use gojq JSON query syntax. Several value paths can be referenced for the same graph by using the + character to separate them.

In addition, each value path can be prefixed with options separated from the path by a column. Several options can be used for the same command by separating them with a comma like so: option1,option2:value.path.

Supported options are:

  • counter: Computes the difference with the last value. The value must increase monotonically.
  • marker: When the value is none-zero, a vertical line is drawn.

Recipes

Memstats

Here is an example command to graph a Go program memstats:

jplot --url http://:8080/debug/vars \
    memstats.HeapSys+memstats.HeapAlloc+memstats.HeapIdle+marker,counter:memstats.NumGC \
    counter:memstats.TotalAlloc \
    memstats.HeapObjects \
    memstats.StackSys+memstats.StackInuse

Vegeta

With the help of jaggr can be used to integrate vegeta with jplot as follow:

echo 'GET http://localhost:8080' | \
    vegeta attack -rate 5000 -workers 100 -duration 10m | vegeta dump | \
    jaggr @count=rps \
          hist\[100,200,300,400,500\]:code \
          p25,p50,p95:latency \
          sum:bytes_in \
          sum:bytes_out | \
    jplot rps+code.hist.100+code.hist.200+code.hist.300+code.hist.400+code.hist.500 \
          latency.p95+latency.p50+latency.p25 \
          bytes_in.sum+bytes_out.sum

Supported Terminals

jplot's People

Contributors

chandanpasunoori avatar dependabot[bot] avatar ibreaker avatar mattn avatar olleolleolle avatar opexxx avatar rs avatar testwill avatar

Stargazers

 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

jplot's Issues

Do you have plan to support terminals + sixel graphics?

Currently, I'm porthing jplot to work with sixel graphics.

terminal4

This works on terminal support DRCS Sixel extension. This screencapture is taken on Windows and mitty terminal. If you have an interesting, I'll send PR in later. But I can't promise when I finish porthing.

iTerm memory grows without being released.

Iterm memory consumption seems to just keep growing while jplot is running. It will grow to 5G if you leave jplot running for just 10-15 minutes. I left jplot running last night and when I got in this morning there was a dialog that all the application memory on my computer had been exhausted. jplot had crashed so it had been reclaimed by the time I got in.

Is there anyway to manage this?

jplot does not cover window

I just started using jplot for the first time. Running an example from vegeta yields the below results. It is only half height and half the width.

screen shot 2018-06-19 at 9 34 26 am

My command is

$ echo 'GET http://192.168.99.100:31330/demo/hello' | \                   
vegeta attack -rate 5000 -duration 10m | vegeta dump | \
                   jaggr @count=rps \
                         hist\[100,200,300,400,500\]:code \
                         p25,p50,p95:latency \
                         sum:bytes_in \
                         sum:bytes_out | \
                   jplot rps+code.hist.100+code.hist.200+code.hist.300+code.hist.400+code.hist.500 \
                         latency.p95+latency.p50+latency.p25 \
                         bytes_in.sum+bytes_out.sum

I suspect this has to do with iTerm beta version. I am using 3.2.0beta3.

Does anybody else have this problem?

amd64 support

Hello

Can you release it for amd64 please ?

Best regards,

New chart did not have seq sub directory

Hi @rs,
When I build jplot I have error: package github.com/wcharczuk/go-chart/seq: cannot find package "github.com/wcharczuk/go-chart/seq" in any of: /usr/lib/go/src/github.com/wcharczuk/go-chart/seq (from $GOROOT) /home/dragon/go/src/github.com/wcharczuk/go-chart/seq (from $GOPATH)

The go-chart is now in v3.0, then code should upgrade to it.

Best regards,
Severus

run and render is base64 string, not image in iterm2

hello, i have some troubled,

when i run command like it in iterm2:

echo 'GET http://www.hi-linux.com' | \
    vegeta attack -rate 5000 -duration 10m | vegeta encode | \
    jaggr @count=rps \
          hist\[100,200,300,400,500\]:code \
          p25,p50,p95:latency \
          sum:bytes_in \
          sum:bytes_out | \
    jplot rps+code.hist.100+code.hist.200+code.hist.300+code.hist.400+code.hist.500 \
          latency.p95+latency.p50+latency.p25 \
          bytes_in.sum+bytes_out.sum

it render base64 string, not image, have you ever met?

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.