Metrics dashboards on terminal (a grafana inspired terminal version)

Grafterm CircleCI Go Report Card

Visualize metrics dashboards on the terminal, like a simplified and minimalist version of Grafana for terminal.

grafterm red dashboard

Features

  • Multiple widgets (graph, singlestat, gauge).
  • Multiple datasources usage.
  • User stored datasources.
  • Override dashboard datasource ID to different datasource ID configured by the user.
  • Custom dashboards based on JSON configuration files.
  • Extensible metrics datasource implementation (Prometheus and Graphite included).
  • Templating of variables.
  • Auto time interval adjustment for queries.
  • Auto unit formatting on widgets.
  • Fixed and adaptive grid.
  • Color customization on widgets.
  • Configurable autorefresh.
  • Single binary and easy usage/deployment.

Installation

Download the binaries from releases

Running options

Exit with q or Esc

Simple

grafterm -c ./mydashboard.json

Relative time

grafterm -c ./mydashboard.json -d 48h

Refresh interval

grafterm -c ./mydashboard.json -r 2s

Debugging

When grafterm doesn't show anything may be that has errors getting metrics or similar. There is available a --debug flag that will write a log on grafterm.log (this path can be override with --log-path flag)

Read the log

tail -f ./grafterm.log

And run grafterm in debug mode.

grafterm -c ./mydashboard.json  -d 48h -r 2s --debug

Fixed time

Setting a fixed time range to visualize the metrics using duration notation. In this example is start at now-22h and end at now-20h

grafterm -c ./mydashboard.json -s 22h -e 20h

Setting a fixed time range to visualize the metrics using timestamp ISO 8601 notation.

grafterm -c ./mydashboard.json -s 2019-05-12T12:32:11+02:00 -e 2019-05-12T12:35:11+02:00

Replacing dashboard variables

grafterm -c ./mydashboard.json -v env=prod -v job=envoy

Replacing dashboard datasource configuration

Replace dashbaord prometheus datasource with user datasource thanos-prometheus (check Datasources section):

grafterm -c ./mydashboard.json -a "prometheus=thanos-prometheus"

Replace dashboard prometheus datasource with user datasource thanos-prometheus available on /tmp/my-datasources.json user datasource configuration file:

grafterm -c ./mydashboard.json -a "prometheus=thanos-prometheus" -u /tmp/my-datasources.json

Dashboard

Check this section that explains how a dashboard is configured. Also check dashboard examples

Datasources

Datasources are the way grafterm knows how to retrieve the metrics for the dashboard.

check available types and how to configure in this section.

If you want support for a new datasource type, open an issue or send a PR

Overriding dashboard datasources

Dashboard referenced datasources on the queries can be override.

User datasource

Grafterm dashboards can have default datasources but the user can override these datasources using a datasources config file. This file has the same format as the dashboard configuration file but will ignore anything other than the datasources block. Example:

{
  "version": "v1",
  "datasources": {
    "prometheus": {
      "prometheus": { "address": "http://127.0.0.1:9090" }
    },
    "localprom": {
      "prometheus": { "address": "http://127.0.0.1:9091" }
    },
    "thanos": {
      "prometheus": { "address": "http://127.0.0.1:9092" }
    },
    "m3db": {
      "prometheus": { "address": "http://127.0.0.1:9093" }
    },
    "victoriametrics": {
      "prometheus": { "address": "http://127.0.0.1:8428" }
    },
    "wikimedia": {
      "graphite": { "address": "https://graphite.wikimedia.org" }
    }
  }
}

If the dashboard has defined a datasource configuration with the ID my-ds reference, and the user datasources has this same datasource ID, grafterm will use the user defined one when the queries in the dashboard reference this ID.

The user datasources location can be configured with this priority (from highest to lowest):

  • If --user-datasources explicit flag is used, it will use this.
  • If GRAFTERM_USER_DATASOURCES env var is set, it will use this.
  • As a fallback location will check {USER_HOME}/grafterm/datasources.json exists.

Alias

Apart from overriding the dashboard datasources IDs that match with the user datasources, the user can force an alias with the form dashboard-ds-id=user-ds-id.

For example, the dashboard uses a datasource named prometheus-2b, and we want to use our local prometheus configured on the user datasources as localprom, we could use the alias flag like this: -a "prometheus-2b=localprom", now every query the dashboard widgets make to prometheus-2b will be made to localprom.

Kudos

This project would not be possible without the effort of many people and projects but specially Grafana for the inspiration, ideas and the project itself, and Termdash for the rendering of all those fancy graphs on the terminal.

Owner
Xabier Larrakoetxea Gallego
Tools at @newrelic
Xabier Larrakoetxea Gallego
Comments
  • Arm release missing

    Arm release missing

    Using GOARM=7 GOARCH=arm for a fourth release in build.sh so it can be used on raspberry pi would be very handy. This is such a neat project to be able to run on my raspberry pi cluster, showing on the little 3.5" screen.

  • Readme.md: add VictoriaMetrics to datasource examples

    Readme.md: add VictoriaMetrics to datasource examples

    VictoriaMetrics supports Prometheus querying API and it listens for 8428 port by default. See https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/README.md#grafana-setup for details.

  • Not working on windows

    Not working on windows

    Hi! This looks amazing, but I am having some troubles while trying on windows. I am not sure if I have to install it somehow, but I guess I don't have to. Therefore, I try to run it on the command console, with this result:

    graftermIssue

    I hope it helps!

  • Allow overriding dashboard datasources with a custom datasource configuration file

    Allow overriding dashboard datasources with a custom datasource configuration file

    When loading a dashboard would be nice to override the datasources of the dashboard using a datasource replace configuration file via flag and/or on a specific path (configured by the user)

  • Refactor all the app view

    Refactor all the app view

    This PR refactors all the main view application into 3 components.

    This refactor changes the view architecture. it Takes a new approach of syncing, the sync process will be triggered by a *sync.Request, and the view will have a sync.Syncer that will be called with that sync request. With this 2 componentes, it follows a similar approach to HTTP client/server architecture. sync.Syncer would be http.Handler and *sync.Request http.Request, although this doesn't have a response.

    • The app itself: This controls the app flow, it creates the initial sync request and will call the syncer.
    • sync package has the sync components (Syncer and Request).
    • page package has the handlers itself, (dashboards, widgets...).

    With this architecture and having the components decoupled, we can extend to render multiple dashboards, request events when selecting widgets...

  • Add null point mode to manage the points in graph that have null values

    Add null point mode to manage the points in graph that have null values

    This adds a policy to the graph series override that will act when there are no datapoints for a specific time range, this is handy on graphs that there is spaced data for the time range.

    An example could be a datapoint every 1m and we have a graph of 30m, 30 datapoints in a graph that could render 400 points in the terminal would not be rendered.

    This happens mostly with Graphite datasource API calls, because Prometheus already calculates the step used on the query API call (that grafterm calculates already) to return the correct number of datapoints so we don't need to do this.

  • Override dashboard datasources with the user ones

    Override dashboard datasources with the user ones

    This PR fixes #37

    Let the user override the datasources that are configured on the dashboard.

    • Add a way of letting the user load a configuration file with multiple datasources.
    • Add alias flag to override the calls to one datasource ID to another one.

    Also adds codeowners and updates documentation.

  • Add start and end flags

    Add start and end flags

    This PR adds the ability to set start and end timestamps using command line flags, it also works with time durations so the user can set start and end based on now - duration style.

    • Fixes graph X labels rendering to local time zone.
    • Add start and end cmd flags.
    • Instant widgets (gauge, singlestat) now use end timestamp instead of now to get the metrics. End is calculated on every sync, so acts as now except that if the user sets end using flags, it will get the one the user set via flag.
    • Rename relative-time-range flag to relative-duration
  • Add the ability to override variables using flags.

    Add the ability to override variables using flags.

    This PR gives the user the ability to override variable values using -v or --var flags.

    • Migrate flags to kingpin library.
    • Add Kingpin dependency.
    • Add -v, --var repeatable flag to allow the user overriding variables on the dashboard.
    • Add the app widget data middleware the override data variables, they will have more priority than the static and sync data.
  • Add units and decimals to singlestat and graph widget.

    Add units and decimals to singlestat and graph widget.

    This PR adds the ability to set unit to the graph and singlestat widgets.

    • Add unit formatters with decimal support:
      • Short formatter (pretty short numbers).
      • Second duration pretty formatter.
      • Byte data quantity pretty formatter.
      • Suffix based formatters.
    • Add settings to set the unit and decimals on graph Y axis (model and V1 configuration).
    • Add settings to set the unit and decimals on singlestat (model and V1 configuration).
  • Adds support for YAML configuration files

    Adds support for YAML configuration files

    I converted the JSON examples to YAML with yq and did some quick smoke testing with those files. Fixes #65

    This file didn't work though (YAML or JSON):

    $ ./bin/grafterm --cfg=./dashboard-examples/json/test-grid-fixed.json
    error executing program: error on  widget grid position: widget grid position in a fixed grid should have an X position
    
  • Support YAML configuration

    Support YAML configuration

    YAML can express precisely what JSON can express, but is much easier to write (as it expresses hierarchy through indentation instead of opening/closing brackets).

    Therefore, it would be awesome if grafterm could support YAML additionally to JSON πŸ™‚

  • Make fails on step 5 (looks like problem with gocenter.io AND problem with mockery)

    Make fails on step 5 (looks like problem with gocenter.io AND problem with mockery)

    Just pulled master. On Arch: amd64 Linux. Tried make...

    Step 5/15 : RUN go get -u github.com/vektra/mockery/.../
     ---> Running in dcd1965c7357
    package github.com/vektra/mockery
            imports github.com/hashicorp/hcl/hcl/printer: cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of:
            /usr/local/go/src/github.com/hashicorp/hcl/hcl/printer (from $GOROOT)
            /go/src/github.com/hashicorp/hcl/hcl/printer (from $GOPATH)
    The command '/bin/sh -c go get -u github.com/vektra/mockery/.../' returned a non-zero code: 1
    make: *** [Makefile:60: build] Error 1
    

    Ok...

    Found this https://github.com/vektra/mockery/issues/364

    Modify ./docker/dev/Dockerfile line to ...

    # Mock creator
    RUN GO111MODULE="on" go get -u github.com/vektra/mockery
    

    Try again ...

    Step 5/15 : RUN GO111MODULE="on" go get -u github.com/vektra/mockery
     ---> Running in f240d67d7a70
    go get github.com/vektra/mockery: unexpected status (https://gocenter.io/github.com/vektra/mockery/@v/list): 405 Not Allowed
    

    Ok, back to Dockerfile... Change goproxy line to...

    ENV GOPROXY=https://proxy.golang.org
    

    Try again...

    Step 8/15 : RUN bash -c 'if [ ${ostype} == Linux ]; then addgroup -g $gid app; else addgroup app; fi &&     adduser -D -u $uid -G app app &&     chown app:app -R /go'
     ---> Running in d2ce703cf649
    addgroup: gid '0' in use
    The command '/bin/sh -c bash -c 'if [ ${ostype} == Linux ]; then addgroup -g $gid app; else addgroup app; fi &&     adduser -D -u $uid -G app app &&     chown app:app -R /go'' returned a non-zero code: 1
    make: *** [Makefile:60: build] Error 1
    

    Ok, back to Dockerfile... changed uid and gid variable names...

    ARG auid=2000
    ARG agid=2000
    
    RUN bash -c 'if [ ${ostype} == Linux ]; then addgroup -g $agid app; else addgroup app; fi && \
        adduser -D -u $auid -G app app && \
        chown app:app -R /go'
    

    Try again...

    Step 16/16 : WORKDIR /src
     ---> Running in 4bd2a103b450
    Removing intermediate container 4bd2a103b450
     ---> 2aa32cec6d7e
    [Warning] One or more build-args [gid uid] were not consumed
    Successfully built 2aa32cec6d7e
    Successfully tagged grafterm:latest
    

    Success!

    Actually building a binary was another slog through the Makefile..

    I manually ran VERSION=amd64 ostype=Linux ./hack/scripts/build.sh

    ❯ ls -l ~/github/grafterm/bin/grafterm-linux-amd64
    -rwxr-xr-x 1 ... /home/user/github/grafterm/bin/grafterm-linux-amd64
    

    Cool.

    ❯ ~/github/grafterm/bin/grafterm-linux-amd64 --help
    usage: grafterm [<flags>]
    
    graph metrics on the terminal
    
    Flags:
          --help                     Show context-sensitive help (also try --help-long and --help-man).
          --version                  Show application version.
      -c, --cfg="dashboard.json"     the path to the configuration file
      -r, --refresh-interval=10s     the interval to refresh the dashboard
          --log-path="grafterm.log"  the path where the log output will be written
      -d, --relative-duration=RELATIVE-DURATION
                                     the relative duration from now to load the graph.
      -s, --start=START              the time the dashboard will start in time. Accepts 2 formats, relative time from now based on duration(e.g.: 24h, 15m), or fixed duration in ISO 8601 (e.g.:
                                     2019-05-12T09:35:11+00:00). If set it disables relative duration flag.
      -e, --end=END                  the time the dashboard will end in time. Accepts 2 formats, relative time from now based on duration(e.g.: 24h, 15m), or fixed duration in ISO 8601 (e.g.:
                                     2019-05-12T09:35:11+00:00).
      -v, --var=VAR ...              repeatable flag that will override the variable defined on the dashboard (in 'key=value' form)
      -a, --ds-alias=DS-ALIAS ...    repeatable flag that maps dashboard ID datasources to user defined datasources in the form of 'dashboard=user' (in 'key=value' form)
      -u, --user-datasources="/home/user/grafterm/datasources.json"
                                     path to a configuration file with user defined datasources, these datasources can override the dashboard datasources with the same ID and also can be used to alias
                                     them using datasource alias flags. It fallbacks to GRAFTERM_USER_DATASOURCES env var
          --debug                    enable debug mode, on debug mode it will print logs to the desired output
    

    Hey, it is alive.

    ❯ ~/github/grafterm/bin/grafterm-linux-amd64 --cfg="/home/$USER/github/grafterm/dashboard-examples/test-grid-adaptive.json"
    

    Yep, that loads the test grid.

  • Stretchr/testify v1.4.0 has a security problem (CVE 6.5)

    Stretchr/testify v1.4.0 has a security problem (CVE 6.5)

    βœ— Medium severity vulnerability found in gopkg.in/yaml.v2 (CVE 6.5) Description: Denial of Service (DoS) Info: https://snyk.io/vuln/SNYK-GOLANG-GOPKGINYAMLV2-1083943 Introduced through: github.com/stretchr/testify/[email protected] From: github.com/stretchr/testify/[email protected] > github.com/stretchr/testify/[email protected] > gopkg.in/[email protected] Fixed in: 2.2.8

A simple http service that generates *.PDF reports from Grafana dashboards.
A simple http service that generates *.PDF reports from Grafana dashboards.

Grafana reporter A simple http service that generates *.PDF reports from Grafana dashboards. Requirements Runtime requirements pdflatex installed and

Dec 27, 2022
An example logging system using Prometheus, Loki, and Grafana.
An example logging system using Prometheus, Loki, and Grafana.

Logging Example Structure Collector Export numerical data for Prometheus and log data for Promtail. Exporter uses port 8080 Log files are saved to ./c

Nov 21, 2022
A flexible process data collection, metrics, monitoring, instrumentation, and tracing client library for Go
A flexible process data collection, metrics, monitoring, instrumentation, and tracing client library for Go

Package monkit is a flexible code instrumenting and data collection library. See documentation at https://godoc.org/gopkg.in/spacemonkeygo/monkit.v3 S

Dec 14, 2022
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

The open-source platform for monitoring and observability. Grafana allows you to query, visualize, alert on and understand your metrics no matter wher

Jan 3, 2023
A Postgres Metrics Dashboard
A Postgres Metrics Dashboard

#Pome Pome stands for Postgres Metrics. Pome is a PostgreSQL Metrics Dashboard to keep track of the health of your database. This project is at a very

Dec 22, 2022
Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.
Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.

logkit-community δΈ­ζ–‡η‰ˆ Introduce Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console. logkit-community De

Dec 29, 2022
gin-gonic/gin metrics for prometheus.
gin-gonic/gin  metrics for prometheus.

gin-metrics gin-gonic/gin metrics exporter for Prometheus. δΈ­ζ–‡ Introduction gin-metrics defines some metrics for gin http-server. There have easy way t

Jan 1, 2023
Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.
Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.

Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.

Jan 4, 2023
gosivy - Real-time visualization tool for Go process metrics
 gosivy - Real-time visualization tool for Go process metrics

Gosivy tracks Go process's metrics and plot their evolution over time right into your terminal, no matter where it's running on. It helps you understand how your application consumes the resources.

Nov 27, 2022
Go runtime metrics stack on your local computer.
Go runtime metrics stack on your local computer.

Goal This repository provides a docker-compose for Go runtime metrics stack on your local computer. It is using influxdb and grafana, it based on the

Oct 8, 2021
Go starter project with Gin, Viper, postgres , redis, zap, prometheus metrics etc setup

Go REST Service Starter/Boilerplate Easily extendible REST API Service boilerplate aiming to follow idiomatic go and best practice. Any feedback and p

Jun 23, 2022
Clogger: a WIP version of my idealized logging system

Clogger Clogger is a WIP version of my idealized logging system. In many ways, i

Dec 30, 2022
A version control system to manage large files.

ArtiVC ArtiVC (Artifacts Version Control) is a handy command-line tool for data versioning on cloud storage. With only one command, it helps you neatl

Jan 4, 2023
Package httpretty prints the HTTP requests you make with Go pretty on your terminal.

httpretty Package httpretty prints the HTTP requests of your Go programs pretty on your terminal screen. It is mostly inspired in curl's --verbose mod

Jan 8, 2023
grafana-sync Keep your grafana dashboards in sync.

grafana-sync Keep your grafana dashboards in sync. Table of Contents grafana-sync Table of Contents Installing Getting Started Pull Save all dashboard

Dec 14, 2022
Snowflake grafana datasource plugin allows Snowflake data to be visually represented in Grafana dashboards.
Snowflake grafana datasource plugin allows Snowflake data to be visually represented in Grafana dashboards.

Snowflake Grafana Data Source With the Snowflake plugin, you can visualize your Snowflake data in Grafana and build awesome chart. Get started with th

Dec 29, 2022
Cole - Cole can use his sixth sense to give you metrics about your Grafana dashboards

Cole Cole can use his sixth sense to give you metrics about your Grafana dashboa

Nov 9, 2022
User-friendly Go library for building Grafana dashboards

Grabana Grabana provides a developer-friendly way of creating Grafana dashboards. Whether you prefer writing code or YAML, if you are looking for a wa

Dec 16, 2022
A simple http service that generates *.PDF reports from Grafana dashboards.
A simple http service that generates *.PDF reports from Grafana dashboards.

Grafana reporter A simple http service that generates *.PDF reports from Grafana dashboards. Requirements Runtime requirements pdflatex installed and

Dec 27, 2022
A tool to lint Grafana dashboards

Grafana Dashboard Linter This is a tool to lint Grafana dashboards for common mistakes. To use: $ go install github.com/grafana/dashboard-linter $ das

Dec 27, 2022