Custom OpenSearch Dashboards Packaging Guide: Building from Source with Custom Plugins
This comprehensive guide covers building OpenSearch Dashboards from source with custom plugins and creating custom Debian packages for deployment. Whether you need to integrate custom visualizations or modify the core functionality, this guide provides multiple approaches for packaging OpenSearch Dashboards.
Table of Contents
Overview
Why Custom Packaging?
Custom packaging of OpenSearch Dashboards provides several advantages:
- Custom Plugin Integration: Include proprietary or custom-developed plugins
- Configuration Control: Pre-configure dashboards with specific settings
- Security Hardening: Apply security patches or customizations
- Resource Optimization: Remove unnecessary components or add optimizations
- Enterprise Deployment: Create standardized packages for enterprise environments
Build Methods
- Standard Build: Using OpenSearch’s built-in build system
- Manual Packaging: Creating Debian packages from scratch
- Custom Plugin Build: Including additional plugins in the build
Prerequisites
System Requirements
# Minimum requirements for building OpenSearch Dashboards# - CPU: 8+ cores (16+ recommended)# - RAM: 16GB+ (32GB recommended)# - Disk: 50GB+ free space# - OS: Ubuntu 20.04+ or compatible Linux distribution
# Install essential build dependenciessudo apt-get updatesudo apt-get install -y \ git \ curl \ wget \ build-essential \ nodejs \ npm \ ruby \ ruby-dev \ rpm \ python3 \ python3-pip \ dpkg-dev \ debhelper
Node.js Version Management
OpenSearch Dashboards requires specific Node.js versions:
# Install nvm (Node Version Manager)curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bashsource ~/.bashrc
# The .nvmrc file in the repository specifies the required Node.js version# This will be used automatically when you run nvm use
Development Tools
# Install Yarn package managernpm install -g yarn
# Install additional build toolsnpm install -g node-gyp
Standard Build Process
1. Source Code Preparation
# Clone OpenSearch Dashboards repositorygit clone https://github.com/opensearch-project/OpenSearch-Dashboards.gitcd OpenSearch-Dashboards
# Checkout specific version (2.18.0 in this example)git checkout 2.18.0
# Use the required Node.js versionnvm install $(cat .nvmrc)nvm use $(cat .nvmrc)
# Verify Node.js versionnode --versionnpm --version
2. Dependency Installation
# Install dependencies using Yarnyarn install
# Alternative: Use npm if preferred# npm install
# Bootstrap plugins (this process can take 30+ minutes)yarn osd bootstrap
3. Custom Plugin Integration (Pre-Build)
If you have custom plugins to include:
# Create plugins directory if it doesn't existmkdir -p plugins
# Copy your custom pluginscp -r /path/to/your/custom/plugins/* plugins/
# Example plugin structure:# plugins/# ├── my-custom-plugin/# │ ├── package.json# │ ├── public/# │ ├── server/# │ └── kibana.json
# Install plugin dependenciescd plugins/my-custom-pluginyarn installcd ../..
4. Build Process
# Build OpenSearch Dashboards (this can take 1+ hours)yarn build --skip-os-packages
# Alternative: Build with OS packagesyarn build --deb
# The built files will be in:# - build/opensearch-dashboards/ (application files)# - build/opensearch-dashboards-*.deb (if building packages)
Manual Debian Package Creation
1. Package Structure Setup
# Create package directory structuremkdir -p opensearch-dashboards-2.18.0/DEBIANmkdir -p opensearch-dashboards-2.18.0/usr/share/opensearch-dashboardsmkdir -p opensearch-dashboards-2.18.0/etc/opensearch-dashboardsmkdir -p opensearch-dashboards-2.18.0/var/log/opensearch-dashboardsmkdir -p opensearch-dashboards-2.18.0/var/lib/opensearch-dashboardsmkdir -p opensearch-dashboards-2.18.0/lib/systemd/system
# Set proper ownership for package buildingsudo chown -R $USER:$USER opensearch-dashboards-2.18.0/
2. Copy Built Application
# Copy built application filescp -r build/opensearch-dashboards/* opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards/
# Create directory structure in the packagemkdir -p opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards/{bin,config,plugins,data}
# Ensure proper permissions for executableschmod +x opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards/bin/*
3. Create Package Control Files
Control File
cat > opensearch-dashboards-2.18.0/DEBIAN/control << 'EOF'Package: opensearch-dashboardsVersion: 2.18.0-custom1Section: webPriority: optionalArchitecture: amd64Depends: libnss3, libatk-bridge2.0-0, libgtk-3-0, libx11-xcb1, libxcomposite1, libxcursor1, libxdamage1, libxi6, libxtst6, libasound2Maintainer: Your Organization <admin@yourorg.com>Description: OpenSearch Dashboards with custom plugins Custom build of OpenSearch Dashboards including specific plugins and configurations for enterprise deployment. . OpenSearch Dashboards is a data visualization dashboard for OpenSearch.Installed-Size: 1048576EOF
Pre-installation Script
cat > opensearch-dashboards-2.18.0/DEBIAN/preinst << 'EOF'#!/bin/bashset -e
# Create opensearch-dashboards group if it doesn't existif ! getent group opensearch-dashboards >/dev/null; then groupadd -r opensearch-dashboardsfi
# Create opensearch-dashboards user if it doesn't existif ! getent passwd opensearch-dashboards >/dev/null; then useradd -r -g opensearch-dashboards -d /usr/share/opensearch-dashboards \ -s /sbin/nologin -c "OpenSearch Dashboards Service User" opensearch-dashboardsfi
# Create necessary directoriesmkdir -p /var/log/opensearch-dashboardsmkdir -p /var/lib/opensearch-dashboardsmkdir -p /etc/opensearch-dashboards
exit 0EOF
Post-installation Script
cat > opensearch-dashboards-2.18.0/DEBIAN/postinst << 'EOF'#!/bin/bashset -e
# Set ownership and permissionschown -R opensearch-dashboards:opensearch-dashboards /usr/share/opensearch-dashboardschown -R opensearch-dashboards:opensearch-dashboards /var/log/opensearch-dashboardschown -R opensearch-dashboards:opensearch-dashboards /var/lib/opensearch-dashboardschown -R opensearch-dashboards:opensearch-dashboards /etc/opensearch-dashboards
# Set directory permissionschmod 750 /usr/share/opensearch-dashboardschmod 750 /var/log/opensearch-dashboardschmod 750 /var/lib/opensearch-dashboardschmod 750 /etc/opensearch-dashboards
# Set file permissionschmod 755 /usr/share/opensearch-dashboards/bin/opensearch-dashboardschmod 755 /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin
# Configure systemd servicesystemctl daemon-reloadsystemctl enable opensearch-dashboards.service
# Create data directory symlink if it doesn't existif [ ! -L /usr/share/opensearch-dashboards/data ]; then ln -sf /var/lib/opensearch-dashboards /usr/share/opensearch-dashboards/datafi
echo "OpenSearch Dashboards installed successfully."echo "Configuration file: /etc/opensearch-dashboards/opensearch_dashboards.yml"echo "Start service: sudo systemctl start opensearch-dashboards"
exit 0EOF
Pre-removal Script
cat > opensearch-dashboards-2.18.0/DEBIAN/prerm << 'EOF'#!/bin/bashset -e
# Stop service if runningif systemctl is-active --quiet opensearch-dashboards; then systemctl stop opensearch-dashboardsfi
# Disable serviceif systemctl is-enabled --quiet opensearch-dashboards; then systemctl disable opensearch-dashboardsfi
exit 0EOF
4. Create Configuration Files
Default Configuration
# Copy default configurationcp config/opensearch_dashboards.yml opensearch-dashboards-2.18.0/etc/opensearch-dashboards/
# Add custom paths to configurationcat >> opensearch-dashboards-2.18.0/etc/opensearch-dashboards/opensearch_dashboards.yml << 'EOF'
# Custom paths for packaged installationpath.data: /var/lib/opensearch-dashboardslogging.dest: /var/log/opensearch-dashboards/opensearch_dashboards.log
# Security settingsserver.ssl.enabled: falseopensearch.ssl.verificationMode: none
# Custom branding (if applicable)opensearchDashboards.branding.mark: "data:image/svg+xml;base64,..."opensearchDashboards.branding.title: "Custom OpenSearch Dashboards"EOF
Systemd Service File
cat > opensearch-dashboards-2.18.0/lib/systemd/system/opensearch-dashboards.service << 'EOF'[Unit]Description=OpenSearch DashboardsDocumentation=https://opensearch.org/docs/dashboardsWants=network-online.targetAfter=network-online.targetRequiresMountsFor=/var/lib/opensearch-dashboards
[Service]Type=simpleUser=opensearch-dashboardsGroup=opensearch-dashboardsEnvironment=NODE_ENV=productionEnvironment=CONFIG_PATH=/etc/opensearch-dashboards/opensearch_dashboards.ymlEnvironment=NODE_OPTIONS="--max-old-space-size=4096"ExecStart=/usr/share/opensearch-dashboards/bin/opensearch-dashboardsRestart=alwaysRestartSec=3StartLimitBurst=3StartLimitInterval=60TimeoutStopSec=30KillMode=mixedKillSignal=SIGTERM
# Security settingsNoNewPrivileges=trueProtectSystem=strictProtectHome=trueReadWritePaths=/var/lib/opensearch-dashboardsReadWritePaths=/var/log/opensearch-dashboardsPrivateTmp=trueProtectKernelTunables=trueProtectControlGroups=trueRestrictSUIDSGID=true
# Resource limitsLimitNOFILE=65536LimitMEMLOCK=infinity
[Install]WantedBy=multi-user.targetEOF
5. Make Scripts Executable
# Make maintainer scripts executablechmod 755 opensearch-dashboards-2.18.0/DEBIAN/preinstchmod 755 opensearch-dashboards-2.18.0/DEBIAN/postinstchmod 755 opensearch-dashboards-2.18.0/DEBIAN/prerm
6. Build the Package
# Build the Debian packagedpkg-deb --build opensearch-dashboards-2.18.0
# Verify packagedpkg-deb --info opensearch-dashboards-2.18.0.debdpkg-deb --contents opensearch-dashboards-2.18.0.deb
# Check package with Lintian (optional)lintian opensearch-dashboards-2.18.0.deb
Custom Plugin Integration
Plugin Development Structure
# Example custom plugin structuremkdir -p plugins/my-security-plugin
cat > plugins/my-security-plugin/package.json << 'EOF'{ "name": "my-security-plugin", "version": "2.18.0", "description": "Custom security visualization plugin", "main": "index.js", "opensearchDashboardsVersion": "2.18.0", "dependencies": { "react": "^16.14.0", "react-dom": "^16.14.0" }}EOF
cat > plugins/my-security-plugin/opensearch_dashboards.json << 'EOF'{ "id": "mySecurityPlugin", "version": "2.18.0", "opensearchDashboardsVersion": "2.18.0", "server": true, "ui": true, "requiredPlugins": ["data", "navigation"], "optionalPlugins": []}EOF
Plugin Build Integration
# Build plugins during the main build processyarn osd bootstrap
# Verify plugin is includedls -la build/opensearch-dashboards/plugins/
Build Optimization
Performance Optimization
# Set Node.js memory limits for large buildsexport NODE_OPTIONS="--max-old-space-size=8192"
# Use parallel builds where possibleexport JOBS=8
# Optimize build for productionyarn build --skip-os-packages --skip-archives --release
Size Optimization
# Remove development dependencies from final packagecd opensearch-dashboards-2.18.0/usr/share/opensearch-dashboardsfind . -name "node_modules" -type d -exec rm -rf {} + 2>/dev/null || truefind . -name "*.map" -deletefind . -name "*.ts" -deletefind . -name "*.spec.js" -deletefind . -name "*.test.js" -delete
# Compress assetsfind . -name "*.js" -exec gzip -9 {} \; -exec mv {}.gz {} \;
Security Hardening
# Remove potentially sensitive filesrm -rf opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards/.git*rm -rf opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards/test/rm -rf opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards/docs/
# Set secure permissionsfind opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards -type f -exec chmod 644 {} \;find opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards -type d -exec chmod 755 {} \;chmod 755 opensearch-dashboards-2.18.0/usr/share/opensearch-dashboards/bin/*
Deployment and Testing
Installation Testing
# Install the custom packagesudo dpkg -i opensearch-dashboards-2.18.0.deb
# Fix any dependency issuessudo apt-get install -f
# Start the servicesudo systemctl start opensearch-dashboards
# Check service statussudo systemctl status opensearch-dashboards
# Verify web interface (default port 5601)curl -s http://localhost:5601/api/status | jq .
Validation Scripts
#!/bin/bashecho "=== OpenSearch Dashboards Installation Validation ==="
# Check service statusif systemctl is-active --quiet opensearch-dashboards; then echo "✓ Service is running"else echo "✗ Service is not running" exit 1fi
# Check port bindingif netstat -tlnp | grep -q :5601; then echo "✓ Port 5601 is bound"else echo "✗ Port 5601 is not bound" exit 1fi
# Check API responseif curl -s -f http://localhost:5601/api/status >/dev/null; then echo "✓ API is responding"else echo "✗ API is not responding" exit 1fi
# Check custom pluginsif curl -s http://localhost:5601/api/plugins | grep -q "mySecurityPlugin"; then echo "✓ Custom plugins loaded"else echo "⚠ Custom plugins not detected"fi
# Check log filesif [ -f /var/log/opensearch-dashboards/opensearch_dashboards.log ]; then echo "✓ Log file exists" if grep -q "Server running at" /var/log/opensearch-dashboards/opensearch_dashboards.log; then echo "✓ Successful startup logged" else echo "⚠ No startup confirmation in logs" fielse echo "✗ Log file not found"fi
echo "=== Validation Complete ==="
Automated Build Script
#!/bin/bashset -e
VERSION="2.18.0"CUSTOM_VERSION="${VERSION}-custom$(date +%Y%m%d)"BUILD_DIR="/tmp/opensearch-dashboards-build"PLUGINS_DIR="/path/to/custom/plugins"
echo "Building OpenSearch Dashboards ${CUSTOM_VERSION}"
# Cleanup previous buildsrm -rf "$BUILD_DIR"mkdir -p "$BUILD_DIR"cd "$BUILD_DIR"
# Clone and checkoutgit clone https://github.com/opensearch-project/OpenSearch-Dashboards.gitcd OpenSearch-Dashboardsgit checkout "$VERSION"
# Setup Node.jsnvm use $(cat .nvmrc)
# Copy custom pluginsif [ -d "$PLUGINS_DIR" ]; then cp -r "$PLUGINS_DIR"/* plugins/fi
# Install dependenciesyarn installyarn osd bootstrap
# Buildyarn build --skip-os-packages --release
# Create packagecd .../create-debian-package.sh "$CUSTOM_VERSION"
echo "Build complete: opensearch-dashboards-${CUSTOM_VERSION}.deb"
Troubleshooting
Common Build Issues
Memory Issues:
# Increase Node.js heap sizeexport NODE_OPTIONS="--max-old-space-size=16384"
# Monitor memory usage during buildwatch -n 1 'free -h && ps aux | grep node'
Permission Issues:
# Fix ownershipsudo chown -R $USER:$USER .
# Fix permissionsfind . -type f -exec chmod 644 {} \;find . -type d -exec chmod 755 {} \;
Plugin Conflicts:
# Clean plugin cacherm -rf plugins/*/node_modulesyarn osd bootstrap --force
# Debug plugin loadingnode --trace-warnings scripts/opensearch_dashboards --verbose
Package Installation Issues
Service Won’t Start:
# Check service logsjournalctl -u opensearch-dashboards -f
# Verify configurationopensearch-dashboards --config /etc/opensearch-dashboards/opensearch_dashboards.yml --help
# Check permissionsls -la /var/lib/opensearch-dashboardsls -la /var/log/opensearch-dashboards
Port Conflicts:
# Check what's using port 5601sudo netstat -tlnp | grep 5601sudo lsof -i :5601
# Change port in configurationecho "server.port: 5602" >> /etc/opensearch-dashboards/opensearch_dashboards.yml
Best Practices
Security Considerations
- Regular Updates: Keep base OpenSearch Dashboards updated
- Plugin Vetting: Audit all custom plugins for security vulnerabilities
- Access Control: Implement proper authentication and authorization
- Network Security: Use HTTPS and proper firewall rules
- Monitoring: Implement logging and monitoring for security events
Performance Optimization
- Resource Allocation: Allocate sufficient CPU and memory
- Caching: Configure appropriate caching strategies
- Index Management: Optimize OpenSearch indices
- Load Balancing: Use load balancers for high availability
- Monitoring: Monitor performance metrics and optimize accordingly
Maintenance Procedures
- Backup Strategy: Regular backups of configurations and customizations
- Update Process: Establish procedures for updating custom packages
- Testing: Comprehensive testing before production deployment
- Documentation: Maintain detailed documentation of customizations
- Rollback Plan: Prepare rollback procedures for failed deployments
Conclusion
Custom packaging of OpenSearch Dashboards enables organizations to deploy tailored solutions that meet specific requirements while maintaining control over the build and deployment process. Whether you need custom plugins, specific configurations, or enterprise-grade packaging, the approaches outlined in this guide provide a solid foundation for creating and deploying custom OpenSearch Dashboards packages.
Key takeaways:
- Plan your customizations carefully before building
- Test thoroughly in development environments
- Implement proper security measures throughout the process
- Maintain detailed documentation of customizations
- Establish reliable build and deployment pipelines
With proper implementation, custom OpenSearch Dashboards packages can provide significant value for organizations requiring specialized functionality or deployment requirements.