### Run Example Site Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/README.md Serve the example site from the theme's directory. Navigate to the exampleSite directory first. ```bash hugo server --themesDir ../.. ``` -------------------------------- ### Basic Hugo Site Setup and File Editing Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Demonstrates basic command-line operations for creating a file, adding front matter in TOML format, and saving changes. Use this for initial content setup. ```bash $ vi foo.md +++ date = "2014-09-28" title = "creating a new theme" +++ bah and humbug :wq ``` ```bash $ cat foo.md +++ date = "2014-09-28" title = "creating a new theme" +++ bah and humbug $ ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/grafana/grizzly/blob/main/CONTRIBUTING.md Vendor Go dependencies for the project. This ensures consistent builds. ```shell go mod vendor ``` -------------------------------- ### Show Grizzly JSONnet Example Source: https://github.com/grafana/grizzly/blob/main/examples/README.md Use this command to display the contents of a Grizzly JSONnet file. ```bash cd examples grr show grr.jsonnet ``` -------------------------------- ### Install Grizzly on Linux Source: https://github.com/grafana/grizzly/blob/main/docs/content/installation.md After downloading the latest release, move the file to /usr/local/bin/grr and make it executable. ```bash sudo mv $DOWNLOADED_FILE /usr/local/bin/grr sudo chmod +x /usr/local/bin/grr ``` -------------------------------- ### Syntax Highlighting Example Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/cupper-shortcodes/index.md Demonstrates how to use markdown code fences with a language specifier for syntax highlighting. ```html ```html

Confirmation

Press Okay to confirm or Cancel

``` ``` ```html

Confirmation

Press Okay to confirm or Cancel

``` -------------------------------- ### Get Configuration Values Source: https://github.com/grafana/grizzly/blob/main/docs/content/configuration.md Retrieve configuration values for the current context or specific settings. ```bash grr config get ``` ```bash grr config get grafana ``` ```bash grr config get grafana.url ``` -------------------------------- ### Build Hugo Docs with Server Mode Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/hugoisforlovers.md Use this command to clone the Hugo repository, navigate into it, and start the Hugo server to build the documentation site. It shows the output messages during the build process. ```bash git clone https://github.com/spf13/hugo cd hugo /path/to/where/you/installed/hugo server --source=./docs > 29 pages created > 0 tags index created > in 27 ms > Web Server is available at http://localhost:1313 > Press ctrl+c to stop ``` -------------------------------- ### Run Hugo Development Server Source: https://github.com/grafana/grizzly/blob/main/docs/README.md Initialize git submodules and start the Hugo development server with draft content enabled. Access the docs at http://localhost:1313/grizzly/. Changes are rendered instantly. ```bash git submodule init git submodule update hugo server -D -s docs ``` -------------------------------- ### Start Hugo Server Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Run the Hugo server with the --verbose flag to see detailed output during the build process. This helps in debugging and understanding Hugo's internal operations. ```bash $ hugo server --verbose ``` -------------------------------- ### Jekyll to Hugo Shortcode Usage Example Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/migrate-from-jekyll.md Demonstrates the conversion of a Jekyll Liquid tag to a Hugo shortcode. The example shows how to replace the old syntax with the new Hugo shortcode syntax, including parameter mapping. ```html {% image full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg "One of my favorite touristy-type photos. I secretly waited for the good light while we were "having fun" and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing." ->http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/ %} ``` ```html {{}} ``` -------------------------------- ### Start the Grizzly Server Source: https://github.com/grafana/grizzly/blob/main/docs/content/server.md Starts the Grizzly server, defaulting to port 8080. Use -b to open a browser and -p to specify a different port. ```bash grr serve ``` -------------------------------- ### Hugo Server Output Example Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Observe the detailed logs when running 'hugo server --verbose'. This output includes information about configuration files, syncing static assets, missing layouts, content status, and server availability. ```log INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml INFO: 2014/09/29 syncing from /Users/quoha/Zafta/static/ to /Users/quoha/Zafta/public/ WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] WARN: 2014/09/29 Unable to locate layout: [404.html] 0 draft content 0 future content 0 pages created 0 tags created 0 categories created in 2 ms Serving pages from /Users/quoha/Zafta/public Web Server is available at http://localhost:1313 Press Ctrl+C to stop ``` -------------------------------- ### Install Grizzly on macOS and Linux Source: https://context7.com/grafana/grizzly/llms.txt Install Grizzly using Homebrew on macOS or by downloading the release binary for Linux. Building from source is also an option. ```bash # macOS via Homebrew brew install grizzly # Linux: download latest release binary sudo mv grr-linux-amd64 /usr/local/bin/grr sudo chmod +x /usr/local/bin/grr # Build from source git clone https://github.com/grafana/grizzly.git cd grizzly make dev sudo mv grr /usr/local/bin/grr ``` -------------------------------- ### Install Cupper Hugo Theme Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/README.md Add the Cupper Hugo theme as a Git submodule to your site's root directory. ```bash git submodule add https://github.com/zwbetz-gh/cupper-hugo-theme.git themes/cupper-hugo-theme ``` -------------------------------- ### Generate HTML for a New Site Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Run the `hugo` command to generate HTML files for your site. Use the `--verbose` flag to get detailed output, including information about file syncing and any layout warnings. ```bash $ hugo --verbose INFO: 2014/09/29 Using config file: config.toml INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] WARN: 2014/09/29 Unable to locate layout: [404.html] 0 draft content 0 future content 0 pages created 0 tags created 0 categories created in 2 ms $ ``` -------------------------------- ### Format Date in Single Template Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Display the publication date of a post using the `.Date.Format` method. This example shows how to format the date in a specific string format. ```gohtml {{ .Date.Format "Mon, Jan 2, 2006" }} ``` -------------------------------- ### Grizzly Proxy Server Source: https://context7.com/grafana/grizzly/llms.txt The `grr serve` command starts a local HTTP proxy that serves resources from disk through a live Grafana instance. This enables WYSIWYG editing and review without publishing changes directly. It supports options for opening the browser, custom ports, and watching for changes. ```bash grr serve ./resources/ ``` ```bash grr serve -b ./resources/ ``` ```bash grr serve -p 9090 ./resources/ ``` ```bash grr serve -w ./resources/ ``` ```bash grr serve -w my-dashboards.jsonnet ./ ``` ```bash grr serve -w my-dashboards.jsonnet 'examples/**.*sonnet' examples/vendor ``` ```bash grr serve -w -S 'npm run -s build' ./src ``` ```bash grr serve -w -b -p 3001 ./resources/ ``` -------------------------------- ### Define a Simple Grafana Dashboard in YAML Source: https://github.com/grafana/grizzly/blob/main/docs/content/what-is-grizzly.md Example YAML representation of a Grafana dashboard, inspired by Kubernetes resource definitions. This defines a basic 'Production Overview' dashboard. ```yaml apiVersion: grizzly.grafana.com/v1alpha1 kind: Dashboard metadata: name: prod-overview folder: general spec: schemaVersion: 17 tags: - templated timezone: browser title: Production Overview uid: prod-overview ``` -------------------------------- ### Get Remote Resource by UID Source: https://context7.com/grafana/grizzly/llms.txt Fetch a single resource from the remote system using its `.` reference. Supports YAML and JSON output, and can retrieve only the spec. ```bash # Get a dashboard by UID grr get Dashboard.prod-overview # apiVersion: grizzly.grafana.com/v1alpha1 # kind: Dashboard # metadata: # name: prod-overview # folder: my-folder # spec: # title: Production Overview # ... # Get a datasource grr get Datasource.prometheus # Get in JSON format grr get Dashboard.prod-overview -o json # Get only the spec (no envelope) grr get Dashboard.prod-overview --only-spec # Get an alert rule group grr get AlertRuleGroup.my-folder-uid.my-group # Get a Prometheus rule group grr get PrometheusRuleGroup.production_rules.app_alerts ``` -------------------------------- ### Render Prometheus Rules with Jsonnet Source: https://github.com/grafana/grizzly/blob/main/docs/content/jsonnet.md Define and render Prometheus alert and recording rules using Jsonnet. This example demonstrates defining a helper function for resource creation and separating rule definitions before exposing them. ```jsonnet { local rule(name, namespace, spec) = { apiVersion: 'grizzly.grafana.com/v1alpha1', kind: 'PrometheusRuleGroup', metadata: { name: name, namespace: namespace, }, spec: spec, }, grizzly_alerts:: { rules: [{ alert: 'PromScrapeFailed', expr: 'up != 1', 'for': '1m', labels: { severity: 'critical', }, annotations: { message: 'Prometheus failed to scrape a target {{ $labels.job }} / {{ $labels.instance }}', }, }], }, grizzly_records:: { rules: [{ record: 'job:up:sum', expr: 'sum by(job) (up)', }], }, prometheus_rules: [ rule('grizzly_alert_rules', 'grizzly_rules', $.grizzly_alerts), rule('grizzly_recording_rules', 'grizzly_rules', $.grizzly_records), ], } ``` -------------------------------- ### Watch and Review Jsonnet Script Changes Source: https://github.com/grafana/grizzly/blob/main/docs/content/server.md Starts the Grizzly server to watch and reload Jsonnet scripts. Specify the entrypoint and the directory to watch independently. Multiple sources can be watched. ```bash grr serve -w examples/grr.jsonnet examples ``` ```bash grr serve -w examples/grr.jsonnet examples/*.*sonnet examples/vendor ``` -------------------------------- ### Serve Local JSON or YAML Files Source: https://github.com/grafana/grizzly/blob/main/docs/content/server.md Starts the Grizzly server to serve local JSON or YAML dashboard files from a specified directory. Access the server at http://localhost:8080 by default. ```bash grr serve examples/yaml/ ``` -------------------------------- ### Watch and Review TypeScript Dashboard Changes Source: https://github.com/grafana/grizzly/blob/main/docs/content/server.md Sets up Grizzly to watch changes in TypeScript files for a Grafana dashboard. This example clones the Grafana Foundation SDK, installs dependencies, and starts the server with a script to compile and watch TypeScript files. ```bash git clone https://github.com/grafana/grafana-foundation-sdk cd grafana-foundation-sdk/examples/typescript/red-method npm install grr serve -w -S 'npm run -s dev' . ``` -------------------------------- ### Get a Resource by UID Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md Retrieve a specific resource from a remote system using its UID, which is a two-part identifier like `.`. For example, a dashboard might be `dashboard.my-uid`. ```sh $ grr get Dashboard.my-uid ``` -------------------------------- ### Install Grizzly on macOS via Homebrew Source: https://github.com/grafana/grizzly/blob/main/docs/content/installation.md Install Grizzly using Homebrew after ensuring Homebrew is installed on your system. ```bash brew install grizzly ``` -------------------------------- ### Build Grizzly from Source Source: https://github.com/grafana/grizzly/blob/main/docs/content/installation.md Clone the repository, navigate into the directory, and build the project using make. Then move the executable to the desired location. ```bash git clone https://github.com/grafana/grizzly.git cd grizzly make dev sudo mv grr /usr/local/bin/grr ``` -------------------------------- ### Chaining Actions with Pipes Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Demonstrates how pipes can be used to chain actions, similar to Unix pipes. The output of one action becomes the input of the next. ```go-html-template {{ if eq 1 1 }} Same {{ end }} ``` ```go-html-template {{ eq 1 1 | if }} Same {{ end }} ``` -------------------------------- ### Including Another Template Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Demonstrates how to include another template file, passing the current context ('.') to it. ```go-template {{ template "chrome/header.html" . }} ``` -------------------------------- ### Calling a Function with Parameters Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Shows how to call the 'add' function with two integer parameters, 1 and 2. ```go-template {{ add 1 2 }} ``` -------------------------------- ### Get Grizzly Config File Path Source: https://github.com/grafana/grizzly/blob/main/docs/content/configuration.md Display the file path to the current Grizzly configuration file. ```bash grr config path ``` -------------------------------- ### Markdown Block Code Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/cupper-typography.md Display larger blocks of code using triple backticks. This preserves formatting and syntax highlighting for code examples. ```markdown ```` This ``` ``` tag is block code. ```` ``` -------------------------------- ### Build and Verify Website Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Clean the public directory, build the Hugo site with verbose output, and then list the generated HTML files to verify the homepage content. ```bash $ rm -rf public $ hugo --verbose INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"} WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] 0 draft content 0 future content 2 pages created 0 tags created 0 categories created in 4 ms $ find public -type f -name '*.html' | xargs ls -l -rw-r--r-- 1 quoha staff 94 Sep 29 22:23 public/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/first/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/second/index.html $ cat public/index.html

second

first

$ ``` -------------------------------- ### Build and Verify Hugo Site Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Build the Hugo site using the 'hugo --verbose' command and verify the output by checking the generated index.html file. This confirms the static home page content. ```bash $ hugo --verbose INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] 0 draft content 0 future content 0 pages created 0 tags created 0 categories created in 2 ms $ find public -type f -name '*.html' | xargs ls -l -rw-r--r-- 1 quoha staff 78 Sep 29 21:26 public/index.html $ cat public/index.html

hugo says hello!

``` -------------------------------- ### List Theme Layout Files Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Use find and xargs to list all HTML files within a theme's layouts directory. This helps in understanding the theme's structure. ```bash $ find themes/zafta -name '*.html' | xargs ls -l -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/single.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html $ ``` -------------------------------- ### Prometheus Recording Rule Group Source: https://github.com/grafana/grizzly/blob/main/docs/content/prometheus.md Define a Prometheus recording rule group using the PrometheusRuleGroup kind. This example records the sum of 'up' metrics by job. ```yaml apiVersion: grizzly.grafana.com/v1alpha1 kind: PrometheusRuleGroup metadata: name: grizzly_recording_rules namespace: grizzly_rules spec: rules: - expr: sum by(job) (up) record: job:up:sum ``` -------------------------------- ### Locate Home Page and Theme Layout Files Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Use the find command to locate all index.html files, differentiating between the generated site's home page and the theme's layout file. ```bash $ find . -name index.html | xargs ls -l -rw-r--r-- 1 quoha staff 0 Sep 29 20:21 ./public/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 ./themes/zafta/layouts/index.html $ ``` -------------------------------- ### List Existing Contexts Source: https://github.com/grafana/grizzly/blob/main/docs/content/configuration.md Display all available Grizzly contexts. ```bash grr config get-contexts ``` -------------------------------- ### Build Grizzly from Source Source: https://github.com/grafana/grizzly/blob/main/CONTRIBUTING.md Build the Grizzly binary locally. This command compiles the project for development purposes. ```shell make dev ``` -------------------------------- ### Watch and Review YAML File Changes Source: https://github.com/grafana/grizzly/blob/main/docs/content/server.md Starts the Grizzly server with watch functionality enabled for a directory. Changes to files in the specified directory will automatically reload dashboards in Grafana. ```bash grr serve -w examples/yaml ``` -------------------------------- ### Set Output Format Source: https://github.com/grafana/grizzly/blob/main/docs/content/configuration.md Configure the default output format for retrieved resources. Can be overridden on the command line. ```bash grr config set output-format json ``` -------------------------------- ### Using Site Parameters with `with` Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md An alternative to `if` for checking site parameters. The `with` statement rebinds the context and skips the block if the parameter is absent, useful for optional content like social media links. ```go-html-template {{with .Site.Params.TwitterUser}}{{end}} ``` -------------------------------- ### Generate Hugo Site with Verbose Output Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Run the Hugo build command with the --verbose flag to see detailed information about the site generation process, including file syncing and warnings. ```bash $ hugo --verbose INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] 0 draft content 0 future content 0 pages created 0 tags created 0 categories created in 2 ms $ ``` -------------------------------- ### Create a New Hugo Site Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Use the `hugo new site` command to generate the basic directory structure and configuration file for a new Hugo site. Navigate into the newly created site directory. ```bash $ hugo new site ~/Sites/zafta $ cd ~/Sites/zafta $ ls -l total 8 drwxr-xr-x 7 quoha staff 238 Sep 29 16:49 . drwxr-xr-x 3 quoha staff 102 Sep 29 16:49 .. drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes -rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.toml drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 content drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layouts drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static $ ``` -------------------------------- ### Defining and Referencing a Variable Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Shows how to define a variable named '$address' and then reference its value. ```go-template {{ $address := "123 Main St."}} {{ $address }} ``` -------------------------------- ### Show Jsonnet Hidden Elements with Grizzly Source: https://github.com/grafana/grizzly/blob/main/examples/hidden-elements/README.md Use the 'grr show' command to display Jsonnet files containing hidden elements. This command is useful for inspecting examples that utilize this historical method. ```bash grr show testdata/hidden-elements/main.jsonnet ``` -------------------------------- ### Full Migration: Pull from Source, Push to Destination Source: https://context7.com/grafana/grizzly/llms.txt This sequence of commands demonstrates a full migration process. It involves creating and configuring two contexts, 'source' and 'destination', pulling resources from the source Grafana instance, and then pushing them to the destination. ```bash grr config create-context source grr config use-context source grr config set grafana.url https://grafana-old.example.com grr config set grafana.token glsa_source_token grr pull ./migrated-resources/ grr config create-context destination grr config use-context destination grr config set grafana.url https://grafana-new.example.com grr config set grafana.token glsa_dest_token grr push ./migrated-resources/ ``` -------------------------------- ### Apply Resources to Remote System Source: https://context7.com/grafana/grizzly/llms.txt Parse local resources and create or update them on the remote system. `push` is an alias for `apply`. Supports applying directories, single files, Jsonnet files, filtering by type, and continuing on errors. ```bash # Apply all resources in a directory grr apply ./resources/ # Applying 5 resources # + Dashboard.prod-overview added # ~ Datasource.prometheus updated # = DashboardFolder.my-folder no changes # Apply a single file grr apply dashboard.yaml # Apply a Jsonnet file grr apply my-dashboards.libsonnet # Apply only dashboards (ignore other kinds) grr apply -t Dashboard ./resources/ # Apply a specific resource by UID grr apply -t Dashboard.prod-overview ./resources/ # Continue on error instead of stopping at first failure grr apply --continue-on-error ./resources/ # Push (alias for apply) grr push ./resources/ ``` -------------------------------- ### Show Rendered Resources Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md Display the resources found after executing Jsonnet, rendered in the expected format for each resource type. This command is useful for previewing resources before applying them. ```sh $ grr show my-dir ``` -------------------------------- ### Build Hugo Website Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Build the static website using the 'hugo' command. This process generates all HTML files based on your content and theme. ```bash $ rm -rf public $ hugo --verbose INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 found taxonomies: map[string]string{"category":"categories", "tag":"tags"} WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] 0 draft content 0 future content 2 pages created 0 tags created 0 categories created in 4 ms $ ``` -------------------------------- ### Verify Generated HTML Files Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md List the generated HTML files in the 'public' directory to confirm that the posts were successfully built into static pages. ```bash $ find public -type f -name '*.html' | xargs ls -l -rw-r--r-- 1 quoha staff 78 Sep 29 22:13 public/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/first/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/second/index.html $ ``` -------------------------------- ### Create and Push Release Tag Source: https://github.com/grafana/grizzly/blob/main/CONTRIBUTING.md Create a Git tag for a new release and push it to the remote repository to trigger the release pipeline. ```shell git tag {version} && git push origin {version} ``` -------------------------------- ### Set Resource Target by Key Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md Use the `-t` or `--target` flag to specify resources by key, in the format `.`. Wildcards like `Dashboard.*` are supported, and lowercase resource types are also accepted. ```sh grr list ``` -------------------------------- ### List Resources in YAML Format Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md List all resources found after executing a Jsonnet file, with the output formatted as YAML. Other available formats include 'default', 'wide', and 'json'. ```sh $ grr list -f yaml my-dir ``` -------------------------------- ### Create Static Home Page Template Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Modify the index.html layout file to include basic HTML content for the home page. This sets up a static page before dynamic content is introduced. ```html $ vi themes/zafta/layouts/index.html

hugo says hello!

:wq $ ``` -------------------------------- ### Create Header and Footer Partials Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Define the HTML structure for header and footer partials. These files are placed in the `layouts/partials/` directory of your theme. ```html {{ .Title }} ``` ```html ``` -------------------------------- ### Watch Directory for Changes and Apply Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md Monitor a directory for file changes, execute Jsonnet, and push updates to remote systems. The watch command restarts if new subdirectories are added. ```sh $ grr watch . my-lib.libsonnet ``` -------------------------------- ### View Generated Index Page with Links Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Displays the content of the generated index.html file. Verifies that the links to individual posts are correctly rendered. ```bash $ cat public/index.html

second

first

``` -------------------------------- ### Using Site Parameters with `if` Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Demonstrates how to check for the existence of a site-wide parameter (`CopyrightHTML`) and render content if it's present. The `safeHtml` pipe ensures HTML is not double-escaped. ```go-html-template {{if .Site.Params.CopyrightHTML}}
{{.Site.Params.CopyrightHTML | safeHtml}}
{{end}} ``` -------------------------------- ### Find Single HTML Templates Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Lists all single.html layout files within the theme directory. Useful for understanding existing template structure. ```bash $ find themes/zafta -name single.html | xargs ls -l -rw-r--r-- 1 quoha staff 132 Sep 29 17:31 themes/zafta/layouts/_default/single.html ``` -------------------------------- ### Theme Directory Structure Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md After creating a new theme, this command lists the generated directory structure. It includes archetypes, content, layouts, public, static, and themes directories, along with initial theme files. ```bash $ ls -l total 8 drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes -rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.toml drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 content drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layouts drwxr-xr-x 4 quoha staff 136 Sep 29 17:02 public drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static drwxr-xr-x 3 quoha staff 102 Sep 29 17:31 themes $ find themes -type f | xargs ls -l -rw-r--r-- 1 quoha staff 1081 Sep 29 17:31 themes/zafta/LICENSE.md -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/archetypes/default.md -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/single.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html -rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html -rw-r--r-- 1 quoha staff 93 Sep 29 17:31 themes/zafta/theme.toml $ ``` -------------------------------- ### List Resources in a Directory Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md List all resources found after executing a Jsonnet file in a specified directory. The output format can be changed using the `-f` flag. ```sh $ grr list my-dir ``` -------------------------------- ### Accessing Site Parameters for Dynamic Content Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Shows how to use site parameters (e.g., `SidebarRecentLimit`) to dynamically control content, such as limiting the number of recent posts displayed in a navigation list. ```go-html-template ``` -------------------------------- ### Configure Grafana, Mimir, and Synthetic Monitoring Source: https://context7.com/grafana/grizzly/llms.txt Set authentication and provider credentials for Grafana, Mimir, or Grafana Cloud Synthetic Monitoring using `grr config set`. Settings can be overridden by environment variables. ```bash # --- Grafana --- grr config set grafana.url http://localhost:3000 grr config set grafana.token glsa_xxxxxxxxxxxxxxxxxxxx # service account token grr config set grafana.user admin # only for basic auth # --- Mimir / Grafana Cloud Prometheus --- grr config set mimir.address https://prometheus-prod-01-eu-west-0.grafana.net grr config set mimir.tenant-id 12345 grr config set mimir.api-key glc_abcdef1234567890 # --- Grafana Cloud Synthetic Monitoring --- grr config set synthetic-monitoring.access-token sm_xxxx grr config set synthetic-monitoring.url https://synthetic-monitoring-api.grafana.net # --- Output & targets --- grr config set output-format json # json | yaml (default: yaml) grr config set targets Dashboard,DashboardFolder grr config set only-spec true # omit envelope wrapper # Verify configuration and connectivity grr config check # Output: # Configuration file: /home/user/.config/grizzly/settings.yaml # Current context: default # Grafana # ======= # Active: true # Online: true ``` -------------------------------- ### Inspect Generated Public Directory Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md List the contents of the public directory after building the site to verify the generated files and directories, such as index.html, sitemap.xml, and static asset folders. ```bash $ ls -l public total 16 drwxr-xr-x 2 quoha staff 68 Sep 29 17:56 css -rw-r--r-- 1 quoha staff 0 Sep 29 17:56 index.html -rw-r--r-- 1 quoha staff 407 Sep 29 17:56 index.xml drwxr-xr-x 2 quoha staff 68 Sep 29 17:56 js -rw-r--r-- 1 quoha staff 243 Sep 29 17:56 sitemap.xml $ ``` -------------------------------- ### Managing Context within Loops Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Explains how the context '.' changes within a `range` loop. It demonstrates setting a variable outside the loop to retain access to the top-level context. ```go-html-template {{ $title := .Site.Title }} {{ range .Params.tags }}
  • {{ . }} - {{ $title }}
  • {{ end }} ``` -------------------------------- ### Build and Inspect Hugo Site Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Commands to clean the public directory, build the Hugo site with verbose output, and list generated HTML files. Verifies the build process and output. ```bash $ rm -rf public $ hugo --verbose INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"} WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] 0 draft content 0 future content 2 pages created 0 tags created 0 categories created in 4 ms $ find public -type f -name '*.html' | xargs ls -l -rw-r--r-- 1 quoha staff 94 Sep 29 22:40 public/index.html -rw-r--r-- 1 quoha staff 125 Sep 29 22:40 public/post/first/index.html -rw-r--r-- 1 quoha staff 0 Sep 29 22:40 public/post/index.html -rw-r--r-- 1 quoha staff 128 Sep 29 22:40 public/post/second/index.html ``` -------------------------------- ### List Remote Resources Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md List all resources available on configured remote providers. This command shows remote resources across all configured providers. ```sh $ grr list -r ``` -------------------------------- ### List Local Resources in a Directory Source: https://context7.com/grafana/grizzly/llms.txt List resources found in local files within a specified directory. Supports wide format for more details and different output formats like YAML or JSON. ```bash # List resources in a local directory grr list ./resources/ # API VERSION KIND UID # grizzly.grafana.com/v1alpha1 Dashboard prod-overview # grizzly.grafana.com/v1alpha1 DashboardFolder my-folder # grizzly.grafana.com/v1alpha1 Datasource prometheus # Wide format (includes path and format info) grr list -f wide ./resources/ # API VERSION KIND UID PATH LOCATION FORMAT # grizzly.grafana.com/v1alpha1 Dashboard prod-overview ./resources/dashboard.yaml . yaml # List as YAML or JSON grr list -f yaml ./resources/ grr list -f json ./resources/ # List remote resources (all configured providers) grr list -r # List remote resources for specific kinds grr list -r -t Dashboard,DashboardFolder # List resources in a single Jsonnet file grr list my-dashboards.jsonnet ``` -------------------------------- ### Create About Page Content Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Define front matter for a new 'about' page, including title, description, date, and slug. The slug influences the generated URL. ```markdown +++ title = "about" description = "about this site" date = "2014-09-27" slug = "about time" +++ ## about us i'm speechless :wq ``` -------------------------------- ### Verify Public Directory Contents Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md After running the `hugo` command, check the `public/` directory for generated files. Initially, with no content, it will contain standard XML files like `index.xml` and `sitemap.xml`. ```bash $ ls -l public total 16 -rw-r--r-- 1 quoha staff 416 Sep 29 17:02 index.xml -rw-r--r-- 1 quoha staff 262 Sep 29 17:02 sitemap.xml $ ``` -------------------------------- ### Compare Local vs. Remote Resources Source: https://context7.com/grafana/grizzly/llms.txt Compare local resources against their current state on the remote system and print a unified diff. Supports diffing directories, single files, Jsonnet files, and filtering by resource type. ```bash # Diff all resources in a directory grr diff ./resources/ # Dashboard.prod-overview # --- Remote # +++ Local # @@ -3,7 +3,7 @@ # title: Production Overview # - refresh: "" # + refresh: 30s # Diff a single Jsonnet file grr diff my-dashboards.libsonnet # Diff only specific resource types grr diff -t AlertRuleGroup ./resources/ # Diff with JSON output grr diff -o json ./resources/ ``` -------------------------------- ### Development Workflow Commands Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Essential commands for theme development: `rm -rf public` to purge old files and `hugo server --watch --verbose` to run the Hugo development server in watch mode. ```bash ## purge old files. hugo will recreate the public directory. ## $ rm -rf public ## ## run hugo in watch mode ## $ hugo server --watch --verbose ``` -------------------------------- ### Diff Jsonnet Resources with Remote System Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md Compare each resource rendered by Jsonnet with its equivalent on the remote system. This helps identify discrepancies before applying changes. ```sh $ grr diff my-lib.libsonnet ``` -------------------------------- ### Deploy Resources as Snapshots Source: https://github.com/grafana/grizzly/blob/main/docs/content/workflows.md Deploy resources as snapshots, currently supported for Grafana dashboards. This command prints out links for each uploaded snapshot. Expiration can be set using the `-e` flag. ```sh $ grr snapshot my-lib.libsonnet ``` -------------------------------- ### View Generated Post Content Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Inspect the content of the newly created post files using 'cat'. This shows the front matter and any initial content added by the archetype. ```bash $ cat content/post/first.md +++ Categories = [] Description = "" Tags = [] date = "2014-09-29T21:54:53-05:00" title = "first" +++ my first post $ cat content/post/second.md +++ Categories = [] Description = "" Tags = [] date = "2014-09-29T21:57:09-05:00" title = "second" +++ my second post $ ``` -------------------------------- ### Simplifying Complex Conditions with Pipes Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Illustrates how pipes can simplify complex conditional logic by chaining boolean functions. This makes the template more readable. ```go-html-template {{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}} Stuff Here {{ end }} ``` ```go-html-template {{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }} Stuff Here {{ end }} ``` -------------------------------- ### Display Principles Shortcode Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/cupper-shortcodes/index.md The `principles` shortcode allows you to display specific principles, optionally including their descriptions. Refer to the provided JSON file for the full list. ```html {{}} ``` ```html {{< principles include="Add value, Be consistent" descriptions="true" >}} ``` -------------------------------- ### Hugo Server Watch Mode Output Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Sample output from `hugo server --watch --verbose` showing file system events and site rebuilds. This demonstrates Hugo's live reload capability. ```bash $ rm -rf public $ hugo server --watch --verbose INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] 0 draft content 0 future content 0 pages created 0 tags created 0 categories created in 2 ms Watching for changes in /Users/quoha/Sites/zafta/content Serving pages from /Users/quoha/Sites/zafta/public Web Server is available at http://localhost:1313 Press Ctrl+C to stop INFO: 2014/09/29 File System Event: ["/Users/quoha/Sites/zafta/themes/zafta/layouts/index.html": MODIFY|ATTRIB] Change detected, rebuilding site WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] 0 draft content 0 future content 0 pages created 0 tags created 0 categories created in 1 ms ``` -------------------------------- ### Import Grizzly for Prometheus Ksonnet Source: https://github.com/grafana/grizzly/blob/main/examples/vendor/github.com/grafana/jsonnet-libs/grizzly/README.md Place this content in `grr.jsonnet` next to your `main.jsonnet` when deploying dashboards structured for prometheus-ksonnet or associated libraries, especially when other resources use Tanka. ```jsonnet local main = (import 'main.jsonnet'); local grizzly = (import 'grizzly/grizzly.libsonnet'); grizzly.fromPrometheusKsonnet(main) ``` -------------------------------- ### Basic Cmd Shortcode Usage Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/cmd-test.md This snippet shows the basic structure of the cmd shortcode. It is used to display arbitrary lines of text within a command-like block. ```go-html-template {{< cmd >}} Line 1 Line 2 Line 3 {{< /cmd >}} ``` -------------------------------- ### Enable Katex Math Typesetting Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/katex-math-typesetting/index.md Set the 'katex' parameter to 'true' in your Hugo configuration file to enable Katex. This action imports the necessary Katex CSS and JavaScript files. ```toml enableLatex = true ``` -------------------------------- ### Configure Hosted Prometheus/Mimir Source: https://github.com/grafana/grizzly/blob/main/docs/content/configuration.md Set the address, tenant ID, and API key for interacting with hosted Prometheus or Mimir instances, particularly for Grafana Cloud. ```sh grr config set mimir.address https://mimir.example.com # URL for Mimir instance or Grafana Cloud Prometheus instance ``` ```sh grr config set mimir.tenant-id myTenant # Tenant ID for your Grafana Cloud Prometheus account ``` ```sh grr config set mimir.api-key abcdef12345 # Authentication token (if you are using Grafana Cloud) ``` -------------------------------- ### Accessing Page Parameters Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md Illustrates accessing a page parameter named 'bar' using dot notation. ```go-template {{ .Params.bar }} ``` -------------------------------- ### Accessing the Page Title Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/goisforlovers.md A common pattern to set the HTML title tag using the page's .Title variable. ```go-template {{ .Title }} ``` -------------------------------- ### Create New Hugo Theme Source: https://github.com/grafana/grizzly/blob/main/docs/themes/cupper-hugo-theme/exampleSite/content/post/creating-a-new-theme.md Use the 'hugo new theme' command to generate the basic directory structure and essential files for a new Hugo theme. This command initializes the theme's skeleton. ```bash $ hugo new theme zafta ```