DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Building an Enterprise CDC Solution
  • Unmasking Entity-Based Data Masking: Best Practices 2025
  • How Trustworthy Is Big Data?
  • Revolutionizing Financial Monitoring: Building a Team Dashboard With OpenObserve

Trending

  • How to Configure and Customize the Go SDK for Azure Cosmos DB
  • Unlocking AI Coding Assistants Part 4: Generate Spring Boot Application
  • A Guide to Developing Large Language Models Part 1: Pretraining
  • Kubeflow: Driving Scalable and Intelligent Machine Learning Systems
  1. DZone
  2. Data Engineering
  3. Databases
  4. Sampler: Dashboards, Monitoring, Alerting From Your Terminal

Sampler: Dashboards, Monitoring, Alerting From Your Terminal

Get metrics right from your terminal.

By 
Alexander Lukyanchikov user avatar
Alexander Lukyanchikov
·
Aug. 12, 19 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
11.6K Views

Join the DZone community and get the full member experience.

Join For Free

As a backend developer, I always need to monitor something — the state machine in the database, records count, message queue lag, custom application metrics, system performance, progress of my deployment scripts.

For a long time, I was trying to find a tool that could do keep everything in one place, alert me on a trigger, and be as fast and nimble as a local development tool. Heavy production monitoring systems can't help with such tasks; I needed a swiss army knife — something that could be configured in a minute and give me results right away.

I couldn't find anything, so I wrote my own. Meet Sampler — a tool for shell commands execution, visualization, and alerting configured with a simple YAML file.

Sampler

Sampler


To install Sampler, just follow the instructions for macOS, Linux or Windows

How Does it Work?

The idea is pretty simple — almost all metrics you might want to monitor and visualize are available through the CLI:

  • The obvious ones: CPU, memory, disk space, network.
  • Telemetry from a remote machine via ssh.
  • Any database metrics and results of your custom queries.
  • JMX.
  • Everything available via http, e.g. Spring Boot Actuator metrics.
  • Kafka, RabbitMQ, ActiveMQ.
  • Docker.

That means we can create our dashboards without complex integrations, drivers, and custom code; we can do it right from the terminal.

Using Sampler is basically a 3-step process:

  • Define your configuration in a YAML file.
  • Run sampler -c your-config-file.yml.
  • Adjust components size and location on UI.

Sampler executes specified commands with a required rate. The output is used for visualization.

Examples

Visualizations and Their YAML Configuration

Runchart

Runchart


runcharts:
  - title: Search engine response time
    rate-ms: 500        # sampling rate, default = 1000
    scale: 2            # number of digits after sample decimal point, default = 1
    legend:
      enabled: true     # enables item labels, default = true
      details: false    # enables item statistics: cur/min/max/dlt values, default = true
    items:
      - label: GOOGLE
        sample: curl -o /dev/null -s -w '%{time_total}'  https://www.google.com
        color: 178      # 8-bit color number, default one is chosen from a pre-defined palette
      - label: YAHOO
        sample: curl -o /dev/null -s -w '%{time_total}'  https://search.yahoo.com
      - label: BING
        sample: curl -o /dev/null -s -w '%{time_total}'  https://www.bing.com


Sparkline

CPU usage and Free memory pages

CPU usage and Free memory pages


sparklines:
  - title: CPU usage
    rate-ms: 200
    scale: 0
    sample: ps -A -o %cpu | awk '{s+=$1} END {print s}'
  - title: Free memory pages
    rate-ms: 200
    scale: 0
    sample: memory_pressure | grep 'Pages free' | awk '{print $3}'


Barchart

Local network activity

Local network activity


barcharts:
  - title: Local network activity
    rate-ms: 500        # sampling rate, default = 1000
    scale: 0            # number of digits after sample decimal point, default = 1
    items:
      - label: UDP bytes in
        sample: nettop -J bytes_in -l 1 -m udp | awk '{sum += $4} END {print sum}'
      - label: UDP bytes out
        sample: nettop -J bytes_out -l 1 -m udp | awk '{sum += $4} END {print sum}'
      - label: TCP bytes in
        sample: nettop -J bytes_in -l 1 -m tcp | awk '{sum += $4} END {print sum}'
      - label: TCP bytes out
        sample: nettop -J bytes_out -l 1 -m tcp | awk '{sum += $4} END {print sum}'


Gauge

Year and minute process

Year and minute process


gauges:
  - title: Minute progress
    rate-ms: 500        # sampling rate, default = 1000
    scale: 2            # number of digits after sample decimal point, default = 1
    percent-only: false # toggle display of the current value, default = false
    color: 178          # 8-bit color number, default one is chosen from a pre-defined palette
    cur:
      sample: date +%S  # sample script for current value
    max:
      sample: echo 60   # sample script for max value
    min:
      sample: echo 0    # sample script for min value
  - title: Year progress
    cur:
      sample: date +%j
    max:
      sample: echo 365
    min:
      sample: echo 0


Textbox

Docker container stats

Docker container stats


textboxes:
  - title: Local weather
    rate-ms: 10000      # sampling rate, default = 1000
    sample: curl wttr.in?0ATQF
    border: false       # border around the item, default = true
    color: 178          # 8-bit color number, default is white
  - title: Docker containers stats
    rate-ms: 500
    sample: docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.PIDs}}"


Asciibox

UTC time

UTC time


asciiboxes:
  - title: UTC time
    rate-ms: 500        # sampling rate, default = 1000
    font: 3d            # font type, default = 2d
    border: false       # border around the item, default = true    
    color: 43           # 8-bit color number, default is white
    sample: env TZ=UTC date +%r


Triggers

Sampler can execute conditional actions based on your shell commands output. Using triggers, you can start the deployment process and get a notification when it's done. You can also get an alert when your metric exceeds a threshold.

Sampler supports four types of trigger actions:

  • Visual (alert will be displayed on top of your chart).
  • Sound (NASA quindar tone).
  • Standard terminal bell.
  • Custom script, where you can use an alert label for current and previous values.

Here is an example of a chart with a configured search engine latency alert. When the latency exceeds the specified threashold of 0.3 sec, Sampler will ring a bell, show the visual notification, and execute a custom script, which uses macOS voice capabilities to say the latency value:

runcharts:
  - title: SEARCH ENGINE RESPONSE TIME (sec)
    rate-ms: 200
    items:
      - label: GOOGLE
        sample: curl -o /dev/null -s -w '%{time_total}'  https://www.google.com
      - label: YAHOO
        sample: curl -o /dev/null -s -w '%{time_total}'  https://search.yahoo.com     
    triggers:
      - title: Latency threshold exceeded
        condition: echo "$prev < 0.3 && $cur > 0.3" |bc -l  # expects "1" as TRUE indicator
        actions:
          terminal-bell: true  # standard terminal bell, default = false
          sound: true   # NASA quindar tone, default = false
          visual: true  # visual notification on top of the component area, default = false
          script: 'say alert: ${label} latency exceeded ${cur} second' # an arbitrary script, which can use $cur, $prev and $label variables


There's More

Interactive shell support, PTY mode, variables, and real-world recipes to work with MySQL, PostgreSQL, MongoDB, Neo4J, Kafka, etc. You can read all about Sampler's advanced capabilities in the documentation.

Don't hesitate to ask questions, contribute, and star the project on Github

terminal Dashboard (Mac OS) Database

Opinions expressed by DZone contributors are their own.

Related

  • Building an Enterprise CDC Solution
  • Unmasking Entity-Based Data Masking: Best Practices 2025
  • How Trustworthy Is Big Data?
  • Revolutionizing Financial Monitoring: Building a Team Dashboard With OpenObserve

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!