Skip to content

Commit

Permalink
updated docs for release v0.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
FloSch62 committed Apr 19, 2024
1 parent 4160162 commit ebde8d3
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The `clab-io-draw` project unifies two tools, `clab2drawio` and `drawio2clab`. T

`clab2drawio` is a Python script that automatically generates Draw.io diagrams from Containerlab YAML configurations. It aims to simplify the visualization of network designs by providing a graphical representation of container-based network topologies.

For detailed information on `clab2drawio`, including features, options, and usage instructions, please refer to the [clab2drawio.md](docs/clab2drawio.md) file located in the same directory as this README.
For detailed information on `clab2drawio`, including features (like [`Grafana`](docs/grafana.md) Dashboard creation), options, and usage instructions, please refer to the [clab2drawio.md](docs/clab2drawio.md) file located in the same directory as this README.

## drawio2clab

Expand All @@ -33,8 +33,9 @@ docker pull ghcr.io/srl-labs/clab-io-draw:latest
Run drawio2clab or clab2drawio within a Docker container by mounting the directory containing your .drawio/.yaml files as a volume. Specify the input and output file paths relative to the mounted volume:

```bash
docker run -v "$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i lab-examples/clos03/cfg-clos.clab.yml
docker run -it -v "$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i lab-examples/clos03/cfg-clos.clab.yml
```
*Note: The `-it` option is for interactive mode and is only needed if using `-I`.*

```bash
docker run -v "$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i output.drawio
Expand Down
16 changes: 12 additions & 4 deletions docs/clab2drawio.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
## Features

- **Automatic Diagram Generation**: Converts containerlab YAML configurations into detailed Draw.io diagrams in vertical and horizontal layouts.
- **Intelligent Node Placement**: Attempts to determine the best placement for nodes automatically. However, for complex topologies, this can be challenging.
- **Graph-level-Based Layout**: Organizes nodes into graph-level based on their connectivity for clearer topology visualization. Users can influence node placement by specifying graph-level directly in the containerlab configuration.
- **Automatic Node Placement**: Attempts to determine the best placement for nodes automatically. However, for complex topologies, this can be challenging.
- **Graph-level-Based Layout**: Organizes nodes into graph-level based on their connectivity for clearer topology visualization. Users can influence node placement by specifying graph-level directly in the containerlab configuration. Also possible with `-I` to set it interactive
- **Graph-icon Support**: Enhances node visualization by allowing users to specify graph-icon labels such as router, switch, or host to define custom icons for nodes in the generated diagrams.
- **Customizable Styles**: Supports customization of node and link styles within the diagrams.
- **Grafana Dahsboards**: Supports to autogenerate Grafana dashboards in Grafana style. (WIP)

![Grafana ](img/grafana.png)

- For more detailed information about this feature, including compatibility, usage guidelines, and future enhancements, please see the [Grafana Dashboard Documentation](./grafana.md).

## Usage
To generate a network topology diagram from a containerlab YAML file, run the following command:
Expand Down Expand Up @@ -59,11 +64,14 @@ Using graph-level helps manage the vertical alignment of nodes in the generated
```bash
python clab2drawio.py -i <path_to_your_yaml_file> -o <path_to_output_file>
```
- `-g, --gf_dashboard`: Generates a grafana dashboard in grafana style. (WIP)
- `-g, --gf_dashboard`: Generates a Grafana dashboard in Grafana style. (WIP)

```bash
python clab2drawio.py -i <path_to_your_yaml_file> -g
python clab2drawio.py -i <path_to_your_yaml_file> -g --theme grafana_dark
```

For more detailed information about this feature, including compatibility, usage guidelines, and future enhancements, please see the [Grafana Dashboard Documentation](./grafana.md).

- `--include-unlinked-nodes`: Include nodes without any links in the topology diagram. By default, only nodes with at least one connection are included.

- `--no-links`: Do not draw links between nodes in the topology diagram. This option can be useful for focusing on node placement or when the connectivity between nodes is not relevant.
Expand Down
227 changes: 227 additions & 0 deletions docs/grafana.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
### Grafana Dashboard Generation Option

The `-g, --gf_dashboard` command line option is designed to automate the generation of Grafana dashboards with all it's rules from your YAML configuration files. This feature is currently in a **work-in-progress (WIP)** stage. When using this option, it is important to note the following specifics:

![Grafana ](img/grafana.png)

#### Features
- Ports are showing up and down (red/green)
- Links are showing it's bandwidth + colors for utilization
- All trafic is outgoing metric

#### Compatibility
- **Grafana Version:** This option is tailored to work optimally with Grafana version **10.3.5**. Buggy from 10.4 upwords
- **Plugin Requirement:** It requires the Flowcharting plugin version **1.0.0.e**, which is available via a specific fork maintained by [skyfrank on GitHub](https://github.com/skyfrank/grafana-flowcharting). This plugin is essential for rendering the custom visualizations generated by the script. Lower version also work, but this one is recommended

#### Usage
To generate a dashboard, execute the following command:
```bash
python clab2drawio.py -i <path_to_your_yaml_file> -g --theme grafana_dark
```
Ensure that you replace `<path_to_your_yaml_file>` with the actual path to your YAML configuration file. Use it with grafana_dark or your own grafana compatible theme.

#### Current Limitations
- **Hardcoded Queries:** Currently, the dashboard queries are hardcoded and are specifically optimized for Nokia's SRLinux and SROS platforms. This means they may not be directly applicable to other environments without modifications.
- **Data Sources:** The dashboard assumes specific data sources (Prometheus) are already configured in your Grafana instance that align with the hardcoded queries.

<details>
<summary><b>Recommended gnmic.yaml Configuration for SROS and SRL</b> (Click to expand)</summary>


```yaml
username: admin
password: *******
insecure: true
log: true

common_sros_subscriptions: &common_sros_subs
insecure: true
password: ******
subscriptions:
- sros-if-stats
- sros-bgp-stats
- sros-service-stats

common_srl_subscriptions: &common_srl_subs
port: 57400
skip-verify: true
insecure: false
password: *******
subscriptions:
- srl-if-stats
- srl-bgp
- srl-system-performance
- srl-routes
- srl-bridge
- srl-apps
- srl-net-instance

targets:
dc1-l1: *common_srl_subs
dc1-l2: *common_srl_subs
dc1-l3: *common_srl_subs
dc1-l4: *common_srl_subs
dc1-s1: *common_srl_subs
dc1-s2: *common_srl_subs
dc2-l1: *common_srl_subs
dc2-l2: *common_srl_subs
dc2-l3: *common_srl_subs
dc2-l4: *common_srl_subs
dc2-s1: *common_srl_subs
dc2-s2: *common_srl_subs
wan1: *common_sros_subs
wan2: *common_sros_subs
dc1_dcgw1: *common_sros_subs
dc2_dcgw2: *common_sros_subs
dc2_dcgw1: *common_sros_subs
dc1_dcgw2: *common_sros_subs

subscriptions:
## SROS ###
sros-if-stats:
paths:
- /state/port[port-id=*]/oper-state
- /state/port[port-id=*]/ethernet/statistics
mode: stream
stream-mode: sample
sample-interval: 1s

sros-bgp-stats:
paths:
- /state/router[router-name=*]/bgp/statistics/peers
- /state/router[router-name=*]/bgp/neighbor[ip-address=*]/statistics/session-state
- /state/router[router-name=*]/bgp/neighbor[ip-address=*]/statistics/family-prefix/ipv4
- /state/router[router-name=*]/bgp/neighbor[ip-address=*]/statistics/family-prefix/evpn
mode: stream
stream-mode: sample
sample-interval: 5s

sros-service-stats:
paths:
- /state/service/vpls[service-name=*]/oper-state
- /state/service/vprn[service-name=*]/oper-state
mode: stream
stream-mode: sample
sample-interval: 5s


srl-system-performance:
mode: stream
stream-mode: sample
sample-interval: 5s
paths:
- /platform/control[slot=*]/cpu[index=all]/total
- /platform/control[slot=*]/memory
srl-if-stats:
mode: stream
stream-mode: sample
sample-interval: 3s
paths:
- /interface[name=ethernet-1/*]/oper-state
- /interface[name=ethernet-1/*]/statistics
- /interface[name=ethernet-1/*]/traffic-rate
srl-routes:
mode: stream
stream-mode: sample
sample-interval: 5s
paths:
- /network-instance[name=*]/route-table/ipv4-unicast/statistics/
- /network-instance[name=*]/route-table/ipv6-unicast/statistics/
srl-bgp:
mode: stream
stream-mode: sample
sample-interval: 5s
paths:
- /network-instance[name=*]/protocols/bgp/statistics
srl-bridge:
mode: stream
stream-mode: sample
sample-interval: 5s
paths:
- /network-instance[name=*]/bridge-table/statistics/
srl-apps:
paths:
- /system/app-management/application[name=*]
mode: stream
stream-mode: sample
sample-interval: 5s
srl-net-instance:
paths:
- /network-instance[name=*]/oper-state
mode: stream
stream-mode: sample
sample-interval: 5s

outputs:
prom-output:
type: prometheus
#listen: "gnmic:9804"
listen: :9273
# export-timestamps: true
#service-registration:
# address: consul:8500
event-processors:
- trim-prefixes
- rename-port-sros
- rename-port-value-sros
- rename-srl-interface
- oper-state-to-int

processors:
trim-prefixes:
event-strings:
value-names:
- "^/state/.*"
transforms:
- trim-prefix:
apply-on: "name"
prefix: "/state/"

oper-state-to-int:
event-strings:
value-names:
- ".*"
transforms:
- replace:
apply-on: "value"
old: "up"
new: "1"
- replace:
apply-on: "value"
old: "down"
new: "0"
rename-port-sros:
event-strings:
tag-names:
- "^port_port-id"
transforms:
- replace:
apply-on: "name"
old: "port_port-id"
new: "interface_name"
rename-port-value-sros:
event-strings:
tag-names:
- "^interface_name"
transforms:
- replace:
apply-on: "value"
old: ".*/c(\\d+)(/\\d+)?"
new: "eth$1"
rename-srl-interface:
event-strings:
tag-names:
- "^interface_name"
transforms:
- replace:
apply-on: "value"
old: "ethernet-(\\d+)/(\\d+)"
new: "e$1-$2"
```
</details>
#### Future Enhancements
- **Configurable Queries:** Plans are in place to enhance this feature by allowing users to configure dashboard queries through a YAML config file. This will enable a more flexible and dynamic approach to adapting the dashboards for different environments and requirements.
#### Contributing
Feedback and contributions are welcome to help advance this feature towards a more robust and flexible implementation. If you are interested in contributing or have suggestions, please refer to the project's contribution guidelines or submit an issue on the project's GitHub repository.
Binary file added docs/img/grafana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ebde8d3

Please sign in to comment.