Black Duck scan heatmap metrics analyzer with interactive visualizations
Project description
Black Duck Heatmap Metrics Analyzer
A Python-based tool for analyzing Black Duck scan metrics from CSV files in zip archives. Generates interactive HTML dashboards with time series analysis, scan type evolution tracking, and year-based filtering.
Prerequisites
Exporting Heatmap Data from Black Duck
Before using this tool, you need to export the heatmap data from your Black Duck server:
-
Access Black Duck Administration
- Log in to your Black Duck server as an administrator
- Navigate to System โ Log Files
-
Download Heatmap Logs
- In the Log Files section, locate the Heatmap logs
- Select the time period you want to analyze
- Click Download to export the data as a ZIP archive
- The downloaded file will contain CSV files with scan metrics
-
Use the Downloaded ZIP
- Save the downloaded ZIP file (e.g.,
heatmap-data.zip) - Use this ZIP file as input to the
bdmetricscommand
- Save the downloaded ZIP file (e.g.,
๐ Detailed Instructions: Black Duck Documentation - Downloading Log Files
Features
- ๐ฆ Zip Archive Support: Reads CSV files directly from zip archives
- ๐ Interactive Charts: Plotly-powered visualizations with hover details
- ๐ฏ Black Duck Specific: Tailored for Black Duck scan heatmap data
- ๐ Multi-level Filtering: Filter by file, year, and project
- ๐ Scan Type Analysis: Track scan type distribution and evolution over time
- โ Success/Failure Metrics: Monitor scan success rates
- ๐จ Professional Theme: Blue gradient design matching Coverity on Polaris
- ๐ฑ Responsive Design: Works on desktop and mobile devices
- ๐ Performance Optimized: Configurable min-scans threshold and skip-detailed mode for large datasets
- ๐ Dual Report Generation: Creates both full (with filters) and simplified (year-only) reports
Installation
From Source
- Clone or download this repository
- Install the package:
# Install in development mode (recommended for development)
pip install -e .
# Or install normally
pip install .
Using pip (once published to PyPI)
pip install blackduck-heatmap-metrics
Usage
After installation, you can use the bdmetrics command from anywhere:
bdmetrics path/to/your/heatmap-data.zip
Or use it as a Python module:
from blackduck_metrics import read_csv_from_zip, analyze_data, generate_chart_data, generate_html_report
# Read data
dataframes = read_csv_from_zip("path/to/heatmap-data.zip")
# Analyze
analysis = analyze_data(dataframes)
chart_data = generate_chart_data(dataframes)
# Generate report
generate_html_report(analysis, chart_data, "output_report.html")
Command-Line Examples
# Basic usage - generates report with default settings
bdmetrics "C:\Users\JouniLehto\Downloads\heatmap-data.zip"
# Specify output file
bdmetrics "path/to/data.zip" -o custom_report.html
# Set minimum scans threshold (default: 10)
# Only projects with 50+ scans will appear in trend charts
bdmetrics "path/to/data.zip" --min-scans 50
# Skip detailed year+project combinations for faster processing and smaller files
# Recommended for large datasets (reduces file size by ~36%)
bdmetrics "path/to/data.zip" --skip-detailed
# Combine options for optimal performance with large datasets
bdmetrics "path/to/data.zip" --min-scans 100 --skip-detailed -o report.html
# Show version
bdmetrics --version
# Show help
bdmetrics --help
Performance Optimization
For large datasets with thousands of projects:
- Use
--min-scansto filter out low-activity projects from trend charts (default: 10) - Use
--skip-detailedto skip year+project combination charts (saves ~36% file size) - Example: Dataset with 37,706 projects โ 7,261 projects (--min-scans 100) โ 282 MB vs 456 MB baseline
Legacy Usage (if using main.py directly)
python main.py "path/to/your/heatmap-data.zip"
Example
python main.py "heatmap-data.zip"
This will:
- Extract and read all CSV files from the zip archive
- Analyze Black Duck scan metrics
- Generate an interactive HTML report as
report_YYYYMMDD_HHMMSS.html
CSV Data Format
The tool expects CSV files with the following columns:
hour: Timestamp of the scancodeLocationId: Unique identifier for code locationcodeLocationName: Name of the code locationversionName: Version being scannedprojectName: Name of the projectscanCount: Number of scansscanType: Type of scan (e.g., SIGNATURE, BINARY_ANALYSIS)totalScanSize: Total size of the scanmaxScanSize: Maximum scan sizestate: Scan state (COMPLETED, FAILED, etc.)transitionReason: Reason for state transition
Report Features
The generated HTML dashboard includes:
Dual Report Generation
Each run generates two reports:
- Full Report (
report_YYYYMMDD_HHMMSS.html): Complete filtering capabilities - Simple Report (
report_YYYYMMDD_HHMMSS_simple.html): Year-only filtering for quick overview
Summary Section
- Total Files Processed: Number of CSV files analyzed
- Total Records: Number of scan records
- Unique Projects: Count of distinct projects
- Total Scans: Total number of scans
- Successful Scans: Number of completed scans
- Failed Scans: Number of failed scans
- Success Rate: Percentage of successful scans
Interactive Filters (Full Report)
- File Selector: Filter by specific CSV file
- Year Selector: Filter all data and charts by year
- Project Search: Type-ahead project search with dynamic filtering
- Clear Filters: Reset all filters to show all data
Interactive Filters (Simple Report)
- Year Selector: Filter all data and charts by year only
Charts and Visualizations
-
Scan Activity Over Time
- Line chart showing number of scans over time
- Total scan size trends
- Filters by year, project, and file
-
Top Projects by Scan Count
- Horizontal bar chart of top 20 projects
- Updates based on filter selection
-
Scan Type Distribution
- Pie chart showing breakdown of scan types
- Updates based on year/project selection
-
Scan Type Evolution Over Time
- Multi-line time series chart
- Interactive checkbox selection for scan types
- Track how different scan types have evolved
- Smart error messages when data unavailable (shows min-scans threshold)
- Automatically updates when filters change
Smart Error Messages
The tool provides context-aware messages when data is unavailable:
- "No trend data for this project (project has less than X scans)" - when project doesn't meet min-scans threshold
- "Year+Project combination data not available" - when --skip-detailed flag was used
Black Duck Overview
- Scan type breakdown with counts
- State distribution
- Filterable statistics
Requirements
- Python 3.7+
- pandas >= 2.0.0
- jinja2 >= 3.1.0
- plotly >= 5.18.0
Project Structure
blackduck_heatmap_metrics/
โโโ blackduck_metrics/
โ โโโ __init__.py # Package initialization
โ โโโ analyzer.py # Core data analysis and report generation
โ โโโ cli.py # Command-line interface
โ โโโ templates/
โ โโโ template.html # Full report template (all filters)
โ โโโ template_simple.html # Simple report template (year filter only)
โโโ main.py # Legacy entry point
โโโ template.html # Root template for development
โโโ template_simple.html # Root simple template for development
โโโ setup.py # Package installation script
โโโ pyproject.toml # Project metadata
โโโ requirements.txt # Python dependencies
โโโ MANIFEST.in # Package manifest
โโโ README.md # This file
How It Works
- Data Extraction: Reads CSV files from zip archive using pandas
- Time-based Analysis: Parses timestamps and groups data by year and project
- Aggregation: Calculates statistics per file, year, project, and year+project combinations
- Chart Generation: Prepares optimized data structures for Plotly visualizations
- Applies min-scans threshold to filter low-activity projects
- Optionally skips year+project combinations for performance
- Reduces data sampling for large datasets (time series: 200 points, scan type evolution: 100 points)
- Template Rendering: Jinja2 combines data with both full and simple HTML templates
- Output: Generates two timestamped HTML files with embedded charts
Customization
Template Styling
Edit templates in blackduck_metrics/templates/:
template.html- Full report with all filterstemplate_simple.html- Simple report with year filter only- Customize: Color scheme (blue gradient), chart types, layouts, summary cards, fonts
Data Analysis
Modify blackduck_metrics/analyzer.py to:
- Add new aggregations
- Include additional metrics
- Change chart data calculations
- Adjust min-scans thresholds
- Modify data sampling rates
- Adjust filtering logic
Output Files
Each run generates two reports with timestamp-based filenames:
Full Report (with all filters)
- Format:
report_YYYYMMDD_HHMMSS.html - Example:
report_20260119_171725.html - Features: File, year, and project filtering
Simple Report (year-only filtering)
- Format:
report_YYYYMMDD_HHMMSS_simple.html - Example:
report_20260119_171725_simple.html - Features: Year filtering only, faster to load
Both reports are:
- Standalone HTML files (no external dependencies except Plotly CDN)
- Self-contained with embedded data and charts
- Shareable - can be opened directly in any modern browser
Browser Compatibility
The generated reports work in all modern browsers:
- Chrome/Edge (recommended)
- Firefox
- Safari
- Opera
Requires JavaScript enabled for interactive features.
Troubleshooting
No charts showing
- Check browser console (F12) for JavaScript errors
- Ensure Plotly CDN is accessible
- Verify CSV data has the expected columns
Charts show "No trend data for this project (project has less than X scans)"
- This is normal for projects with few scans
- Adjust
--min-scansthreshold if needed (default: 10) - Click "Clear Filters" to see all data
Charts not updating after filter selection
- Ensure JavaScript is enabled
- Try refreshing the page
- Check browser console for errors
"Year+Project combination data not available" message
- Report was generated with
--skip-detailedflag - Regenerate without this flag for full year+project filtering
- This is normal for optimized reports
Report file too large
- Use
--min-scans 50or higher to reduce projects in charts - Use
--skip-detailedto skip year+project combinations (~36% size reduction) - Example: 456 MB โ 282 MB with --min-scans 100 --skip-detailed
Year filter not working
- Ensure
hourcolumn contains valid timestamps - Check that data spans multiple years
Charts show "No data available"
- Verify CSV files contain the required columns
- Check for empty or malformed data
- Ensure project has sufficient scans (check min-scans threshold)
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blackduck_heatmap_metrics-0.1.7.tar.gz.
File metadata
- Download URL: blackduck_heatmap_metrics-0.1.7.tar.gz
- Upload date:
- Size: 64.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04e2cdd16980899a5ad20ab9372b7803c3a1d929fce946b6b12ad61b1fb042e9
|
|
| MD5 |
750f9ebf1450bdfd73f9e121c5c45a02
|
|
| BLAKE2b-256 |
29e31280ebe2bff2304b0ec8dff6c3aef07c1be01fe03fcc2698e55de1365e80
|
File details
Details for the file blackduck_heatmap_metrics-0.1.7-py3-none-any.whl.
File metadata
- Download URL: blackduck_heatmap_metrics-0.1.7-py3-none-any.whl
- Upload date:
- Size: 37.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7694a8bb58c0add15c30e8eda533a0d9fb2f34e277bf8fdc7c99434115d55da9
|
|
| MD5 |
c0b9172a9a831fd0f66685a15e7dfa53
|
|
| BLAKE2b-256 |
69c662eadfc46a79ed1b476de6fc3a2fdf4d55c951e59f64959ac98fa45746e6
|