Telegraf
Plugin-driven server agent for collecting and reporting metrics.
Overview
Telegraf is InfluxData's plugin-driven server agent designed to collect, process, aggregate, and write metrics from diverse sources including system statistics, application metrics, IoT sensors, and third-party APIs. Originally developed as part of the TICK stack (Telegraf, InfluxDB, Chronograf, Kapacitor), Telegraf has become the de facto standard for metrics collection with over 300 input plugins and numerous output destinations, making it one of the most versatile monitoring agents available.
This monitoring stack combines Telegraf's comprehensive data collection capabilities with InfluxDB's purpose-built time-series database engine to create a powerful metrics pipeline. Telegraf continuously gathers metrics from configured sources and pushes them directly to InfluxDB using its native line protocol, while InfluxDB stores and indexes the time-stamped data for fast retrieval and analysis. The push-based architecture ensures reliable data delivery even during network interruptions through Telegraf's built-in buffering and retry mechanisms.
This combination is ideal for infrastructure teams, DevOps engineers, and system administrators who need comprehensive monitoring without the complexity of agent-server architectures like Prometheus. Organizations running hybrid environments, IoT deployments, or custom applications benefit from Telegraf's extensive plugin ecosystem and InfluxDB's flexible querying capabilities through both InfluxQL and Flux languages, making it particularly valuable for teams requiring both operational monitoring and business analytics from the same data store.
Key Features
- 300+ input plugins including Docker containers, system metrics, SNMP devices, databases, message queues, and cloud services
- Native InfluxDB line protocol integration with automatic schema creation and tag/field optimization
- Built-in data processing with aggregation, transformation, and filtering processors before storage
- Automatic service discovery for dynamic environments including Docker, Kubernetes, and cloud platforms
- Multiple output destinations supporting simultaneous writes to InfluxDB, Prometheus, Kafka, and other systems
- InfluxDB 2.0 organization and bucket-based data isolation with token-based authentication
- Flux query language support for advanced analytics, predictions, and cross-measurement joins
- Configurable data retention policies and downsampling for long-term storage optimization
Common Use Cases
- 1Infrastructure monitoring for servers, containers, and network devices with centralized metrics storage
- 2IoT sensor data collection and analysis for manufacturing, environmental monitoring, or smart building systems
- 3Application performance monitoring with custom metrics, database query times, and business KPIs
- 4DevOps pipeline monitoring including build times, deployment frequencies, and error rates
- 5Network monitoring through SNMP polling of switches, routers, and other network infrastructure
- 6Database performance tracking for MySQL, PostgreSQL, MongoDB, and other database systems
- 7Cloud resource monitoring across AWS, Azure, and GCP with cost and utilization metrics
Prerequisites
- Minimum 1GB RAM for InfluxDB with additional memory scaling based on cardinality and retention periods
- Port 8086 available for InfluxDB HTTP API and web interface access
- Docker socket access (/var/run/docker.sock) mounted for container monitoring capabilities
- Understanding of time-series concepts including tags, fields, and measurement schemas for optimal data modeling
- Telegraf configuration knowledge for input/output plugin setup and metric collection intervals
- Network connectivity from monitored systems to Telegraf agent for remote monitoring scenarios
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 influxdb: 3 image: influxdb:24 container_name: influxdb5 restart: unless-stopped6 environment: 7 DOCKER_INFLUXDB_INIT_MODE: setup8 DOCKER_INFLUXDB_INIT_USERNAME: admin9 DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_PASSWORD}10 DOCKER_INFLUXDB_INIT_ORG: myorg11 DOCKER_INFLUXDB_INIT_BUCKET: telegraf12 volumes: 13 - influxdb_data:/var/lib/influxdb214 ports: 15 - "8086:8086"16 networks: 17 - telegraf-network1819 telegraf: 20 image: telegraf:latest21 container_name: telegraf22 restart: unless-stopped23 volumes: 24 - ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro25 - /var/run/docker.sock:/var/run/docker.sock:ro26 depends_on: 27 - influxdb28 networks: 29 - telegraf-network3031volumes: 32 influxdb_data: 3334networks: 35 telegraf-network: 36 driver: bridge.env Template
.env
1INFLUXDB_PASSWORD=changeme123Usage Notes
- 1Docs: https://docs.influxdata.com/telegraf/
- 2InfluxDB UI at http://localhost:8086 - admin/INFLUXDB_PASSWORD
- 3Create ./telegraf/telegraf.conf or generate: telegraf config > telegraf.conf
- 4300+ input plugins: system stats, Docker, SNMP, databases, etc.
- 5Output to InfluxDB, Prometheus, Kafka, and many more
- 6TICK stack component - pairs with InfluxDB, Chronograf, Kapacitor
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
influxdb
influxdb:
image: influxdb:2
container_name: influxdb
restart: unless-stopped
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: admin
DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_PASSWORD}
DOCKER_INFLUXDB_INIT_ORG: myorg
DOCKER_INFLUXDB_INIT_BUCKET: telegraf
volumes:
- influxdb_data:/var/lib/influxdb2
ports:
- "8086:8086"
networks:
- telegraf-network
telegraf
telegraf:
image: telegraf:latest
container_name: telegraf
restart: unless-stopped
volumes:
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
- influxdb
networks:
- telegraf-network
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 influxdb:5 image: influxdb:26 container_name: influxdb7 restart: unless-stopped8 environment:9 DOCKER_INFLUXDB_INIT_MODE: setup10 DOCKER_INFLUXDB_INIT_USERNAME: admin11 DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_PASSWORD}12 DOCKER_INFLUXDB_INIT_ORG: myorg13 DOCKER_INFLUXDB_INIT_BUCKET: telegraf14 volumes:15 - influxdb_data:/var/lib/influxdb216 ports:17 - "8086:8086"18 networks:19 - telegraf-network2021 telegraf:22 image: telegraf:latest23 container_name: telegraf24 restart: unless-stopped25 volumes:26 - ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro27 - /var/run/docker.sock:/var/run/docker.sock:ro28 depends_on:29 - influxdb30 networks:31 - telegraf-network3233volumes:34 influxdb_data:3536networks:37 telegraf-network:38 driver: bridge39EOF4041# 2. Create the .env file42cat > .env << 'EOF'43INFLUXDB_PASSWORD=changeme12344EOF4546# 3. Start the services47docker compose up -d4849# 4. View logs50docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/telegraf/run | bashTroubleshooting
- Error 'database not found' or 401 authentication: Verify InfluxDB initialization completed and bucket 'telegraf' exists with correct token permissions
- High memory usage in InfluxDB: Check metric cardinality using SHOW CARDINALITY and avoid high-cardinality tags like timestamps or UUIDs
- Telegraf metrics not appearing: Verify telegraf.conf output configuration matches InfluxDB organization/bucket and check Telegraf logs for connection errors
- Permission denied accessing Docker socket: Ensure telegraf container user has docker group membership or run with appropriate privileges
- Clock synchronization errors: Verify system clocks are synchronized between Telegraf agents and InfluxDB as time skew affects data ingestion
- Plugin-specific errors in logs: Check plugin documentation for required permissions, credentials, or network access to monitored services
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
telegrafinfluxdb
Tags
#telegraf#metrics#influxdb#agent#plugins
Category
Monitoring & ObservabilityAd Space
Shortcuts: C CopyF FavoriteD Download