Expand description
Copyright © 2025-2026 Wenze Wei. All Rights Reserved.
This file is part of DMSC. The DMSC project belongs to the Dunimd Team.
Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
§Grafana Integration Module
This module provides data structures for creating and managing Grafana dashboards and panels. It enables programmatic generation of Grafana dashboards with panels, queries, and layout information.
§Key Components
- DMSCGridPos: Represents the grid position of a panel on a dashboard
- DMSCGrafanaPanel: Represents a single Grafana panel with title, query, type, and position
- DMSCGrafanaDashboard: Represents a Grafana dashboard with multiple panels
§Design Principles
- Serde Integration: All structs implement Serialize and Deserialize for easy JSON conversion
- Simple API: Easy-to-use methods for creating dashboards and adding panels
- Layout Support: Built-in support for Grafana’s grid layout system
- Extensible: Can be extended to support additional panel types and dashboard features
- Type Safety: Strongly typed structs for all Grafana components
- JSON Compatibility: Generates JSON that is compatible with Grafana’s API
§Usage
use dmsc::prelude::*;
fn example() -> DMSCResult<()> {
// Create a new dashboard
let mut dashboard = DMSCGrafanaDashboard::new("DMSC Metrics");
// Create a panel
let panel = DMSCGrafanaPanel {
title: "Request Rate".to_string(),
query: "rate(http_requests_total[5m])".to_string(),
panel_type: "graph".to_string(),
grid_pos: DMSCGridPos {
h: 8,
w: 12,
x: 0,
y: 0,
},
};
// Add panel to dashboard
dashboard.add_panel(panel)?;
// Convert to JSON for Grafana API
let json = dashboard.to_json()?;
println!("Dashboard JSON: {}", json);
Ok(())
}Structs§
- DMSC
Grafana Dashboard - Grafana dashboard configuration
- DMSC
Grafana Dashboard Generator - Grafana dashboard generator
- DMSC
Grafana Panel - Grafana panel configuration
- DMSC
Grafana Tag - Grafana dashboard tag
- DMSC
Grafana Target - Grafana target configuration for data sources
- DMSC
Grafana Time Range - Grafana time range configuration
- DMSC
Grid Pos - Grafana grid position configuration