grafana/dashboard-linter

Value validation

Closed this issue · 2 comments

xorima commented

Hi,

Before building such a feature I wanted to seek opinions from others as to if this should be part of this tool and if it is even valuable to others.

Problem I am trying to solve

There are values which I want to have set a specific way in my dashboards, for example:

  1. editable must always be false
  2. tags must be from a given list of approved tags (stops a lot of spelling & singular vs plural issues)
  3. some variables must always be set to the all
    etc

Proposed solution

Add in a config/cli flags to support additional checks based on desired outputs, with appropriate rules.
So we might have a rule called dashboard is not editable and that would only be enabled based on a flag.

Or some way of saying this json path should always look like this because it's how I need things to look in my world view. for example:

cfg:

valueMatchers:
  - path: "foo.bar"
     value:
       type: "exact" 
       value: "hello world"
  - path: "tags"
     value:
       type: "in" 
       list:
         - foo
         - bar

I'm sure I'm not explaining this 100% clearly but feedback would be

Hi Jason! I think our preference here is to follow the lead set by tools like gofmt and golint - that is: no options and a set of opinionated rules that apply to everyone. My hesitation with your suggestions are that they won't apply to everyone - except perhaps the "all" value for templates.

xorima commented

Fair point @tomwilkie, since writing this and thinking more about it I think OPA can probably achieve what I want it to achieve.

The only 1 generic rule from the above that might be worth including here is that dashboards defined in json should have editable set to false