Tori: Ditch the Grafana Stack – Terminal-Native Docker Monitoring & Alerting (Show HN)

Introduction

In the fast-paced world of DevOps, maintaining visibility into our containerized applications is paramount. Yet, achieving this peace of mind often feels like an uphill battle. We've all been there: deploying a full-blown monitoring stack—Prometheus, Grafana, Loki, Alertmanager—only to be overwhelmed by its complexity, resource consumption, and the sheer effort required for setup and maintenance. It's a heavy overhead, especially when all you truly need is to quickly confirm that your Docker services are healthy and responding.

This frustration sparked a mission: to build a lightweight, efficient, and intuitive solution. The result is Tori, a terminal-native Docker monitoring and alerting tool delivered in a single binary. Tori eliminates the need for sprawling monitoring infrastructure, bringing essential insights directly to your terminal screen, ready when you are.

Core Concepts: What Makes Tori Unique?

Tori isn't just another monitoring tool; it redefines simplicity and efficiency for Docker environments. Its core concepts are designed to give you maximum value with minimum overhead.

The Single-Binary Advantage

At its heart, Tori is distributed as a single executable file. This means no complex dependencies, no intricate installation procedures, and significantly reduced resource footprint. Deploy it, run it, and you're monitoring—it’s that straightforward.

Terminal-Native Interface

Forget browser tabs and dashboard configurations. Tori provides a rich, interactive interface directly within your terminal. This design choice prioritizes speed and immediate access to critical data, making it ideal for quick checks, troubleshooting sessions, and server-side operations.

Integrated Agent Functionality

Tori operates as an intelligent agent deployed on your Docker host. This agent is responsible for three primary tasks:

  • Metric Collection: Gathers essential Docker container metrics like CPU usage, memory consumption, network I/O, and process status.
  • Log Tailing: Tails logs from specified Docker containers, providing real-time log streams for immediate diagnostics.
  • Alert Evaluation: Continuously evaluates predefined alert rules against collected metrics and logs, triggering notifications when thresholds are breached.

Built-in Alerting System

Unlike traditional setups that require separate tools for alerting (e.g., Alertmanager), Tori integrates alerting directly into its single binary. Define your rules in a simple configuration file, and Tori handles the rest—from evaluation to notification, all within its lightweight footprint.

Implementation Guide: Getting Started with Tori

Getting Tori up and running is designed to be as simple as possible. Follow these steps to start monitoring your Docker environment.

Step 1: Download the Tori Binary

Download the latest Tori binary for your operating system and architecture from the official release page (or a specified download URL).

# Example for Linux AMD64
wget https://get.tori.dev/tori_linux_amd64 -O tori
chmod +x tori

Step 2: Create Your Configuration File (tori.yaml)

Tori uses a YAML file for its configuration, specifying which containers to monitor, log paths, and alert rules. Create a file named tori.yaml in the same directory as your binary (or specify its path).

# tori.yaml example
docker:
  containers:
    - name: my-webapp
      id: "a1b2c3d4e5f6" # Optional: if container names change, use ID
      metrics: ["cpu_usage", "memory_usage", "network_io"]
      log_paths: ["/var/log/docker/my-webapp.log", "stdout"] # 'stdout' tails container logs directly

alerts:
  - name: High CPU Usage
    metric: "my-webapp.cpu_usage"
    threshold: 80 # Percentage
    operator: ">"
    duration: "1m"
    message: "High CPU usage detected on my-webapp container!"
    action: "log" # Other actions could be "webhook", "email" (if configured)
  - name: Error Log Detected
    log_path: "my-webapp.log"
    regex: "ERROR|FAILED"
    message: "Critical error found in my-webapp logs!"
    action: "log"

Step 3: Run the Tori Agent

Execute the Tori binary, pointing it to your configuration file. For persistent monitoring, it's recommended to run Tori as a systemd service or within a Docker container itself.

./tori --config tori.yaml

To run it in the background:

nohup ./tori --config tori.yaml &

Step 4: Access the Terminal UI (if applicable)

Tori might offer an interactive terminal UI. If so, instructions to access it would be provided upon running or via a separate command.

# Example command to launch the TUI, if separate
./tori tui

Automating Monitoring Deployment in CI/CD

Integrating Tori into your CI/CD pipelines ensures that your monitoring setup scales and updates seamlessly with your application deployments. This practice ensures consistent monitoring across all environments.

GitHub Actions Example

You can automate the deployment of the Tori agent and its configuration file to new or existing servers during your application deployment pipeline. This ensures that every new instance is immediately under Tori's watch.

name: Deploy Application with Tori Monitoring

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Deploy Tori Agent and Config
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.PROD_HOST }}
        username: ${{ secrets.PROD_USERNAME }}
        key: ${{ secrets.PROD_SSH_KEY }}
        script: |
          # Ensure Tori directory exists
          mkdir -p /opt/tori
          
          # Download Tori binary
          wget https://get.tori.dev/tori_linux_amd64 -O /opt/tori/tori
          chmod +x /opt/tori/tori
          
          # Upload tori.yaml from your repo
          echo "${{ secrets.TORI_CONFIG_YAML }}" > /opt/tori/tori.yaml
          
          # Restart Tori service (assuming systemd service is configured)
          sudo systemctl restart tori || sudo systemctl start tori

Note: secrets.TORI_CONFIG_YAML would be a GitHub Secret containing your base64 encoded tori.yaml content, or you can `scp` the file directly.

Jenkins Pipeline Example

For Jenkins, you can achieve similar automation using SSH steps or configuration management tools like Ansible within your pipeline.

pipeline {
    agent any
    stages {
        stage('Deploy Application') {
            steps {
                script {
                    // ... your application deployment steps ...
                }
            }
        }
        stage('Deploy Tori Monitoring') {
            steps {
                sshPublisher(publishers: [
                    sshPublisherDesc(
                        configName: 'YourProdServer', // Configure this in Jenkins System Settings
                        transfers: [
                            sshTransfer(
                                sourceFiles: 'tori.yaml', // Assuming tori.yaml is in your workspace
                                removePrefix: '',
                                remoteDirectory: '/opt/tori/',
                                execCommand: '''
                                    if [ ! -f /opt/tori/tori ]; then
                                        wget https://get.tori.dev/tori_linux_amd64 -O /opt/tori/tori
                                        chmod +x /opt/tori/tori
                                    fi
                                    sudo systemctl restart tori || sudo systemctl start tori
                                '''
                            )
                        ]
                    )
                ])
            }
        }
    }
}

These examples illustrate how Tori's simplicity lends itself well to automated deployment, ensuring your monitoring infrastructure is always up-to-date and in sync with your application state.

Comparison vs. Alternatives: Why Tori Stands Out

While a robust monitoring stack is invaluable for complex, large-scale deployments, it often comes with significant overhead. Tori offers a compelling alternative or complement.

Traditional Monitoring Stacks (Grafana, Prometheus, Loki, Alertmanager)

  • Complexity: High setup and maintenance complexity, requiring multiple services and extensive configuration.
  • Resource Intensive: Demands substantial CPU, memory, and storage, especially for historical data and high cardinality metrics.
  • Learning Curve: Steep learning curve for querying languages (PromQL, LogQL) and dashboard creation.
  • Strength: Ideal for long-term data retention, intricate dashboards, advanced analytics, and large-scale, distributed systems.

Tori

  • Simplicity: Single binary, minimal setup, and straightforward YAML configuration.
  • Resource Light: Designed for efficiency, making it suitable for resource-constrained environments or edge devices.
  • Immediate Insights: Terminal-native interface provides instant access to real-time metrics and logs, perfect for quick checks and troubleshooting.
  • Integrated Alerting: All-in-one solution for monitoring and alerting without external dependencies.
  • Strength: Perfect for immediate Docker host health checks, smaller deployments, development environments, and quick alert notifications without the bloat.

Tori is not necessarily a replacement for a full-fledged monitoring stack but rather a highly efficient alternative for specific use cases where simplicity, speed, and low resource consumption are critical. It's about getting peace of mind without the operational burden.

Best Practices for Using Tori

To maximize the benefits of Tori in your Docker environments, consider these best practices:

  • Start Simple with Alerts: Begin with essential alerts for critical metrics like high CPU/memory usage or key error patterns in logs. Refine and expand your alert rules as you become more familiar with your application's behavior.
  • Monitor Critical Services First: Prioritize monitoring for your most important Docker containers. This ensures that you're alerted to issues that directly impact your application's availability and performance.
  • Version Control Your tori.yaml: Treat your Tori configuration file as code. Store it in version control (e.g., Git) alongside your application code. This allows for tracking changes, auditing, and easy rollback.
  • Automate Deployment: Integrate Tori's deployment into your CI/CD pipelines. This ensures that every new server or updated application instance automatically gets its monitoring agent and configuration.
  • Use Systemd for Persistence: Run Tori as a systemd service to ensure it automatically starts on boot and restarts if it crashes, providing continuous monitoring without manual intervention.
  • Review Logs Periodically: While Tori alerts you to critical issues, a periodic review of the full logs (via Tori's tailing feature or direct access) can help spot subtle trends or recurring warnings that might not yet trigger an alert.

Conclusion

Tori emerges as a refreshing answer to the perennial challenge of Docker monitoring. By distilling the essential functionalities of metric collection, log tailing, and alerting into a single, terminal-native binary, it offers unparalleled simplicity and efficiency. It frees DevOps teams from the complexity and resource demands of traditional monitoring stacks, providing immediate insights and peace of mind directly where you work—your terminal.

If you're tired of over-engineered solutions for basic monitoring needs, Tori is designed for you. It's about getting back to basics, focusing on what truly matters: understanding the health of your Docker containers with minimal fuss.

Comments

Popular posts from this blog

Real-world Terraform scenarios to test and improve your Infrastructure as Code skills

Azure Kubernetes Service (AKS) Complete Guide

Automate Your DevOps Documentation: `iac-to-docs` Lands on PyPI with AI Power