When your applications generate logs, the raw text is full of useful signals — response times, error rates, request counts, and queue depths. But Prometheus and Grafana can’t read raw log files. You need a log parser to extract metrics from unstructured text and expose them in a format your monitoring stack understands.
This guide compares three self-hosted log parsing tools: mtail (Google’s log-to-metrics extractor), grok_exporter (Prometheus exporter with Grok pattern matching), and Vector (high-performance observability pipeline). Each can transform your application logs into actionable Prometheus metrics without shipping the entire log payload to a central aggregator.
For a broader look at log aggregation architecture, see our rsyslog vs syslog-ng vs Vector comparison and Prometheus vs Grafana vs VictoriaMetrics overview.
Why Self-Host Log Parsing?
Cloud-based log management services charge by ingestion volume. If you’re generating gigabytes of logs daily, sending everything to a SaaS platform gets expensive fast. Self-hosted log parsing lets you:
- Extract only the metrics you need — parse logs locally and discard the raw text after extraction
- Reduce storage costs — store structured metrics (kilobytes) instead of raw logs (gigabytes)
- Maintain full data sovereignty — logs never leave your infrastructure
- Integrate with existing Prometheus/Grafana stacks — no new monitoring platform required
- React to log patterns in real time — trigger alerts based on parsed log events, not just raw text searches
Quick Comparison
| Feature | mtail | grok_exporter | Vector |
|---|---|---|---|
| GitHub Stars | 4,007 | 930 | 21,730 |
| Last Updated | March 2026 | November 2023 | April 2026 |
| Developer | Community (fstab) | Datadog (open source) | |
| Language | Go | Go | Rust |
| Pattern Syntax | Custom mtail language | Grok (Logstash-compatible) | VRL (Vector Remap Language) |
| Output Format | Prometheus metrics, stdout | Prometheus metrics | 40+ sinks (Prometheus, Loki, etc.) |
| Docker Image | google/mtail | fstab/grok_exporter | timberio/vector |
| Resource Usage | Low | Low | Low to Medium |
| Learning Curve | Medium | Low (if you know Grok) | Medium |
| Best For | Simple log-to-metrics extraction | Teams already using Grok patterns | Full observability pipeline |
mtail — Google’s Log-to-Metrics Extractor
mtail is Google’s open-source tool for extracting metrics from application logs. It uses a custom pattern language that’s purpose-built for log parsing. mtail watches log files (or receives data via stdin) and applies your program to extract counters, gauges, and histograms.
Key Features
- Purpose-built pattern language — the mtail language is designed specifically for log parsing, with regex, state machines, and time extraction built in
- Prometheus-native — exposes a
/metricsendpoint that Prometheus scrapes directly - Low resource footprint — runs as a lightweight sidecar alongside your applications
- Google production-tested — used internally at Google for monitoring thousands of services
Docker Compose Setup
| |
Example mtail Program
Here’s an mtail program that parses Nginx access logs and extracts HTTP status code counts and response time histograms:
| |
Installation (Binary)
| |
grok_exporter — Prometheus Exporter with Grok Patterns
grok_exporter is a Prometheus exporter that uses Grok patterns (the same syntax used by Logstash) to parse unstructured log data. If your team already uses Grok patterns for Logstash or Elasticsearch, grok_exporter lets you reuse them directly for Prometheus metrics.
Key Features
- Grok pattern compatibility — reuse existing Logstash/Elasticsearch Grok patterns without rewriting
- Simple YAML configuration — define metrics, patterns, and labels in a single config file
- Multiple metric types — supports counters, gauges, histograms, and summaries
- File and stdin input — can tail log files or receive data via standard input
Note: grok_exporter’s last commit was in November 2023. While it remains functional for stable use cases, the project is no longer actively maintained. For new deployments, Vector is the recommended alternative with active development.
Docker Compose Setup
| |
Example Configuration
| |
Custom Grok Pattern
For logs that don’t match built-in patterns, you can define custom ones:
| |
Installation (Binary)
| |
Vector — High-Performance Observability Pipeline
Vector is a high-performance observability data pipeline built in Rust. While mtail and grok_exporter focus solely on log-to-metrics extraction, Vector can collect, transform, and route logs, metrics, and traces to 40+ destinations. Its VRL (Vector Remap Language) provides powerful log parsing capabilities.
Key Features
- All-in-one pipeline — collect, transform, and route logs, metrics, and traces in a single tool
- VRL (Vector Remap Language) — purpose-built transformation language with regex, JSON parsing, and conditional logic
- 40+ sinks — output to Prometheus, Loki, Elasticsearch, S3, Kafka, and many more
- Rust performance — handles millions of events per second with minimal CPU and memory
- Active development — backed by Datadog with a large open-source community
Docker Compose Setup
| |
Example Vector Configuration (TOML)
| |
Installation (Binary)
| |
Performance Comparison
| Metric | mtail | grok_exporter | Vector |
|---|---|---|---|
| Throughput | ~50K lines/sec | ~30K lines/sec | ~500K+ lines/sec |
| Memory Usage | ~20 MB | ~15 MB | ~50-100 MB |
| CPU Usage | Low | Low | Low to Medium |
| Startup Time | < 1s | < 1s | 1-2s |
| Regex Performance | Good (RE2 engine) | Good (Oniguruma) | Excellent (Rust regex) |
Note: Performance numbers are approximate and depend on pattern complexity, log format, and hardware.
When to Use Each Tool
Choose mtail if:
- You want a simple, focused tool for log-to-metrics extraction
- Your team is comfortable writing custom parsing programs
- You need Prometheus metrics with minimal overhead
- You’re monitoring Google Cloud Platform services (mtail integrates well)
Choose grok_exporter if:
- You already have a library of Grok patterns from Logstash/Elasticsearch
- Your log parsing needs are straightforward and stable
- You want a quick drop-in Prometheus exporter for existing log formats
- You don’t need active maintenance (project is in maintenance mode)
Choose Vector if:
- You need a full observability pipeline (logs, metrics, traces)
- Performance is critical (millions of events per second)
- You want to route data to multiple destinations simultaneously
- You need active development and community support
- You want to transform and enrich data before sending it to your monitoring stack
Frequently Asked Questions
What is the difference between log parsing and log aggregation?
Log parsing extracts structured data (metrics, fields) from unstructured log text. Log aggregation collects and centralizes log data from multiple sources. Tools like mtail and grok_exporter focus on parsing — they turn raw logs into Prometheus metrics. Tools like Vector can do both: parse logs into metrics AND aggregate/ship raw logs to central storage.
Can I use Grok patterns with mtail?
No, mtail uses its own custom pattern language. However, the concepts are similar — both use regex-based pattern matching with named capture groups. If you have existing Grok patterns, you’ll need to translate them to mtail syntax. Vector supports both Grok-like regex and its own VRL language.
Is grok_exporter still maintained?
The last commit to grok_exporter was in November 2023. The project is functional and stable for existing use cases, but it is not actively developed. For new deployments, Vector is recommended as it offers Grok-compatible parsing with active maintenance and a broader feature set.
Can these tools parse JSON logs?
Yes, all three can handle JSON-formatted logs. mtail can parse JSON using its regex capabilities. grok_exporter has a JSON input type. Vector has native JSON parsing via parse_json!() in VRL, making it the most straightforward option for JSON log formats.
How do I integrate parsed metrics with Prometheus?
All three tools expose a /metrics HTTP endpoint that Prometheus scrapes. Add a scrape configuration to your prometheus.yml:
| |
For related reading, see our Prometheus alerting guide and container monitoring comparison.
Do I need to restart these tools when log files rotate?
mtail handles log rotation automatically — it detects when a file is rotated and switches to the new file. grok_exporter also handles log rotation natively. Vector’s file source supports log rotation detection out of the box. No manual restart is needed for any of these tools.