Candlestick Panels in Grafana
Introduction
Candlestick panels are specialized visualization tools in Grafana that display time-series data in a format similar to financial stock charts. Originally developed for financial market data, candlestick charts have become valuable for visualizing any time-series data that includes open, high, low, and close (OHLC) values over specific time intervals.
In this guide, we'll explore how to set up and use candlestick panels in Grafana, their key features, and practical applications beyond financial data.
What are Candlestick Charts?
Candlestick charts originated in Japan over 300 years ago for rice trading and have since become standard in financial markets. Each "candlestick" represents four data points within a time period:
- Open: The value at the start of the time period
- High: The highest value during the time period
- Low: The lowest value during the time period
- Close: The value at the end of the time period
Installing Candlestick Panels
Candlestick panels are available as a plugin in Grafana. To install:
- Navigate to Configuration → Plugins in your Grafana instance
- Search for "Candlestick"
- Click on the plugin and select "Install"
Alternatively, you can install via the Grafana CLI with:
grafana-cli plugins install grafana-candlestick-panel
After installation, restart your Grafana server to activate the plugin.
Setting Up Your First Candlestick Panel
Step 1: Create a New Dashboard and Panel
- In Grafana, click on "Create" → "Dashboard"
- Click "Add new panel"
- In the visualization options, select "Candlestick" from the visualization dropdown
Step 2: Configure Data Source
Your data needs to provide the OHLC values. You can use:
- Time-series databases like InfluxDB, Prometheus, or TimescaleDB
- SQL databases with time-series data
- CSV or JSON files with appropriate structure
Step 3: Query Configuration
Your queries need to return data for the open, high, low, and close values. Here's an example using InfluxDB:
SELECT
first("value") AS "open",
max("value") AS "high",
min("value") AS "low",
last("value") AS "close"
FROM "measurement"
WHERE $timeFilter
GROUP BY time($__interval)
Step 4: Panel Configuration
In the panel options:
- Map your query fields to the corresponding OHLC fields
- Configure colors for increasing and decreasing values
- Adjust candlestick width and spacing
- Configure tooltip options
Key Features and Options
Color Mapping
Candlesticks are typically colored based on whether the close value is higher or lower than the open value:
- Increasing (Bullish): Close > Open (Often green)
- Decreasing (Bearish): Close < Open (Often red)
You can customize these colors in the panel options:
// Example configuration (pseudocode)
panel.options = {
colorStrategy: 'close-open',
increasingColor: 'green',
decreasingColor: 'red'
}
Volume Display
Many candlestick panels support volume indicators displayed below the main chart:
- Enable the volume display in panel options
- Configure a separate query to return volume data
- Map the volume field in the panel options
Technical Indicators
Advanced candlestick panels support technical indicators such as:
- Moving Averages (MA)
- Relative Strength Index (RSI)
- Bollinger Bands
- MACD (Moving Average Convergence Divergence)
Enable these in the panel options and configure their parameters as needed.
Practical Examples
Example 1: System Resource Monitoring
Monitoring server CPU utilization with candlestick charts:
SELECT
first("cpu_usage") AS "open",
max("cpu_usage") AS "high",
min("cpu_usage") AS "low",
last("cpu_usage") AS "close"
FROM "server_metrics"
WHERE $timeFilter
GROUP BY time($__interval), "host"
This visualization helps identify:
- Volatility in resource usage (height of candles)
- Trends over time (sequence of candles)
- Sudden spikes vs. gradual changes
Example 2: IoT Sensor Data
For temperature sensors in different rooms:
SELECT
first("temperature") AS "open",
max("temperature") AS "high",
min("temperature") AS "low",
last("temperature") AS "close"
FROM "sensors"
WHERE $timeFilter
GROUP BY time($__interval), "room"
This helps visualize:
- Temperature fluctuations throughout the day
- Pattern recognition across different rooms
- Identification of anomalies
Advanced Customization
Adding Annotations
Annotations can mark significant events on your candlestick chart:
// In dashboard JSON configuration
annotations: {
list: [
{
name: "Deployments",
datasource: "InfluxDB",
query: "SELECT * FROM events WHERE type = 'deployment'",
iconColor: "rgba(255, 96, 96, 1)",
enable: true
}
]
}
Custom Tooltips
Enhance tooltips with additional information:
// In panel options (pseudocode)
tooltip: {
mode: 'multi',
sort: 2,
customizeText: true,
additionalFields: ['volume', 'moving_average']
}
Time Range Zooming
Implement zoom capabilities to focus on specific time periods:
- Enable time range zooming in panel options
- Use the built-in range selector
- Configure zoom behavior (drag to zoom, wheel zoom, etc.)
Troubleshooting Common Issues
Data Mapping Problems
If your candlesticks don't appear correctly:
- Verify your queries return all required OHLC fields
- Check that fields are mapped correctly in panel options
- Ensure time grouping is appropriate for your data density
Performance Optimization
For large datasets:
- Increase the minimum interval between data points
- Use data aggregation at the database level
- Limit the maximum number of data points
Display Issues
If candlesticks appear distorted:
- Adjust the width and spacing settings
- Check for extreme outliers in your data
- Verify time alignment across all OHLC values
Integration with Other Panels
Create a comprehensive dashboard by combining candlestick panels with:
- Gauge Panels: For current values
- Stat Panels: For key metrics
- Time Series Panels: For complementary trend views
- Table Panels: For detailed data points
Use template variables to synchronize the data shown across all panels.
Summary
Candlestick panels in Grafana provide a powerful way to visualize time-series data with open, high, low, and close values. While traditionally used for financial data, they offer valuable insights for system monitoring, IoT applications, and any scenario where understanding value fluctuations within time periods is important.
The key advantages of candlestick panels include:
- Visual representation of data volatility
- Clear indication of trends and patterns
- Compact display of multiple data points
- Rich configuration options for customization
Additional Resources
- Grafana Official Documentation
- Candlestick Panel Plugin Repository
- Time Series Visualization Best Practices
Exercises
- Create a candlestick panel to visualize CPU and memory usage on a server, with annotations marking deployment events.
- Build a dashboard combining candlestick panels with other visualization types to monitor a web application's performance.
- Use candlestick panels to track environmental variables (temperature, humidity, etc.) from multiple sensors, identifying patterns and anomalies.
- Implement technical indicators like moving averages on a candlestick panel to identify trends in your time-series data.
If you spot any mistakes on this website, please let me know at [email protected]. I’d greatly appreciate your feedback! :)