This project provides a fully automated solution for generating Kibana dashboards directly from a Swagger/OpenAPI specification. The script analyzes each controller (API scope) defined in the specification and produces a dedicated dashboard containing detailed monitoring panels for every endpoint. Each panel visualizes the API’s operational metrics, including the distribution of returned HTTP status codes, enabling teams to observe performance patterns, detect anomalies, and quickly identify reliability issues.
This tool eliminates the need for manual dashboard creation, ensures consistent observability across all services, and keeps monitoring aligned with API changes. It is especially useful for microservice environments where maintaining accurate dashboards manually is time-consuming and error-prone.
- swagger_kibana_analyzer.py - Analyzes existing dashboards to find unmonitored endpoints
- generate_dashboards.py - Generates new dashboards and visualizations for API monitoring
- swagger_parser.py - Parses Swagger/OpenAPI specifications
- endpoint_comparator.py - Compares and analyzes API endpoints
- models.py - Data models for API endpoints
- Swagger/OpenAPI Support: Reads both Swagger 2.0 and OpenAPI 3.0 JSON files (local files or URLs)
- Kibana Integration: Connects to Kibana via REST API to retrieve dashboards and visualizations
- Smart URL Extraction: Uses regex patterns to find API URLs in dashboard queries and visualizations
- Endpoint Comparison: Intelligently compares Swagger endpoints with dashboard URLs using path normalization
- Unmonitored Endpoint Detection: Identifies API endpoints not covered by existing dashboards
- Automatic Dashboard Creation: Generates Kibana dashboards grouped by API tags
- Status Code Monitoring: Creates visualizations for each HTTP status code (200, 400, 500, etc.)
- Controller-based Organization: Groups endpoints by Swagger controller into separate dashboards
- Elasticsearch Query Integration: Uses your specific log format and field structure
- Batch Processing: Processes all endpoints and creates comprehensive monitoring setup
- Flexible Authentication: Supports username/password and API key authentication for Kibana
- Detailed Reporting: Provides comprehensive JSON output with analysis results
- Modular Design: Separated components for easy customization and extension
- Install Python dependencies:
pip install -r requirements.txt# Generate dashboards for all API endpoints with api key
python generate_dashboards.py https://api.example.com/swagger.json http://localhost:5601 --api-key your-key
# With custom index pattern
python generate_dashboards.py swagger.json http://localhost:5601 --api-key your-key --index-pattern "api-logs-*"
# Save generation results
python generate_dashboards.py swagger.json http://localhost:5601 --api-key your-key --output generation_results.jsonpython swagger_kibana_analyzer.py swagger.json http://localhost:5601 --api-key your-key --output results.jsonpython swagger_kibana_analyzer.py swagger.json http://localhost:5601 --api-key your-key --verboseswagger_file: Path to the Swagger/OpenAPI JSON file or URL (e.g., https://api.example.com/swagger.json)kibana_url: Kibana URL (e.g., http://localhost:5601)--username: Kibana username (optional if using API key)--password: Kibana password (optional if using API key)--api-key: Kibana API key (alternative to username/password)--output: Output file for results in JSON format (optional)--verbose,-v: Enable verbose logging
The script outputs a JSON report with the following structure:
{
"total_endpoints": 150,
"monitored_endpoints": 120,
"unmonitored_endpoints": 30,
"dashboard_summary": {
"API Monitoring Dashboard": [
"/api/users",
"/api/orders",
"/api/products"
],
"Error Tracking Dashboard": [
"/api/auth/login",
"/api/auth/logout"
]
},
"unmonitored_endpoint_details": [
{
"path": "/api/admin/settings",
"method": "GET",
"operation_id": "getAdminSettings",
"summary": "Get admin settings",
"tags": ["admin"]
}
]
}- Reads Swagger/OpenAPI JSON files
- Extracts all API endpoints with their methods, paths, and metadata
- Handles both Swagger 2.0 (
basePath) and OpenAPI 3.0 (servers) formats
- Connects to Kibana using the Saved Objects API
- Retrieves all dashboards and their associated visualizations
- Extracts queries and configurations from visualizations
Uses multiple regex patterns to find API URLs in dashboard content:
- HTTP(S) URLs containing
/api/ - Relative API paths starting with
/api/ - JSON fields like
"path"and"url" - Configuration fields like
endpoint
- Normalizes paths by removing query parameters and trailing slashes
- Converts dynamic path segments (IDs, UUIDs) to generic placeholders
- Performs fuzzy matching to account for different URL formats
--api-key your-api-keyTo create an API key in Kibana:
- Go to Stack Management → API Keys
- Click "Create API Key"
- Set appropriate privileges
- Copy the generated key
- Verify Kibana URL is accessible
- Check authentication credentials
- Ensure Kibana API is enabled
- Verify user has permission to read dashboards
- Check if dashboards exist in the specified Kibana instance
- The script uses regex patterns to find URLs
- Complex query structures might not be detected
- Consider customizing the
url_patternsinDashboardAnalyzer
Customize the normalize_path method in EndpointComparator to handle specific path patterns in your API.
- Python 3.7+
- requests library
- Access to Kibana instance
- Valid Swagger/OpenAPI JSON file