### Optional: Quickstart Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/docker.mdx Sets up a quickstart configuration with a fake device and starts hyperglass using Docker Compose. ```shell cp /opt/hyperglass/.samples/sample_devices.yaml /etc/hyperglass/devices.yaml cd /opt/hyperglass docker compose up ``` -------------------------------- ### Optional: Quickstart Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/manual.mdx Quickstart hyperglass with default settings and a fake device. ```shell curl -o /etc/hyperglass/devices.yaml https://raw.githubusercontent.com/thatmattlove/hyperglass/main/.samples/sample_devices.yaml hyperglass start ``` -------------------------------- ### Example with Defaults Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config.mdx Example configuration file with default values. ```yaml org_name: Beloved Hyperglass User plugins: [] primary_asn: 65000 request_timeout: 90 site_description: Beloved Hyperglass User Network Looking Glass site_title: Beloved Hyperglass User ``` -------------------------------- ### Install hyperglass Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/manual.mdx Install hyperglass via PyPI after cloning the repository. ```shell git clone https://github.com/thatmattlove/hyperglass --depth=1 cd hyperglass # optional - switch to the latest stable release # git switch -c v2.0.4 v2.0.4 pip3 install -e . ``` -------------------------------- ### Example Query Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/plugins.mdx An example query sent to hyperglass. ```json { "query_target": "192.0.2.0/24", "query_location": "your_location", "query_type": "ip_route_directive" } ``` -------------------------------- ### Menus Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/web-ui.mdx Example configuration for custom menus in the footer. ```yaml web: menus: - title: Terms & Conditions content: | **Don't** break stuff! _please_ side: right order: 1 - title: Help content: /path/to/help/file.md side: left order: 0 ``` -------------------------------- ### Highlighting Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/web-ui.mdx Example configuration for highlighting special values in router output. ```yaml web: highlight: - pattern: "65000:1234" label: Special snowflake community that does a thing color: primary - pattern: '^192\.0\.2\.[0-9]+$' label: Magical IP Address color: blue ``` -------------------------------- ### Device Configuration Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices.mdx An example of how to configure a device in the `devices.yaml` file, including its name, address, platform, and attributes for sourcing commands. ```yaml devices: - name: New York, NY address: 192.0.2.1 platform: cisco_ios attrs: source4: 192.0.2.1 source6: "2001:db8::1" ``` -------------------------------- ### Header Authentication Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices/http-device.mdx Example of sending an HTTP GET request with an Authorization header. ```yaml devices: - name: New York, NY address: 192.0.2.1 http: path: /path/to/query/device headers: Authorization: your special token ``` -------------------------------- ### Create a systemd service Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/manual.mdx Create and enable a systemd service for hyperglass. ```shell curl -o /etc/hyperglass/hyperglass.service https://raw.githubusercontent.com/thatmattlove/hyperglass/main/.samples/hyperglass-manual.service ln -s /etc/hyperglass/hyperglass.service /etc/systemd/system/hyperglass.service systemctl daemon-reload systemctl enable hyperglass systemctl start hyperglass ``` -------------------------------- ### Title Mode Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/web-ui.mdx Example of configuring the title mode in the web UI. ```yaml web: text: title: Our Looking Glass subtitle: Company Name, Inc. title_mode: text_only ``` -------------------------------- ### Syslog Configuration Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/logging.mdx Example configuration for sending logs to a syslog server. ```yaml logging: syslog: host: log.example.com port: 514 ``` -------------------------------- ### Non-HTTPS Request Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices/http-device.mdx Example of sending an HTTP GET request using the HTTP scheme. ```yaml devices: - name: New York, NY address: 192.0.2.1 http: path: /path/to/query/device scheme: http ``` -------------------------------- ### Create app directory Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/manual.mdx Create the application directory for hyperglass. ```shell mkdir /etc/hyperglass ``` -------------------------------- ### API Docs Configuration Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/api-docs.mdx Example configuration for the API documentation section, including base URL, enable status, path, title, description, and endpoint-specific settings. ```yaml docs: base_url: https://lg.example.com enable: true mode: redoc path: /api/docs title: Beloved Hyperglass User Looking Glass API Documentation description: null # API Endpoints ↓ devices: title: Devices description: List of all devices/locations with associated identifiers, display names, networks, & VRFs. summary: Devices List info: title: System Information description: General information about this looking glass. summary: System Information queries: title: Supported Queries description: List of supported query types. summary: Query Types query: title: Supported Query description: Request a query response per-location. summary: Query the Looking Glass ``` -------------------------------- ### Generic HTTP Logging Configuration Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/logging.mdx Example configuration for sending logs via HTTP POST to a generic endpoint with Basic Authentication. ```yaml logging: http: provider: generic host: https://httpbin.org headers: x-special-header: super special header value params: source: hyperglass verify_ssl: true timeout: 5 authentication: mode: basic username: your username password: super secret password ``` -------------------------------- ### Slack Webhook Logging Configuration Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/logging.mdx Example configuration for sending logs to a Slack webhook. ```yaml logging: http: provider: slack host: ``` -------------------------------- ### Select Directive Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/directives.mdx Example of a select directive. ```yaml your-directive: name: BGP Community rules: - condition: null command: show ip bgp community {target} field: description: BGP community to show options: - value: "65001:1" description: Provider A Routes - value: "65001:2" description: Provider B Routes ``` -------------------------------- ### With Directives Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices.mdx An example where an additional directive `cisco-show-lldp-neighbors` is added to the built-in directives. ```yaml devices: - name: New York, NY address: 192.0.2.1 platform: cisco_ios credential: username: you password: your password directives: - cisco-show-lldp-neighbors ``` -------------------------------- ### Font Override Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/web-ui.mdx Example of overriding the default body font. ```yaml web: theme: fonts: body: Inter ``` -------------------------------- ### Enable Specifc Built-in Directives Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices.mdx In this example, only specified built-in directives are made available. ```yaml devices: - name: New York, NY address: 192.0.2.1 platform: cisco_ios credential: username: you password: your password directives: - builtin: [bgp_route, traceroute] ``` -------------------------------- ### Upgrade to v2.0.4 using Docker Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/upgrading.mdx This command sequence demonstrates how to upgrade your Hyperglass installation to version 2.0.4 using Docker Compose. It involves stopping the current containers, removing old resources, fetching the new version, rebuilding the images, and starting the new version. ```shell cd /opt/hyperglass docker compose down docker compose rm -f git fetch git checkout v2.0.4 docker compose build docker compose up ``` -------------------------------- ### Microsoft Teams Webhook Logging Configuration Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/logging.mdx Example configuration for sending logs to a Microsoft Teams webhook. ```yaml logging: http: provider: msteams host: ``` -------------------------------- ### Greeting Configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/web-ui.mdx Example configuration for enabling and customizing the greeting modal in the web UI. ```yaml web: greeting: enable: true file: /path/to/your/file.md title: Welcome button: Continue required: false ``` -------------------------------- ### Color Override Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/web-ui.mdx Example of overriding the default primary color by mapping it to a different intrinsic color. ```yaml web: theme: colors: cyan: "#00ffff" ``` -------------------------------- ### Using a Python dictionary to define configuration parameters Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/overview.mdx Example of using a Python dictionary named 'main' to define configuration parameters for hyperglass. ```python main = { "org_name": "Your Organization Name", "web": { "theme": { "colors": { "blue": "#0000ff", } } } } ``` -------------------------------- ### Logo Configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/web-ui.mdx Example configuration for setting custom logos and favicons in the web UI. ```yaml web: logo: light: /path/to/light-logo.svg dark: /path/to/dark-logo.svg favicon: /path/to/favicon.svg width: 100% height: null ``` -------------------------------- ### Using a Python function to define configuration parameters Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/overview.mdx Example of using a Python function named 'main' to define configuration parameters for hyperglass. ```python def main(): return { "org_name": "Your Organization Name", "web": { "theme": { "colors": { "blue": "#0000ff", } } } } # The main function can also be an async function. async def main(): config = await some_function_to_fetch_config() return config ``` -------------------------------- ### Text Directive Example Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/directives.mdx Example of a text directive expecting a string value matching a regex pattern. ```yaml your-directive: name: IP Route rules: - condition: null command: show ip route {target} field: description: IP of target validation: '[0-9a-f\.\:]+' ``` -------------------------------- ### Use an SSH Proxy When Connecting to a Device Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices/ssh-proxy.mdx This example demonstrates how to configure an SSH proxy in the devices.yaml file. It shows how to specify the proxy address, port, and credentials, as well as the target device's address and credentials. ```yaml devices: - name: New York, NY address: 192.0.2.1 credential: username: you password: your password proxy: address: 203.0.113.1 credential: username: your proxy username password: your proxy password ``` -------------------------------- ### Default Caching Configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/caching.mdx Example of the default caching configuration in YAML format. ```yaml cache: timeout: 120 show_text: true ``` -------------------------------- ### Username & Password Authentication Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices/credentials.mdx Example configuration for authenticating to a device using a username and password. ```yaml devices: - name: New York, NY address: 192.0.2.1 platform: cisco_ios credential: username: you password: your password ``` -------------------------------- ### Year Constant Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/license.mdx A JavaScript constant to dynamically get the current year for copyright notices. ```javascript export const Year = () => new Date().getFullYear(); ``` -------------------------------- ### Disable Built-in Directives Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices.mdx In this example, _only_ the `cisco-show-lldp-neighbors` directive will be available. Built-in directives are disabled. ```yaml devices: - name: New York, NY address: 192.0.2.1 platform: cisco_ios credential: username: you password: your password directives: - builtin: false - cisco-show-lldp-neighbors ``` -------------------------------- ### Run Multiple Commands Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/directives.mdx This example illustrates how to configure a directive to run multiple commands based on a condition, useful for querying BGP communities. ```yaml your-directive: name: BGP Communities rules: - condition: "65000:[0-9]+" commands: - "show route table inet.0 community {target} detail" - "show route table inet6.0 community {target} detail" ``` -------------------------------- ### Regex Validation Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/directives.mdx This example shows how to use a regex pattern as a condition for validating input, specifically for DNS queries. ```yaml your-directive: name: DNS Query rules: - condition: '^.+\.yourdomain\.com$' ``` -------------------------------- ### Custom Message Configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/messages.mdx Example of how to customize the 'general' message in the configuration file. ```yaml message: general: Something with wrong. ``` -------------------------------- ### Basic HTTP Configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices/http-device.mdx Example of sending an HTTP POST request with basic authentication and SSL verification disabled. ```yaml devices: - name: New York, NY address: 192.0.2.1 http: path: /path/to/query/device method: POST verify_ssl: false basic_auth: username: you password: your password ``` -------------------------------- ### Deny a Specific Prefix Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/directives.mdx This example shows how to deny a specific IP prefix using a hyperglass directive. ```yaml your directive: name: BGP Route rules: - condition: "192.0.2.0/24" action: deny - condition: "0.0.0.0/0" command: "show ip bgp {target}" ``` -------------------------------- ### No Validation Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/directives.mdx This example demonstrates a directive with no validation, where any query input will pass and be used in the command. ```yaml your-directive: name: IP Route rules: - condition: null command: show ip route {target} ``` -------------------------------- ### SSH Private Key Authentication Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices/credentials.mdx Example configuration for authenticating to a device using an SSH private key. ```yaml devices: - name: San Francisco, CA address: 192.0.2.2 platform: juniper credential: username: you key: /path/to/your/ssh/key ``` -------------------------------- ### Redis Password Authentication Configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/CHANGELOG.md Example of how to configure Redis password authentication in hyperglass.yaml and the corresponding Redis configuration. ```yaml cache: password: examplepassword ``` ```text requirepass examplepassword ``` -------------------------------- ### Require IPv4 Queries between /8 and /24 Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/directives.mdx This example demonstrates how to configure an IP rule to require IPv4 queries within a specific prefix length range. ```yaml your-directive: name: IP Route rules: - condition: 0.0.0.0/0 ge: 8 le: 24 command: "show ip route {target} {mask}" ``` -------------------------------- ### Download hyperglass Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/docker.mdx Clones the hyperglass repository and sets up the necessary directory structure. ```shell mkdir /etc/hyperglass cd /opt git clone https://github.com/thatmattlove/hyperglass.git --depth=1 cd /opt/hyperglass ``` -------------------------------- ### Create a systemd service Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/docker.mdx Copies the hyperglass systemd service file, creates a symbolic link, reloads the daemon, and enables/starts the hyperglass service. ```shell cp /opt/hyperglass/.samples/hyperglass-docker.service /etc/hyperglass/hyperglass.service ln -s /etc/hyperglass/hyperglass.service /etc/systemd/system/hyperglass.service systemctl daemon-reload systemctl enable hyperglass systemctl start hyperglass ``` -------------------------------- ### Simple Device Configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/examples/basic-configuration.mdx A basic hyperglass configuration for defining devices. ```yaml devices: - name: NYC Router 1 address: credential: username: password: platform: cisco_ios attrs: source4: source6: ``` -------------------------------- ### Simple Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/devices.mdx A basic configuration for two devices, one Cisco IOS and one Juniper. ```yaml devices: - name: New York, NY address: 192.0.2.1 platform: cisco_ios credential: username: you password: your password - name: San Francisco, CA address: 192.0.2.2 platform: juniper credential: username: you password: your password ``` -------------------------------- ### Copy NGINX configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/reverse-proxy.mdx Copies the sample NGINX configuration file and creates a symbolic link to enable it. ```shell cp /opt/hyperglass/.samples/hyperglass.nginx /etc/nginx/sites-available/hyperglass ln -s /etc/nginx/sites-available/hyperglass /etc/nginx/sites-enabled/hyperglass ``` -------------------------------- ### Create the Directive Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/examples/add-your-own-command.mdx This YAML snippet defines a new custom directive named 'show-bgp-summary' which executes the 'show bgp all summary' command on a device. ```yaml show-bgp-summary: name: BGP Summary rules: - condition: null command: show bgp all summary field: null ``` -------------------------------- ### Copy Caddyfile Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/installation/reverse-proxy.mdx Copies the sample Caddyfile to the Caddy configuration directory. ```shell cp /opt/hyperglass/.samples/Caddyfile /etc/caddy/Caddyfile ``` -------------------------------- ### Associate the Directive with the Device Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/examples/add-your-own-command.mdx This YAML snippet shows how to associate the newly created 'show-bgp-summary' directive with a specific device configuration. ```yaml devices: - name: Your Router address: 192.0.2.1 platform: cisco_ios directives: - show-bgp-summary ``` -------------------------------- ### Show RPKI State from the Device's Perspective Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/structured-output.mdx Configuration to set the RPKI mode to 'router' to use the device's view of the RPKI state. ```yaml structured: rpki: mode: router ``` -------------------------------- ### Add a Link to the Footer Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/examples/customize-the-ui.mdx You can add links to the footer in the config.yaml file. ```yaml web: links: - title: PeeringDB url: https://www.peeringdb.com/65000 show_icon: true side: right order: 1 - title: Our Website url: https://example.com show_icon: false side: left order: 0 ``` -------------------------------- ### Original Command Output Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/plugins.mdx The command that would have been sent without the transform plugin. ```text show ip route 192.0.2.0/24 ``` -------------------------------- ### Transformed Command Output Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/plugins.mdx The command sent to the device after the CIDR prefix is transformed. ```text show ip route 192.0.2.0 255.255.255.0 ``` -------------------------------- ### Directives Configuration Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/plugins.mdx YAML configuration for directives, referencing the transform plugin. ```yaml ip_route_directive: name: IP Route plugins: - "/path/to/your/transform_plugin.py" rules: - condition: "0.0.0.0/0" action: permit command: "show ip route {target}" - condition: "::/0" action: permit command: "show ipv6 route {target}" ``` -------------------------------- ### Show RPKI State from a Public/External Perspective Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/structured-output.mdx Configuration to set the RPKI mode to 'external' to use an external service's view of the RPKI state. ```yaml structured: rpki: mode: external ``` -------------------------------- ### Selectively Enable Built-in Directives Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/examples/add-your-own-command.mdx This YAML snippet shows how to selectively enable only specific built-in directives, such as 'bgp_route' and 'traceroute', while disabling others. ```yaml devices: - name: Your Router address: 192.0.2.1 platform: cisco_ios directives: - builtins: [bgp_route, traceroute] ``` -------------------------------- ### Change the Logo Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/examples/customize-the-ui.mdx You can change the logo for light and dark mode in the config.yaml file. ```yaml web: logo: light: dark: ``` -------------------------------- ### Upgrade hyperglass-agent Source: https://github.com/thatmattlove/hyperglass/blob/main/CHANGELOG.md If you use hyperglass-agent, you must upgrade your version of hyperglass-agent to 0.1.6 or later. If using hyperglass-agent with SSL, this release will require you to re-generate & re-send your SSL certificates to hyperglass. ```bash $ hyperglass-agent certificate $ hyperglass-agent send-certificate ``` -------------------------------- ### Deny Listed Communities by Regex pattern Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/structured-output.mdx Configuration to deny BGP communities that match the specified regex patterns or exact strings. ```yaml 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. ``` -------------------------------- ### Transform CIDR Plugin Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/plugins.mdx A Python plugin to transform a CIDR prefix to network address and netmask. ```python from ipaddress import ip_network from hyperglass.plugins import InputPlugin class TransformCIDR(InputPlugin): def transform(self, query): (target := query.query_target) target_network = ip_network(target) if target_network.version == 4: return f"{target_network.network_address!s} {target_network.netmask!s}" return target ``` -------------------------------- ### Permit only Listed Communities Source: https://github.com/thatmattlove/hyperglass/blob/main/docs/pages/configuration/config/structured-output.mdx Configuration to permit only BGP communities that match the specified regex patterns or exact strings. ```yaml structured: communities: mode: permit items: - "^65000:.*$" # permit any communities starting with 65000, but no others. - "1234:1" # permit only the 1234:1 community. ```