Skip to content

flipkart-incubator/prometheus-dashboard-porter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dash-Porter

A CLI tool to migrate Grafana dashboards from OpenTSDB to Prometheus data sources.

Overview

Dash-Porter helps convert existing Grafana dashboards that use OpenTSDB as a data source to use Prometheus instead. It handles dashboard migration and can create Prometheus datasources in your target Grafana instance.

Features

  • Dashboard Migration: Convert dashboards from OpenTSDB to Prometheus format
  • Datasource Management: Create new Prometheus datasources
  • Flipkart Mode: Optional enterprise-specific functionality via --flipkart flag
  • Authentication Support: Works with API key, basic auth, or public Grafana instances
  • Dry Run Mode: Preview changes without applying them

Installation

Build from Source

# Clone the repository
git clone <repository-url>
cd prometheus-dashboard-porter

# Build the application
go build -o dash-porter

# Run the application
./dash-porter --help

Prerequisites

  • Source Grafana Instance: With OpenTSDB dashboards to migrate
  • Target Grafana Instance: Where Prometheus datasources will be created
  • Authentication: API keys or credentials for Grafana instances (if required)

Configuration

Create a config.yaml file with your Grafana instance details:

source:
  grafana_url: "https://source-grafana.example.com"
  auth:
    type: "api_key" # or "basic", "none" for public instances
    api_key: "your-source-api-key"

target:
  grafana_url: "https://target-grafana.example.com"
  prometheus_url: "http://prometheus.example.com:9090"
  auth:
    type: "api_key"
    api_key: "your-target-api-key"

Usage

Available Commands

The tool provides two main commands:

1. Migrate Dashboard

# Migrate a single dashboard by UID
./dash-porter migrate dashboard <dashboard-uid>

# With options
./dash-porter migrate dashboard <dashboard-uid> \
  --folder "target-folder" \
  --target-datasource "prometheus-ds"

# With Flipkart mode
./dash-porter --flipkart migrate dashboard <dashboard-uid>

# Dry run to preview changes
./dash-porter --dry-run migrate dashboard <dashboard-uid>

2. Create Datasource

# Create a new Prometheus datasource
./dash-porter datasource create <datasource-name>

# With custom Prometheus URL
./dash-porter datasource create <datasource-name> \
  --prometheus-url "http://prometheus:9090"

# Set as default datasource
./dash-porter datasource create <datasource-name> --default

# Dry run to preview
./dash-porter datasource create <datasource-name> --dry-run

Global Options

  • --config, -c: Configuration file path (default: config.yaml)
  • --dry-run, -d: Perform dry run without making changes
  • --verbose, -v: Enable verbose output
  • --flipkart: Enable Flipkart-specific functionality

Complete Workflow Examples

Standard Migration Workflow

# 1. Create the target datasource
./dash-porter datasource create "prometheus-main" \
  --prometheus-url "http://prometheus.company.com:9090" \
  --default

# 2. Migrate dashboards
./dash-porter migrate dashboard DASH-001 \
  --target-datasource "prometheus-main"

./dash-porter migrate dashboard DASH-002 \
  --target-datasource "prometheus-main"

Flipkart Multi-App Workflow

# 1. Create app-specific datasources
./dash-porter --flipkart datasource create "app1_hyd-1" \
  --prometheus-url "http://prom-hyd.company.com:9090"

./dash-porter --flipkart datasource create "app1_ch-2" \
  --prometheus-url "http://prom-ch.company.com:9090"

./dash-porter --flipkart datasource create "app2_hyd-1" \
  --prometheus-url "http://prom-hyd.company.com:9090"

# 2. Migrate Flipkart dashboards (auto-assigns correct datasources)
./dash-porter --flipkart migrate dashboard FLIPKART-DASH-001
./dash-porter --flipkart migrate dashboard FLIPKART-DASH-002

Configuration Options

Authentication Types

  • api_key: Standard Grafana API key authentication
  • basic: HTTP basic authentication (username/password)
  • none/public/"": No authentication (public instances)

Migration Settings

  • folder_prefix: Prefix for migrated dashboard folders
  • preserve_uids: Keep original dashboard UIDs
  • timeout: Operation timeout duration
  • show_null_values: Display null values in converted queries

Global Flags

  • --config: Specify config file path
  • --dry-run: Preview operations without executing
  • --verbose: Enable detailed logging
  • --flipkart: Enable Flipkart-specific functionality

Flipkart Integration

Metric Processing

  • Input Format: appid.metric_name (e.g., myapp.cpu_usage)
  • Output: Clean metric_name (e.g., cpu_usage)
  • Datasource: Automatic appid_zone assignment (e.g., myapp_hyd-1)

Zone Support

  • Default zones: hyd-1, ch-2
  • Zone detection from dashboard tags
  • Configurable zone mappings

Template Processing

  • Zone-based template variable updates
  • AppID extraction and processing
  • Datasource name generation

Configuration Details

Authentication Types

  • api_key: Use Grafana API key for authentication
  • basic: Use username/password basic authentication
  • none: For public Grafana instances (no authentication required)

Flipkart Mode

When using --flipkart flag, the tool enables enterprise-specific features:

  • Custom metric processing for Flipkart applications
  • Zone-based datasource management
  • Application-specific template handling

Development

Building

Build from source

go build -o dash-porter

Run tests (if any exist)

go test ./...


## Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

About

Tool to migrate Grafana OpenTSDB Dashboards to Prometheus Dashboards

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors