jakubplichta / grafana-dashboard-builder

Generate Grafana dashboards with YAML
Apache License 2.0
147 stars 42 forks source link

Use yaml components from different files #153

Closed manueligno78 closed 5 years ago

manueligno78 commented 5 years ago

Actually this is a question, with a new sample request.

I am struggling to understand how to have two yaml files, one with my project definition and one with some variables that I want to reuse also in other projects.

I know that you can run grafana-dashboard-builder passing a folder to path parameter. And It works, but I cannot still create a reference between the two files... I'll try to explain better.

What I want to do is this:

Given a project file like this:

---
- name: test Project Dashboards
  project:
    service:
      - service1
      - service2
      - service3
    dashboards:
      - TestDashboard

- name: TestDashboard
  dashboard:
    title: 'TestDashboard'
...
    templates:
    - custom-template:
        name: service
        options: '{service}'
        includeAll: true
        multi: true
        current: All
...

I want to remove the list from project file and move it to another file (services.yaml), because I would like to reuse the same list on other dashboards/projects

Can you help me to understand?

jakubplichta commented 5 years ago

Well this is a bit harder.. what you can definitely do is to define project and dashboard in 2 distinct files and then pass folder or explicitly both files to builder.. if you need to reuse service property between multiple projects than there is only context support left to use - https://github.com/jakubplichta/grafana-dashboard-builder/blob/master/samples/config.yaml#L11-L13

You can find more at https://github.com/jakubplichta/grafana-dashboard-builder#external-context-definition

Builder at this moment does not support any other reusable block of variables.

manueligno78 commented 5 years ago

looking at today needs on my side, splitting yaml into project and dashboards is a good solution Thank you @jakubplichta