Giter Club home page Giter Club logo

grizzly's Introduction

Grizzly: A tool for Managing Observability Systems

A utility for managing various observability resources with Jsonnet. Currently supported are:

  • Grafana dashboards/dashboard folders
  • Grafana datasources
  • Grafana Cloud Prometheus recording rules/alerts
  • Grafana Synthetic Monitoring checks

It is designed to work with existing monitoring mixins.

Status: Alpha. This is a proof of concept. It will have many holes. PRs welcome.

Authentication and Configuration

Each system handles authentication differently.

Grafana Itself

This tool interacts with Grafana via its REST API. For this, you will need to establish authentication credentials. These are provided to grr via environment variables.

Name Description Required Default
GRAFANA_URL Fully qualified domain name of your Grafana instance. true -
GRAFANA_USER Basic auth username if applicable. false api_key
GRAFANA_TOKEN Basic auth password or API token. false -

See Grafana's Authentication API docs for more info.

Grafana Cloud Prometheus

To interact with Grafana Cloud Prometheus, you must have the cortextool binary available on your path (download it here), and must have these environment variables set:

Name Description Required
PROMETHEUS_ADDRESS URL for Grafana Cloud Prometheus instance true
PROMETHEUS_TENANT_ID Tenant ID for your Grafana Cloud Prometheus account true
PROMETHEUS_TOKEN Authentication token/api key true

Grafana Synthetic Monitoring

To interact with Grafana Synthetic Monitoring, you must have these environment variable set:

Name Description Required
GRAFANA_SM_TOKEN Authentication token/api key true

Commands

grr get

Retrieves a resource from the remote system, via its UID. Its UID will be two parts separated by a dot, <resource-type>.<resource-id>. A dashboard might be dashboard.mydash:

$ grr get dashboard.my-uid

grr list

List all resources found after executing Jsonnet file.

$ grr list my-lib.libsonnet

grr show

Shows the resources found after executing Jsonnet, rendered as expected for each resource type:

$ grr show my-lib.libsonnet

grr diff

Compares each resource rendered by Jsonnet with the equivalent on the remote system:

$ grr diff my-lib.libsonnet

grr apply

Uploads each dashboard rendered by the mixin to Grafana

$ grr apply my-lib.libsonnet

grr watch

Watches a directory for changes. When changes are identified, the jsonnet is executed and changes are pushed to remote systems. This example watches the current directory for changes, then executes my-lib.libsonnet when changes are noticed:

$ grr watch . my-lib.libsonnet

grr listen

The opposite to watch, when supported, this listens for changes on a remote system. When a change is noticed, the raw resource is downloaded and saved to a local named file.

$ grr listen dashboard.my-uid my-dash.json

grr export

Renders Jsonnet and saves resources as files directory which is specified with the second argument.

These resources can then be deployed This can be used with Grafana Provisioning to provision dashboards that can be picked up immediately by Grafana.

$ grr export some-mixin.libsonnet my-provisioning-dir

grr preview

When a backend supports preview functionality, this renders Jsonnet and uploads previews to endpoint systems.

At present, only Grafana dashboards are supported. With Grafana, it produces dashboard snapshots. It then prints out links for each snapshot that was uploaded.

$ grr preview my-lib.libsonnet

Grafana snapshots by default do not expire. Expiration can be set via the -e, --expires flag which takes a number of seconds as an argument.

Flags

-t, --target strings

The show, diff, and apply commands accept this flag. It allows the targeting of resources by key, where key is in the form <type>.<uid>.

Run grr list to get a list of resource keys in your code.

Grafana Dashboard Example

Create a file, called mydash.libsonnet, that contains this:

{

  grafanaDashboardFolder: 'my-folder', // optional

  grafanaDashboards+:: {
    'my-dash.json': {
      uid: 'prod-overview',
      title: 'Production Overview',
      tags: ['templated'],
      timezone: 'browser',
      schemaVersion: 16,
    },
  },
}

Note that this dashboard has a UID. Dashboard UIDs are required for grr to function correctly.

This file follows the standard Monitoring Mixin pattern, where resources are added to hidden maps at the root of the JSON output.

Now, we can see this rendered as a JSON dashboard with:

$ grr show mydash.libsonnet

Next, we need to interact with Grafana. You will need to export two environment variables: GRAFANA_TOKEN, an API token created within Grafana itself, and GRAFANA_HOST, the hostname for your Grafana installation. If the Grafana instance is not hosted at the root of the domain, you can add specify a hostname such as admin.example.com/grafana. If your Grafana does not use SSL, you can set GRAFANA_PROTOCOL to http.

Now, let's push our dashboard to Grafana:

$ grr apply mydash.libsonnet

At this point, you should find your dashboard has been uploaded and will be visible within the Grafana UI.

As a next step, we shall make a change to our dashboard. In your mydash.libsonnet, change the title to Production Overview mk2.

Then:

$ grr diff mydash.libsonnet

will show us the single change we have made to our dashboard.

And next:

$ grr apply mydash.libsonnet

will push our change up to Grafana. Check your Grafana dashboard list - you should see your dashboard show with its new name.

You can retrieve a dashboard from Grafana via its UID:

$ grr get prod-overview

grizzly's People

Contributors

deathborn avatar duologic avatar hoenn avatar jvrplmlmn avatar malcolmholmes avatar mavimo avatar sanhajio avatar sh0rez avatar thlacroix avatar trotttrotttrott avatar yazgoo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.