Coder Social home page Coder Social logo

dashboard-spec's Introduction

DEPRECATED: Note, this repo is no-longer under active development. Whilst it was used to render Grafonnet's library for Grafana 7.0, future schema work is happening inside Grafana itself.

THIS REPOSITORY IS NOT BEING MAINTAINED. A SCHEMA IS NOW BEING BUILT DIRECTLY INTO GRAFANA ITSELF.

Grafana Dashboard Spec

Schema description documents for Grafana Dashboard JSON and core panels using the OpenAPI Specification.

Also in this repository is a code generator that uses the schema documents to generate libraries for writing Grafana dashboards as code.

Repo Layout

Human-managed specification YAML files.

Style Guide for Spec Files

All properties of an object should be defined alphabetically.

All properties should have a description. This is used for API doc generation.

File names should be in camel case. All files referenced as a schema component in a spec.yml should begin with a capital letter (PascalCase). Files containing shared schema components like "gridPos" or "threshold" should be named with a leading underscore.

Each spec directory should have child directories "panels", "targets", "templates" for organizing schema files. All files should live in those directories except "Dashboard.yml" and "spec.yml".

If a property's name could be more descriptive in code or it collides with another name nested in the same object, use the title field to indicate what that object should be called in code. For example, some panels have a top-level array called links and also a nested array called links. The top-level array is referring to panel links while the nested array is referring to data links, therefore, the properties have title set to "Panel Link" and "Data Link". The code generator should use this field instead for deciding method names. Depending on what the language has set for its object inflection property, this will result in methods like, addPanelLink() and addDataLink().

Templates for the code generator. Child directories are named after the language they contain templates for.

Each language must implement the following templates:

  • main.tmpl: this is intended to be the "entrypoint" for the generated code. It should import all other files or do whatever is necessary to tie everything together.
  • dashboard.tmpl: for generating the dashboard object and file.
  • panel.tmpl: for generating panel objects and files.
  • target.tmpl: for generating target objects and files.
  • template.tmpl: for generating template objects and files.
  • _shared.tmpl: shared template file available to all other templates. This is useful for defining reusable template code for others to share.

templates/docs.tmpl is an exception because it is language agnostic. All languages use this template for documentation generation.

Style Guide for Templates

Object arrays should have "appender" methods. For example addLink() and addTarget().

Objects nested one level should have "setter" methods with all simple fields as arguments. For example, setGridPos() and setLegend().

If fields need special processing, set them as readOnly and implement static methods for setting them. For example if you need to add an incrementing id field like we do when adding panels to a dashboard.

If a property is readOnly and also has a default, set the default as a static value on the object.

Code Generator

The code generator is a Go program in this repository. Currently only supported is Jsonnet for spec 7.0. Use it locally with:

go run . 7.0 jsonnet

This will produce the generated files in _gen/7.0/jsonnet/. Generated files are updated and committed to the _gen branch after every commit to master. See the Generated Code section for direct links.

Generated Code

The generated code lives in this repository's _gen branch.

Spec Documents

Libraries

dashboard-spec's People

Contributors

julienduchesne avatar malcolmholmes avatar samjewell avatar sdboyer avatar stsmdt avatar trotttrotttrott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dashboard-spec's Issues

Use maps internally for dashboard panels in jsonnet library

When we render Jsonnet for adding panels to dashboards, we add a panel to a list. In Jsonnet, this makes it difficult to later interact with those dashboards.

There's a simple trick that can solve this: have the addPanel method add the panel to a hidden map, and add its name to a hidden field order list. Then, render the actual panel list from these with a simple for loop.

This way, the dashboard can later be amended by patching the panel map without the need for iteration as would be needed if it were a list.

Please add examples

The examples in the old repository and the current one make reference to grafana.singlestat which no longer exists in 7.0. Please update the repo with even a minimal example that uses the 7.0 library.

Add Description Field to Existing Schemas

Bug: Annotations miss query attribute

When using the addAnnotation() function for panels the query attribute (among others) is missing.

I tried passing the query string to the existing rawQuery attribute but this is not accepted by Grafana.

Apart from that the textColumn and tagsColumn attributes should be available to account for the "Field mappings" for influx Queries.

Please add a license

grafonnet-lib readme says:

We very much appreciate contributions in grafana/dashboard-spec for components yet to be added.

but there's no license in this repo :). Adding one could clear up some confusion.

Complete 7.0 Schemas

We'd like to include all core features and plugins as defined in grafana/grafonnet-lib/CONTRIBUTING.md.

  • Alert List
  • Azure Monitor
  • Bar gauge
  • CloudWatch
  • Dashboard list
  • Elasticsearch
  • Gauge
  • Graph
  • Graphite
  • Heatmap
  • InfluxDB
  • Jaeger
  • Logs
  • Loki
  • Microsoft SQL Server
  • MySQL
  • News
  • OpenTSDB
  • Plugin list
  • PostgreSQL
  • Prometheus
  • Singlestat (deprecated)
  • Stackdriver
  • Stat
  • Table
  • Table (old) (deprecated)
  • TestData DB
  • Text
  • Zipkin

Builds fail on master

Hello, I am interested in contributing to this project. When I attempted to run go run . 7.0 jsonnet on a newly cloned master the build unfortunately failed with the following error message open _gen/7.0/spec.json: no such file or directory. Are builds only intended to work on the _gen branch or is there an issue with the master branch?

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.