1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-17 08:48:05 +00:00

improve docs

This commit is contained in:
thatmattlove 2024-03-20 18:49:51 -04:00
parent cea421c939
commit 5f3b669388
14 changed files with 313 additions and 422 deletions

View file

@ -42,7 +42,7 @@ When using a Python file for a hyperglass configuration, one of the following me
#### Define a Function Named `main`
```python
```python filename="Example: Using a Python function to define configuration parameters"
def main():
return {
"org_name": "Your Organization Name",
@ -63,7 +63,7 @@ async def main():
#### Define a Dictionary Named `main`
```python
```python filename="Example: Using a Python dictionary to define configuration parameters"
main = {
"org_name": "Your Organization Name",
"web": {

View file

@ -158,37 +158,37 @@ When structured output is available, hyperglass checks the RPKI state of each BG
Additionally, hyperglass provides the ability to control which BGP communities are shown to the end user.
| Parameter | Type | Default Value | Description |
| :---------------------------- | :-------------- | :------------ | :---------------------------------------------------------------------------------------------------------------------------- |
| :----------------------------- | :-------------- | :------------ | :---------------------------------------------------------------------------------------------------------------------------- |
| `structured.rpki` | String | router | Use `router` to use the router's view of the RPKI state (1 above), or `external` to use Cloudflare's view (2 above). |
| `structured.communities.mode` | String | deny | Use `deny` to deny any communities listed in `structured.communities.items`, or `permit` to _only_ permit communities listed. |
| `structured.communities.items | List of Strings | | |
| `structured.communities.items` | List of Strings | | List of communities to match. |
#### Community Filtering Examples
##### Deny Listed Communities by Regex pattern
```yaml filename="config.yaml"
```yaml filename="config.yaml" {5-6}
structured:
communities:
mode: deny
items:
- '^65000:1\d+$' # don't show any communities starting with 65000:1. 65000:1234 would be denied, but 65000:4321 would be permitted.
- '65000:2345' # don't show the 65000:2345 community.
- "65000:2345" # don't show the 65000:2345 community.
```
##### Permit only Listed Communities
```yaml filename="config.yaml"
```yaml filename="config.yaml" {5-6}
structured:
communities:
mode: permit
items:
- '^65000:.*$' # permit any communities starting with 65000, but no others.
- '1234:1' # permit only the 1234:1 community.
- "^65000:.*$" # permit any communities starting with 65000, but no others.
- "1234:1" # permit only the 1234:1 community.
```
### Caveats
#### Arista EOS
For whatever reason, Arista EOS does not supply certain details about routes in its JSON output when running commands `show ip bgp regex <pattern>` or `show ip bgp community <community>`. Specifically, the the route's timestamp and any attached communities are not supplied. When these commands are used with Arista EOS, hyperglass sets the timestamp to the current time, and the community to an empty list.
For whatever reason, the tested version of Arista EOS does not supply certain details about routes in its JSON output when running commands `show ip bgp regex <pattern>` or `show ip bgp community <community>`. Specifically, the the route's timestamp and any attached communities are not supplied. When these commands are used with Arista EOS, hyperglass sets the timestamp to the current time, and the community to an empty list.

View file

@ -17,7 +17,7 @@ Console, file, HTTP, and/or syslog logging configuration.
##### Syslog Example
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
logging:
syslog:
host: log.example.com
@ -52,7 +52,7 @@ Authentication is supported using HTTP basic authentication or an API key.
##### Generic
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
logging:
http:
provider: generic
@ -73,7 +73,7 @@ In the above example, hyperglass will send a `POST` request to `https://httpbin.
##### Microsoft Teams Webhook
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
logging:
http:
provider: msteams
@ -82,7 +82,7 @@ logging:
##### Slack
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
logging:
http:
provider: slack

View file

@ -1,5 +1,5 @@
import { Callout } from 'nextra-theme-docs';
import { Color } from '~/components/color';
import { Callout } from "nextra-theme-docs";
import { Color } from "~/components/color";
## Web UI
@ -31,7 +31,7 @@ hyperglass provides extensive customization options for the look and feel of the
##### Example
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
web:
logo:
light: /path/to/light-logo.svg
@ -59,7 +59,7 @@ The greeting is an optional modal/popup window that will present itself to users
##### Example
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
web:
greeting:
enable: true
@ -91,10 +91,10 @@ Each value you wish to be highlighted is defined with the following schema:
##### Example
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
web:
highlight:
- pattern: '65000:1234'
- pattern: "65000:1234"
label: Special snowflake community that does a thing
color: primary
- pattern: '^192\.0\.2\.[0-9]+$'
@ -115,7 +115,7 @@ hyperglass can show completely-customizable menus in the footer. Each menu can b
##### Example
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
web:
menus:
- title: Terms & Conditions
@ -144,7 +144,7 @@ hyperglass can show customizable links to anything you think your users might fi
##### Example
```yaml filename="config.yaml"
```yaml filename="config.yaml" copy
web:
links:
- title: PeeringDB
@ -165,12 +165,12 @@ web:
| :-------- | :-----: | :-----: | :--------------------------------------------------------------------------------------- |
| `enable` | Boolean | `true` | Enable or disable the display of developer credit & link to hyperglass GitHub repository |
<Callout>
<Callout emoji="❤️" type="info">
**Note from the Developer**
<br /> If your organization's policy allows, and you don't mind, I request that you keep `credit` enabled.
Remember: my goal for this project is get more networks to use looking glasses to make all of our lives
easier. Because it's primarily other network operators who will use this tool to begin with, I'd love
for any operators that use your looking glass to know where they can get their own.
<br /> If your organization's policy allows, and you don't mind, I request that you keep `credit`
enabled. Remember: my goal for this project is get more networks to use looking glasses to make all
of our lives easier. Because it's primarily other network operators who will use this tool to begin
with, I'd love for any operators that use your looking glass to know where they can get their own.
</Callout>
### Text
@ -206,10 +206,12 @@ Most of the text in the hyperglass UI can be overridden to suit your needs.
Available title modes are:
- `logo_only` only the logo is displayed, no title or subtitle will be visible.
- `text_only` only the title and subtitle are displayed, no logo will be visible.
- `logo_subtitle` only the logo and subtitle are displayed, no title will be visible.
- `all` logo, title, and subtitle will all be visible.
| `title_mode` Value | Action |
| :----------------- | :------------------------------------------------------------------ |
| `logo_only` | Only the logo is displayed, no title or subtitle will be visible. |
| `text_only` | Only the title and subtitle are displayed, no logo will be visible. |
| `logo_subtitle` | Only the logo and subtitle are displayed, no title will be visible. |
| `all` | Logo, title, and subtitle will all be visible. |
##### Example
@ -269,7 +271,7 @@ To override hyperglass's primary color, it's recommended to override its mapped
web:
theme:
colors:
cyan: '#00ffff'
cyan: "#00ffff"
```
#### Fonts

View file

@ -59,7 +59,7 @@ Each configured device may have the following parameters:
## Simple
```yaml filename="devices.yaml"
```yaml filename="devices.yaml" copy
devices:
- name: New York, NY
address: 192.0.2.1
@ -77,7 +77,7 @@ devices:
## With Directives
```yaml filename="devices.yaml"
```yaml filename="devices.yaml" copy {8-9}
devices:
- name: New York, NY
address: 192.0.2.1
@ -91,7 +91,7 @@ devices:
## With an SSH Proxy
```yaml filename="devices.yaml"
```yaml filename="devices.yaml" copy {8-12}
devices:
- name: New York, NY
address: 192.0.2.1

View file

@ -45,47 +45,51 @@ A rule is a way of saying "if a query target matches the rule's conditions, run
##### Require IPv4 Queries between /8 and /24
```yaml filename="directives.yaml"
```yaml filename="directives.yaml" {5-6} /{target} {mask}/ copy
your-directive:
name: IP Route
rules:
- condition: 0.0.0.0/0
ge: 8
le: 24
command: 'show ip route {target} {mask}'
command: "show ip route {target} {mask}"
```
Given a query target of 198.18.0.0/15, the command run on the device would be `show ip route 198.18.0.0 255.254.0.0`
Given a query target of 198.18.0.0/15, the command run on the device would be:
```none /198.18.0.0 255.254.0.0/
show ip route 198.18.0.0 255.254.0.0
```
##### Deny a Specific Prefix
```yaml
```yaml filename="directives.yaml" {5} copy
your directive:
name: BGP Route
rules:
- condition: '192.0.2.0/24'
- condition: "192.0.2.0/24"
action: deny
- condition: '0.0.0.0/0'
command: 'show ip bgp {target}'
- condition: "0.0.0.0/0"
command: "show ip bgp {target}"
```
In this example, a query of any IP address or prefix contained within 192.0.2.0/24 will result in an error.
##### Run Multiple Commands
```yaml filename="directives.yaml"
```yaml filename="directives.yaml" /{target}/ {6-7} copy
your-directive:
name: BGP Communities
rules:
- condition: '65000:[0-9]+'
- condition: "65000:[0-9]+"
commands:
- 'show route table inet.0 community {target} detail'
- 'show route table inet6.0 community {target} detail'
- "show route table inet.0 community {target} detail"
- "show route table inet6.0 community {target} detail"
```
In this example, a query of `65000:1` would result in the following commands being sent to the device:
```
```none /65000:1/
show route table inet.0 community 65000:1 detail
show route table inet6.0 community 65000:1 detail
```
@ -96,7 +100,7 @@ The output for both commands will be shown as the query result.
To validate input by regex pattern, just specify a regex pattern as the `condition`
```yaml filename="directives.yaml"
```yaml filename="directives.yaml" copy
your-directive:
name: DNS Query
rules:
@ -105,7 +109,7 @@ your-directive:
### No Validation
```yaml filename="directives.yaml"
```yaml filename="directives.yaml" /{target}/ copy {4}
your-directive:
name: IP Route
rules:
@ -113,7 +117,11 @@ your-directive:
command: show ip route {target}
```
In this example, any query would pass, regardless of query input. For instance, if a user selected this directive/query type and queried 'your mom', the real command sent to the device will be `show ip route your mom`.
In this example, any query would pass, regardless of query input. For instance, if a user selected this directive/query type and queried `your mom`, the real command sent to the device will be:
```none /your mom/
show ip route your mom
```
## Fields
@ -145,7 +153,7 @@ Each select option uses the following schema:
Example of a text directive expecting a string value matching a regex pattern:
```yaml filename="directives.yaml"
```yaml filename="directives.yaml" copy {6-7}
your-directive:
name: IP Route
rules:
@ -157,7 +165,7 @@ your-directive:
Example of a select directive:
```yaml filename="directives.yaml"
```yaml filename="directives.yaml" copy {6-12}
your-directive:
name: BGP Community
rules:
@ -165,8 +173,8 @@ your-directive:
command: show ip bgp community {target}
field:
options:
- value: '65001:1'
- value: "65001:1"
description: Provider A Routes
- value: '65001:2'
- value: "65001:2"
description: Provider B Routes
```

View file

@ -7,7 +7,7 @@ import { Callout } from "nextra-theme-docs";
To get started, hyperglass only needs to know about your devices.
<Callout>
<Callout type="info">
**Devices** are your routers, switches, or whatever else you want to call the endpoints
hyperglass will query for information.
</Callout>

View file

@ -3,8 +3,7 @@ title: Introduction
description: Get started with hyperglass
---
import Link from "next/link";
import { Button } from "nextra/components";
import { Cards, Card } from "nextra/components";
import platforms from "~/platforms.json";
export const Platforms = () => (
@ -41,6 +40,6 @@ hyperglass was created with the lofty goal of benefiting the internet community
- Query multiple devices simultaneously
- Browser-based DNS-over-HTTPS resolution of FQDN queries
<Link href="/installation">
<Button className="nx-my-2 nx-py-2 nx-px-4">Get Started</Button>
</Link>
<Cards>
<Card title="Get Started" href="installation/docker" arrow />
</Cards>

View file

@ -1,145 +1,11 @@
---
title: Installation
description: Installing hyperglass
---
import { Cards, Card } from "nextra/components";
import { Callout, Tab, Tabs } from 'nextra-theme-docs';
<Cards>
<Card href="installation/docker" title="Using Docker" />
<Card href="installation/manual" title="Manual Installation" />
</Cards>
## Docker
<Callout type="info">
**Docker is the recommended method for running hyperglass.**
</Callout>
### 1. [Install Docker](https://docs.docker.com/engine/install/)
### 2. Download hyperglass
```shell copy
mkdir /etc/hyperglass
cd /opt
git clone https://github.com/thatmattlove/hyperglass/tree/v2.0.0 --depth=1
```
### Quickstart (optional)
Do this if you just want to see the hyperglass page working with a fake device.
```shell copy
cp /opt/hyperglass/.samples/sample_devices.yaml /etc/hyperglass/devices.yaml
cd /opt/hyperglass
docker compose up
```
Navigate to http://localhost:8001
### 3. Setup Reverse Proxy
[Caddy](https://caddyserver.com) is recommended, but any reverse proxy ([NGINX](https://www.nginx.com), [Apache2](https://httpd.apache.org)) will work.
#### Caddy
[**Install Caddy**](https://caddyserver.com/docs/install)
```shell copy
cp /opt/hyperglass/.samples/Caddyfile /etc/caddy/Caddyfile
```
Change the `lg.example.com` and `person@example.com` values to match your hyperglass FQDN and email address (the email address is for automatic SSL certificate generation via Let's Encrypt).
<Callout type="info">
If you prefer to use other Let's Encrypt validation methods or your own SSL certificate, modify your `/etc/hyperglass/Caddyfile` in accordance with the [Caddy docs](https://caddyserver.com/docs/caddyfile-tutorial).
</Callout>
Restart the Caddy service: `systemctl restart caddy{:shell}`
#### NGINX
```shell copy
cp /opt/hyperglass/.samples/hyperglass.nginx /etc/nginx/sites-available/hyperglass
ln -s /etc/nginx/sites-available/hyperglass /etc/nginx/sites-enabled/hyperglass
```
Change the `lg.example.com` value to match your hyperglass FQDN.
Change the `<path to cert chain>` and `<path to key>` values to match the path to your certificate and private key files.
## Automatic installation
If your system runs on:
- Ubuntu/Debian Linux
- ~~CentOS/Red Had Linux~~
You should be able to proceed with the automatic installation:
```bash
curl https://install.hyperglass.dev | sudo bash
```
<Callout type="warning">
**Piping to bash**
<br /> You should be _very_ worried when someone asks you to do what I just did. Downloading a bash
script from the internet and piping it to `bash` with root privileges is a terrible idea, unless you
fully trust the source. Please don't trust me - go [look at the code](https://github.com/thatmattlove/hyperglass/blob/v1.0.0/install.sh)
and determine for your self if it's safe to execute. If you feel it's not, please proceed with the
manual installation (and [tell me why](https://github.com/thatmattlove/hyperglass/issues), so I can
fix it).
</Callout>
## Manual Installation
### System Dependencies
#### Python
hyperglass is written in Python 3 and requires Python version **3.9** as a minimum dependency.
If you're confident upgrading your system's version of Python won't break your system (many Linux operating systems rely heavily on Python for package management and other system functions), you can install Python 3.9:
<Tabs items={["Debian/Ubuntu", "RHEL/CentOS"]}>
<Tab>
```bash
sudo apt install -y python3-dev python3-pip
```
</Tab>
<Tab>
Documentation for CentOS is still in-progress. However, it's been determined that these dependencies _may_ also be required, depending on the version of CentOS:
```bash
sudo yum install libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \
freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \
harfbuzz-devel fribidi-devel libraqm-devel libimagequant-devel \
libxcb-devel ncurses-devel
```
Until further testing with CentOS can be done, you should install the above dependencies _before_ installing Python 3. You may have to uninstall and re-install Python 3 if these dependencies weren't already installed.
You can install python from the CentOS 7 repository:
```bash
sudo yum install python3-devel python3-pip
```
But you can also use the [SCL repository](https://www.softwarecollections.org/en/scls/rhscl/rh-python36/)
```bash
sudo yum install centos-release-scl
sudo yum install rh-python36
```
</Tab>
</Tabs>
### Install hyperglass
Now that system dependencies are installed, you can install hyperglass.
```bash
pip3 install hyperglass
```
<Cards>
<Card href="installation/environment-variables" title="Environment Variables" />
<Card href="installation/reverse-proxy" title="Reverse Proxy" />
</Cards>

View file

@ -3,22 +3,25 @@ title: Using Docker
description: Installing hyperglass with Docker
---
import { Button } from "nextra/components";
import { Card, Cards, Steps } from "nextra/components";
import { Callout } from "nextra-theme-docs";
## Docker
<Callout type="info">**Docker is the recommended method for running hyperglass.**</Callout>
### 1. Install Docker
<Steps>
<Button className="nx-my-4 nx-py-2 nx-px-4 nx-font-bold">
<a target="_blank" href="https://docs.docker.com/engine/install/">
Docker Engine Installation Guide
</a>
</Button>
### Install Docker
### 2. Download hyperglass
<Cards>
<Card
title="Docker Engine Installation Guide"
href="https://docs.docker.com/engine/install/"
target="_blank"
arrow
/>
</Cards>
### Download hyperglass
```shell copy
mkdir /etc/hyperglass
@ -38,7 +41,7 @@ docker compose up
Navigate to http://localhost:8001
### 3. Create a `systemd` service
### Create a `systemd` service
<Callout type="info">
Before you create and start the hyperglass service, you may want to verify whether or not you
@ -52,3 +55,5 @@ systemctl daemon-reload
systemctl enable hyperglass
systemctl start hyperglass
```
</Steps>

View file

@ -3,9 +3,13 @@ title: Manual Installation
description: Installing hyperglass manually
---
import { Callout } from 'nextra-theme-docs';
import { Steps } from "nextra/components";
import { Callout } from "nextra-theme-docs";
<Steps>
### Install Dependencies
## Install Dependencies
To install hyperglass manually, you'll need to install the following dependencies:
1. [Python 3.9, 3.10, 3.11, or 3.12](https://www.python.org/downloads/)
@ -13,11 +17,9 @@ To install hyperglass manually, you'll need to install the following dependencie
3. [PNPM 8 or later](https://pnpm.io/installation)
4. [Redis 7.2 or later](https://redis.io/download/)
<Callout type="default">
Make sure the Redis server is started.
</Callout>
<Callout type="warning">Make sure the Redis server is started.</Callout>
## Install hyperglass
### Install hyperglass
Once these dependencies are installed, install hyperglass via PyPI:
@ -25,17 +27,18 @@ Once these dependencies are installed, install hyperglass via PyPI:
pip3 install hyperglass
```
## Create app directory
### Create app directory
<Callout type="info">
If you plan on using a different directory, be sure to set the directory you wish to use in your [environment variables](environment-variables.mdx).
If you plan on using a different directory, be sure to set the directory you wish to use in your
[environment variables](environment-variables.mdx).
</Callout>
```shell copy
mkdir /etc/hyperglass
```
## Optional: Quickstart
### Optional: Quickstart
Do this if you just want to see the hyperglass page working with default settings and a fake device.
@ -44,7 +47,7 @@ curl -o /etc/hyperglass/devices.yaml https://github.com/thatmattlove/hyperglass/
hyperglass start
```
## Create a `systemd` service
### Create a `systemd` service
```shell copy
curl -o /etc/hyperglass/hyperglass.service https://github.com/thatmattlove/hyperglass/blob/v2.0.0/.samples/hyperglass-manual.service
@ -55,6 +58,8 @@ systemctl start hyperglass
```
<Callout type="info">
If you used a different app directory from the default `/etc/hyperglass`, change the `EnvironmentFile` value in the `hyperglass.service` file.
If you used a different app directory from the default `/etc/hyperglass`, change the
`EnvironmentFile` value in the `hyperglass.service` file.
</Callout>
</Steps>

View file

@ -3,18 +3,16 @@ title: Reverse Proxy
description: Setting up a reverse proxy for hyperglass
---
import { Button } from "nextra/components";
import { Cards, Card } from "nextra/components";
import { Callout } from "nextra-theme-docs";
[Caddy](https://caddyserver.com) is recommended, but any reverse proxy ([NGINX](https://www.nginx.com), [Apache2](https://httpd.apache.org)) will work.
## Caddy
<Button className="nx-my-4 nx-py-2 nx-px-4 nx-font-bold">
<a target="_blank" href="https://caddyserver.com/docs/install">
Install Caddy
</a>
</Button>
<Cards>
<Card title="Install Caddy" target="_blank" href="https://caddyserver.com/docs/install" arrow />
</Cards>
```shell copy
cp /opt/hyperglass/.samples/Caddyfile /etc/caddy/Caddyfile

View file

@ -1,7 +1,14 @@
---
title: Plugins
description: hyperglass Plugins
---
import { Cards, Card } from "nextra/components";
Starting in version 2.0, hyperglass supports custom plugins. There are two main types of plugins:
- **Input Plugins**: Apply custom validation logic to or transform user input before the query is sent to a device.
- **Output Plugins**: Interact with the output from a device before it's displayed to the user.
- [**Input Plugins**](#input-plugins): Apply custom validation logic to or transform user input before the query is sent to a device.
- [**Output Plugins**](#output-plugins): Interact with the output from a device before it's displayed to the user.
Plugins are associated with a directive.
@ -13,7 +20,7 @@ Plugins are associated with a directive.
In this example, the following query is sent to hyperglass:
```json
```json filename="Example Query"
{
"query_target": "192.0.2.0/24",
"query_location": "your_location",
@ -41,14 +48,14 @@ class TransformCIDR(InputPlugin):
ip_route_directive:
name: IP Route
plugins:
- '/path/to/your/transform_plugin.py'
- "/path/to/your/transform_plugin.py"
rules:
- condition: '0.0.0.0/0'
- condition: "0.0.0.0/0"
action: permit
command: 'show ip route {target}'
- condition: '::/0'
command: "show ip route {target}"
- condition: "::/0"
action: permit
command: 'show ipv6 route {target}'
command: "show ipv6 route {target}"
```
When the query is received, the query target is transformed, resulting in this being sent to the device:

View file

@ -114,6 +114,7 @@ const config: DocsThemeConfig = {
},
feedback: { content: null },
footer: { text: `© ${new Date().getFullYear()} hyperglass` },
editLink: { component: null },
chat: {
link: "https://netdev.chat/",
icon: (