Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana configuration #53874

Merged
merged 2 commits into from Feb 6, 2019
Merged

Grafana configuration #53874

merged 2 commits into from Feb 6, 2019

Conversation

atopuzov
Copy link
Contributor

@atopuzov atopuzov commented Jan 13, 2019

Provision data sources and dashboards declarativly
http://docs.grafana.org/administration/provisioning/

Example usage:

    provision = {
      enable = true;
      datasources = [
        {
          type = "prometheus";
          name = "prometheus";
          url = "http://localhost:9090";
        }
      ];
      dashboards = [
        {
          options.path = "/etc/nixos/grafana-dashboards";
        }
      ];
    };

This adds prometheus as datasource to grafana and a dashboard provider path "/etc/nixos/grafana-dashboards" which is scanned by grafana and dashboards are automatically added.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for doing this! I recently configured a Grafana and I missed such a feature! I tested this locally in a VM and it seems fine.

Below are some review comments. Feel free to ping me if you need further assistance.

Also, please rename your commits as described in the contribution guidelines, i.e. nixos/grafana: implement dashboard & datasource provisioning.

nixos/modules/services/monitoring/grafana.nix Outdated Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Outdated Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Outdated Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Outdated Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Outdated Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Outdated Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Outdated Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Outdated Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Show resolved Hide resolved
nixos/modules/services/monitoring/grafana.nix Show resolved Hide resolved
@atopuzov
Copy link
Contributor Author

atopuzov commented Feb 5, 2019

@Ma27 Updated per comments

Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in a VM, I really like it 👍

I'll write some changelog, but I guess that this should be mergable then.

@Ma27
Copy link
Member

Ma27 commented Feb 6, 2019

rebased onto master and added a changelog entry.

@Ma27
Copy link
Member

Ma27 commented Feb 6, 2019

@atopuzov thanks!

@bhipple
Copy link
Contributor

bhipple commented Mar 15, 2019

Thanks for the work here; declarative grafana provisioning looks really slick and I'm looking forward to trying it out in NixOS 19.03!

@arianvp
Copy link
Member

arianvp commented Nov 3, 2019

I have found some bugs with this. For some reason, non of the introduced options here actually get typechecked by the nixos module system.

E.g. you can omit any of the fields and it will just compile. Also if you mistype any of the fields it works, and it also works when you use the wrong type anywhere.

I have a feeling the typechekcing is somehow disabled due to the custom apply function used; but not sure.

e.g. the following config just works, whilst it's clearly wrong:

      grafana.provision.datasources = [
        {
          # name = "hello"; # name is mandatory but I can leave it out
          editable = "hello i should be a boolean but i made it a string";
          type = "prometheus";
          url = "http://127.0.0.1:9090"; # TODO make configurable
        }
      ];

@arianvp
Copy link
Member

arianvp commented Nov 3, 2019

Nevermind I forgot to enable provision.enable ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants